I have an SMatrix
of dimension (D, k)
. What I want to do is to normalize each column of this matrix, as if they were individual vectors.
What I do at the moment is always carry around with me a Vector[SVector]
, and do:
using StaticArrays
D = 3; k = 3
dummy = [rand(SVector{D}) for i in 1:k]
A = rand(SMatrix{D, k})
for i in 1:k
dummy[i] = normalize(A[:, i])
end
A = hcat(dummy...)
But that doesn’t seem very efficient…
Both D, k
can be known at compile time, maybe there is a more performant way involving metaprogramming?