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

A / lu(A) returns Array when A is an SArray #851

Closed
dmillard opened this issue Nov 12, 2020 · 3 comments
Closed

A / lu(A) returns Array when A is an SArray #851

dmillard opened this issue Nov 12, 2020 · 3 comments

Comments

@dmillard
Copy link

dmillard commented Nov 12, 2020

This is related to #796 but I think it's a different issue.

Here's an example:

julia> A = @SMatrix [1.0 2 3; 4 99 6; 22 8 9]
3×3 SArray{Tuple{3,3},Float64,2,9} with indices SOneTo(3)×SOneTo(3):
  1.0   2.0  3.0
  4.0  99.0  6.0
 22.0   8.0  9.0

julia> A / lu(A)
3×3 Array{Float64,2}:
 1.0  3.46945e-18  0.0
 0.0  1.0          0.0
 0.0  0.0          1.0

I would expect that this right hand solve would in fact produce an SArray, like in

julia> A / A
3×3 SArray{Tuple{3,3},Float64,2,9} with indices SOneTo(3)×SOneTo(3):
  1.0  -0.0  -0.0
 -0.0   1.0  -0.0
 -0.0  -0.0   1.0

I'm not actually interested in A/A, I have a problem A/B, but I thought this demonstrated the type issues well.

Am I missing something that would help me get what I want? Thanks!

@mateuszbaran
Copy link
Collaborator

I think this was accidentally fixed on master in this PR: #837 . If you don't want to use master you can just add this method definition: @inline Base.:/(A::StaticMatrix, B::StaticArrays.StaticULT) = transpose(transpose(B) \ transpose(A)).

@dmillard
Copy link
Author

Perfect. Thanks!

@c42f
Copy link
Member

c42f commented Nov 23, 2020

Nice!

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

3 participants