Hi Henrik,
thanks a lot for sharing your code!
Best regards,
Jürgen
On 5/15/24 01:09, Henrik Moller wrote:
I do a lot of stuff with matrices and it occurred to me a couple of
days ago to start packaging some of them as gnu APL native functions I
don't think are built into the present release. (I could be wrong
about that, but neither the documentation nor grep mention anything
that might be relevant. Someone let me know if I'm wrong.)
This first release provides matrix determinants and vector cross
products. I might add more stuff later.
https://github.com/ChrisMoller/mtx
Here's the README.md:
# MTX
mtx is collection of matrix operations not natively supported by gnu APL.
For this frst release it includes support for finding the determinant of
a matrix and the cross product of vectors.
To use mtx, it must be fixed in the workspace:
'libmtx.so' ⎕fx 'mtx'
using any function name that pleases you instead of 'mtx'.
The general form of the use of mtx is either monadic:
mtx y
mtx['c'] y
mtx['d'] y
or dyadic:
x mtx y
In the monadic form, an "axis" of 'c' (or any string that starts with
'c' or
'C') will do the cross product of the arguement. 'd" or 'D' will get the
determinant. If neither is specified, the default is determinant.
The dyadic
form always yields the cross product.
(It's handy to create a couple of named lambdas for these:
cross ← {⍺ mtx['c'] ⍵}
and
det ← {mtx['d'] ⍵}
)
The argument for determinants must be a real or complex square matrix. For
cross products in the dyadic form, both arguments must be of rank 1 and of
length 3. In monadic form, the argument must have a shape of [n-1 n]
though
for reasons I'm not enough of a mathematician to understand, cross
products
are only valid in 3-space and 7-space, so the only valid arguments are of
shapes [2 3] or [6 7]. mtx, however, doesn't check this and will happily
give you a result in any dimensionality and leave it your imagination what
it may mean.
I may add more functionality in later releases. (Eigen pairs come to
mind,
and I'm open to suggestions.)
Chris Moller
hen...@henrikmoller.me
(If you care, the entirety of my name is Christian Henrik Luja Møller,
giving me a great deal of flexibility in obfuscating my identity.)