Hello,
For a long lime I've been having a bad feeling for having a Union in a
composite type, as in
type GMM{T:<FloatingPoint}
...
kind::Symbol
μ::Matrix{T}
Σ::Union(Matrix{T},Vector{Matrix{T}})
...
end
where the choice in `Σ` depends on whether `kind==:diag` or `kind==:full`.
I have the feeling it is better to have defined something along the lines
of
typealias DiagCov{T} Matrix{T}
typealias FullCov{T} Vector{Matrix{T}}
type GMM{T:<FloatingPoint,CT}
...
μ::Matrix{T}
Σ::CT
end
function kind(g::GMM)
T = eltype(g.μ)
if isa(g.Σ, FullCov{T})
return :full
else
return :diag
end
end
In the second case, the `kind` is inferred from the type instance, rather
than stored as a type variable.
What is in your expert's opinion a better way of defining such a type?
Thanks,
---david