[libre-riscv-dev] 3D Matrix-style operations / primitives

lkcl luke.leighton at gmail.com
Wed Sep 18 06:24:27 BST 2019

does anyone know of some mathematics for analysing which would be the best 
"primitives" for Matrix operations, suited to transposition and inversion, 
determinant and normalisation?

for 3D that generally means just 2x2, 3x3 and 4x4.

i'm looking up how matrix inverses are calculated and, hoo-boy :)

normalisation looks to be just "divide by the determinant":

so... i am logically deducing that if you wanted something RISC-like, you'd 
have operations for transpose and determinant?  or... can determinant be 
broken down further into something elegant?

whilst 2x2 looks pretty obvious - 0,0 x 1,1 - 1,0 x 0,1 - it looks like it 
goes recursive from there, with permutations:

at that point, honestly, i'm scared/alarmed to even recommend a Matrix 
Determinant opcode!

likewise, Transpose appears to be a series of MV operations with offsets, 
which tends to suggest that there may be some vector primitives that would 
be really good to have, that could be added to this:


a quick search "matrix inverse swizzle" shows this:

which mentions __mm_shuffle_epl32, _mm_shuffle_ps, _mm_movelp_ps and that 
leads on a merry search to SSE/AVX/AVX-512:

looovely :)

at which point i am definitely lost.  does anyone have any suggestions?


More information about the libre-riscv-dev mailing list