Simple Matrix |
|
matrix is intended to be useable on most types of matrices. Thats why it does not check for special types of matrices for optimised calculation but instead provides functions usable on most types of matrices. The matrix functions need a complex number handling for the complex matrices, you find it in the package on the download site
A list of functions:
matrix.add matrix.columns matrix.concath matrix.concatv matrix.conjugate matrix.copy matrix.cross matrix.det matrix.div matrix.divnum matrix.dogauss matrix.getelement matrix.gsub matrix.invert matrix.ipairs matrix.latex matrix.len matrix.mul matrix.mulnum matrix:new matrix.normf matrix.normmax matrix.pow matrix.print matrix.random matrix.remcomplex matrix.replace matrix.root matrix.rotl matrix.rotr matrix.round matrix.rows matrix.scalar matrix.setelement matrix.size matrix.solve matrix.sqrt matrix.sub matrix.subm matrix.tocomplex matrix.tostring matrix.tosymbol matrix.transpose matrix.type
Testcode is in the *.zip file on the downloadsite
DetectingUndefinedVariables with luac -p -l complex.lua matrix.lua | grep ETGLOBAL .
LuaStyleGuide for setting up a module
Square root of a matrix [1] [2][3]
Tensors [4]
"Denman–Beavers square root iteration" [2]
Complex abs [5]
B = A^(1/p) generalized for integer p > 2 is noted here [6]
Another approach is in "A new sqrtm for Matlab" ([7] or [8]) cited by Octave, though perhaps cannot be extended as well to M^{1/n} for n not equal to 2.
M^x (for matrix M and complex x) is in general defined as expm(logm(M)*x), just like in the real and complex cases. logm and expm[9] can be understood as Taylor expansions in terms of non-negative integer powers of M (again, analogous to the real and complex cases). Evaluation is discussed in "A Schur-Parlett Algorithm for Computing Matrix Functions" [10]. That is all getting somewhat complicated to (re)implement robustly and perhaps outside the main scope of this module. --DavidManura