Description
Consider the following example:
P = @SMatrix [-0.5 0.5 0.5; 0.5 -0.5 0.5; 0.5 0.5 -0.5] # SMatrix{3,3,Float64,9}
w = rand(Float64, 3) # Vector{Float64}
W = rand(Float64, 3, 3) # Matrix{Float64}
println(typeof(P\w)) # => SArray{Tuple{3},Float64,1,3}
println(typeof(P\W)) # => Array{Float64,2}
i.e. doing a matrix solve with \(::SMatrix, ::Matrix)
returns an ordinary matrix but a matrix solve with \(::SMatrix, ::Vector)
returns a static vector. This seems surprising to me: I had expected both calls to return non-static/ordinary vectors/matrices (or at least the same "base" array type).
Here, \
calls into the generic (\)(A::AbstractMatrix, B::AbstractVecOrMat)
from LinearAlgebra (at https://github.com/JuliaLang/julia/blob/cf410dc9e81cfa14a18ca3aef50346000b4615c7/stdlib/LinearAlgebra/src/generic.jl#L1102) which in turn calls into StaticArrays' \
method for LU decompositions at
Lines 186 to 187 in 64c64b2
So the issue seems to me that v[F.p]
in the above converts v
to an SVector
(due to the indexing call), but B[F.p,:]
is still an ordinary matrix due to the combination with :
.