-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Covariance matrix obs_noise_cov
is restricted to Array{FT, 2}
#99
Comments
For sure, the creation of the package was done with types being used to restrict arguments (before i even knew about the difficulties with matrix != array{,2} != DiagonalMatrix type problems) I think for Covariance matrices, I am happy to take the broadest umbrella type that can have a dimension specified (i.e. must be 2D)? Or would you be looking for all typing completely removed as we don't dispatch? |
You want to use a variable concrete type: obs_noise_cov::M The type union julia> using LinearAlgebra
julia> a = rand(2, 2)
2×2 Matrix{Float64}:
0.479173 0.77404
0.842289 0.230474
julia> b = Diagonal(a)
2×2 Diagonal{Float64, Vector{Float64}}:
0.479173 ⋅
⋅ 0.230474
julia> c = 0.1 * I
UniformScaling{Float64}
0.1*I
julia> a isa AbstractMatrix
true
julia> b isa AbstractMatrix
true
julia> c isa AbstractMatrix
false I would be cautious about using a type constraint for a user-facing object like this. Type constraints are more appropriate for low-level code where the possible range of types are actually known. It's difficult to have omniscient knowledge about anything users might do. @simonbyrne probably has enough knowledge to say whether As an aside, I think it's more user-friendly for user-facing stuff to intentionally validate input rather than relying on the often-obscure obs_noise_cov isa Union{UniformScaling, AbstractMatrix} ||
throw(ArgumentError(string(summary(obs_noise_cov), " obs_noise_cov is not supported. Use UniformScaling or AbstractMatrix")) or something like that. |
The type of
EnsembleKalmanProcess.obs_noise_cov
is restricted toArray{FT, 2}
, which is inconvenient and prevents the use of commonLinearAlgebra
abstractions that represent arrays.For example:
0.1 * I
is a valid and efficient way to specify a covariance matrix. The code itself likely works as is, since key lines likeare valid for a wide variety of matrix types. Thus probably the only change needed is to release
obs_noise_cov
fromArray{FT, 2}
.For large observation vectors the need to convert objects like
UniformScaling
toArray{FT, 2}
is a waste of memory:Another important matrix type is
Diagonal
representing a diagonal matrix.cc @simonbyrne
The text was updated successfully, but these errors were encountered: