@@ -58,6 +58,43 @@ struct MOInputIsotopicByOutputs{S,T<:AbstractVector{S}} <: AbstractVector{Tuple{
58
58
out_dim:: Integer
59
59
end
60
60
61
+ """
62
+ MOInputsHeterotopic(x::AbstractVector, output_indices::Integer)
63
+
64
+ `MOInputsHeterotopic(x, output_indices)` has length `length(x)`.
65
+
66
+ ```jldoctest
67
+ julia> x = [1, 2, 3, 4, 5, 6];
68
+
69
+ julia> out_inds = [1, 1, 2, 3, 2, 1];
70
+
71
+ julia> KernelFunctions.MOInputsHeterotopic(x, out_inds)
72
+ 6-element KernelFunctions.MOInputsHeterotopic{Int64, Vector{Int64}}:
73
+ (1, 1)
74
+ (2, 1)
75
+ (3, 2)
76
+ (4, 3)
77
+ (5, 2)
78
+ (6, 1)
79
+ ```
80
+
81
+ Accommodates modelling multi-dimensional output data where not all outputs are observed
82
+ for every input.
83
+
84
+ As shown above, an `MOInputsHeterotopic` represents a vector of tuples.
85
+ The `length(x)` elements represent the inputs that are observed at the locations specified
86
+ by `output_indices`.
87
+ """
88
+ struct MOInputsHeterotopic{S ,T<: AbstractVector{S} } <: AbstractVector{Tuple{S,Int}}
89
+ x:: T
90
+ output_indices:: AbstractVector{Int}
91
+ end
92
+
93
+ # Return the inputs at a specific output
94
+ function get_inputs_at_output (inp:: MOInputsHeterotopic , output)
95
+ return [input[1 ] for input in inputs if input[2 ]== output]
96
+ end
97
+
61
98
const IsotopicMOInputsUnion = Union{MOInputIsotopicByFeatures,MOInputIsotopicByOutputs}
62
99
63
100
function Base. getindex (inp:: MOInputIsotopicByOutputs , ind:: Integer )
@@ -74,7 +111,13 @@ function Base.getindex(inp::MOInputIsotopicByFeatures, ind::Integer)
74
111
return feature, output_index
75
112
end
76
113
114
+ function Base. getindex (inp:: MOInputsHeterotopic , ind:: Integer )
115
+ @boundscheck checkbounds (inp, ind)
116
+ return inp. x[ind], inp. output_indices[ind]
117
+ end
118
+
77
119
Base. size (inp:: IsotopicMOInputsUnion ) = (inp. out_dim * length (inp. x),)
120
+ Base. size (inp:: MOInputsHeterotopic ) = (length (inp. output_indices),)
78
121
79
122
function Base. vcat (x:: MOInputIsotopicByFeatures , y:: MOInputIsotopicByFeatures )
80
123
x. out_dim == y. out_dim || throw (DimensionMismatch (" out_dim mismatch" ))
@@ -86,6 +129,10 @@ function Base.vcat(x::MOInputIsotopicByOutputs, y::MOInputIsotopicByOutputs)
86
129
return MOInputIsotopicByOutputs (vcat (x. x, y. x), x. out_dim)
87
130
end
88
131
132
+ function Base. vcat (x:: MOInputsHeterotopic , y:: MOInputsHeterotopic )
133
+ return MOInputsHeterotopic (vcat (x. x, y. x), vcat (x. output_indices, y. output_indices))
134
+ end
135
+
89
136
"""
90
137
MOInput(x::AbstractVector, out_dim::Integer)
91
138
0 commit comments