ID:116489
 
<!--

I just released a preliminary version of pif_MatrixMath. This implements a /matrix type, and basic matrix operations, such as addition, subtraction, negation, scaling, matrix multiplication, row operations, determinants, etc. If you have any comments, suggestions, criticisms, or bug reports, either reply here or on the forum, as usual.

Additionally, as a preliminary version, it lacks my standard +Documentation.dm file, but it's well-commented, so that should make up for it.

-->

NOPE.
Wow, that sounds interesting!
I'll check it out, keep up the good work.
I am doing a quick pass on things, will comment as I go.

- How can the columns or rows of a matrix be 'null'? You check for it several times.
- Like I said in The Saloon, determinant calculation is too slow. Check out http://en.wikipedia.org/wiki/Determinant#Calculation for future versions. Consider also that types of matrices (such as triangular or sparse) can have optimizations unique to them.
- I'm not sure how your matrix is stored, but can't you use Swap() in RowSwitch?
- Hopefully, in future versions, eigen values/vectors.
- Orthogonal matrices are a must for any good library.
Another thing. The matrix inversion algorithm seems inadequate for when one needs accurate inversions. A more stable algorithm, floating-point-wise, would be perhaps using http://en.wikipedia.org/wiki/LU_decomposition.

Case in point: the matrix {(1,2),(3,4)} is clearly invertible but your code says it isn't.

edit: I also think you aren't checking whether a matrix is actually square before trying to invert it.
Toadfish wrote:
- How can the columns or rows of a matrix be 'null'? You check for it several times.

I create a matrix with a null elements list when I am going to be explicitly assigning values to it (such as when I'm generating a new matrix, like with the CofactorMatrix function, or in a number of others). Consequently, a user can make a null matrix via new /matrix(null). Both /matrix.Columns() and /matrix.Rows() return null if the elements list is null. Therefore, for certain things, I need to check the matrix actually exists in any way.

- Like I said in The Saloon, determinant calculation is too slow. Check out http://en.wikipedia.org/wiki/Determinant#Calculation for future versions. Consider also that types of matrices (such as triangular or sparse) can have optimizations unique to them.

Alright, I've have to look into both of these.

- I'm not sure how your matrix is stored, but can't you use Swap() in RowSwitch?

Yep

- Hopefully, in future versions, eigen values/vectors.

I intend to.

- Orthogonal matrices are a must for any good library.

I'll look into these.

Another thing. The matrix inversion algorithm seems inadequate for when one needs accurate inversions. A more stable algorithm, floating-point-wise, would be perhaps using http://en.wikipedia.org/wiki/LU_decomposition.

I'll look into this, too.

edit: I also think you aren't checking whether a matrix is actually square before trying to invert it.

Ack. I wasn't aware square matrices are the only ones that can be inverted this way.
Good response, and good luck with the library.
Its late, so I will check this out tomorrow if I remember to. I do remember trying to figure out a good way to use matrices with BYOND a while back, but I can't remember the reason why I wanted to. Oh well.
Pop, what libraries do you have that you suggest any developer looking to make a game with the quality of Decadence would use? Page me if you can.
Resonence wrote:
Pop, what libraries do you have that you suggest any developer looking to make a game with the quality of Decadence would use? Page me if you can.

All the libraries.