External product of StaticArrays vectors

Hi,

I have two SVector’s, and I wish to compute their external product. I have three requirements

  1. the output should be a SMatrix,
  2. the operation should be FAST (slow, I can do myself…)
  3. preferably, the output is non-mutable

The later requirement makes it difficult for me to create a naive implementation…

Is the operation implemented? I could not find it in the StaticArrays docs.

:slightly_smiling_face:

Philippe

Hi!

Do you mean outer product? If so, you can just do

julia> a = @SVector randn(4);

julia> b = @SVector randn(4);

julia> a*b'
4×4 SArray{Tuple{4,4},Float64,2,16} with indices SOneTo(4)×SOneTo(4):
  0.423303   0.402792   0.373048   0.136053
 -0.782696  -0.744771  -0.689774  -0.251565
  0.774667   0.73713    0.682698   0.248984
 -0.982405  -0.934802  -0.865773  -0.315753
1 Like

Yes, outer, not external
Oh so simple!!! :rofl:

Thanks!

2 Likes