Skip to content
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

Avoid Disrupting Array Types #177

Closed
ParadaCarleton opened this issue Sep 15, 2023 · 2 comments
Closed

Avoid Disrupting Array Types #177

ParadaCarleton opened this issue Sep 15, 2023 · 2 comments

Comments

@ParadaCarleton
Copy link

ParadaCarleton commented Sep 15, 2023

As an example:

julia> using DimensionalData, Distributions

julia> z = randn(3, 3) |> x->x' * x |> x->DimArray(x, (ax1=[:x, :y, :z], ax2=[:x, :y, :z]))
3×3 DimArray{Float64,2} with dimensions: 
  Dim{:ax1} Categorical{Symbol} Symbol[:x, :y, :z] ForwardOrdered,
  Dim{:ax2} Categorical{Symbol} Symbol[:x, :y, :z] ForwardOrdered
        :x         :y         :z
  :x   3.2005    -0.550321  -0.538308
  :y  -0.550321   2.14419   -2.98709
  :z  -0.538308  -2.98709    5.92229

julia> typeof(MvNormal(z))
ZeroMeanFullNormal{Tuple{OneTo{Int64}}} (alias for MvNormal{Float64, PDMats.PDMat{Float64, Array{Float64, 2}}, FillArrays.Zeros{Float64, 1, Tuple{Base.OneTo{Int64}}}})

julia> rand(MvNormal(z))
3-element Vector{Float64}:
 -0.14355464178021315
  1.076531030969517
 -0.666861987973966

This makes it impossible to use DimensionalData.jl or other array wrappers (such as CuArrays) together with PDMats.jl.

@devmotion
Copy link
Member

Distributions is not needed for the example, a bit more minimal and clearer:

julia> PDMat(z)
3×3 PDMat{Float64, Matrix{Float64}}:
  1.87205    3.20828  -0.993003
  3.20828    5.97114  -1.88158
 -0.993003  -1.88158   0.597444

I'm not sure if it's an actual issue with PDMats though, the main problem seems to be

julia> using LinearAlgebra

julia> cholesky(z)
Cholesky{Float64, Matrix{Float64}}
U factor:
3×3 UpperTriangular{Float64, Matrix{Float64}}:
 1.36823  2.34484   -0.725759
         0.687651  -0.261456
                   0.0485701

@devmotion
Copy link
Member

Seems to be rafaqz/DimensionalData.jl#514.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants