To contents

14.18.1 Math.Matrix

CLASS
Math.Matrix

DESCRIPTION
This class hold Matrix capabilites, and support a range of matrix operations.

It can only - for speed and simplicity - hold floating point numbers and are only in 2 dimensions.

METHOD
Math.Matrix.`+,
Math.Matrix.``+,
Math.Matrix.add

SYNTAX
object `+(object with)
object ``+(object with)
object add(object with)

DESCRIPTION
Add this matrix to another matrix. A new matrix is returned. The matrices must have the same size.

METHOD
Math.Matrix.cast

SYNTAX
array(array(float)) cast(string to_what)
array(array(float)) cast(string to_what)

DESCRIPTION
This is to be able to get the matrix values. (array) gives back a double array of floats. m->vect() gives back an array of floats.

METHOD
Math.Matrix.cast

SYNTAX
array(array(float)) cast(string to_what)

DESCRIPTION
This is to be able to get the matrix values. This gives back a double array of floats.

METHOD
Math.Matrix.create

SYNTAX
void create(array(array(int|float)))
void create(array(int|float))
void create(int n, int m)
void create(int n, int m, string type)
void create(int n, int m, float|int init)
void create("identity", int size)
void create("rotate", int size, float rads, Matrix axis)
void create("rotate", int size, float rads, float x, float y, float z)

DESCRIPTION
This method initializes the matrix. It is illegal to create and hold an empty matrix.

The normal operation is to create the matrix object with a double array, like Math.Matrix( ({({1,2}),({3,4})}) ).

Another use is to create a special type of matrix, and this is told as third argument.

Currently there are only the "identity" type, which gives a matrix of zeroes except in the diagonal, where the number one (1.0) is. This is the default, too.

The third use is to give all indices in the matrix the same value, for instance zero or 42.

The forth use is some special matrixes. First the square identity matrix again, then the rotation matrix.

METHOD
Math.Matrix.cross,
Math.Matrix.``×,
Math.Matrix.`×

SYNTAX
object (object with)
object ``×(object with)
object cross(object with)

DESCRIPTION
Matrix cross-multiplication.

METHOD
Math.Matrix.`*,
Math.Matrix.``*,
Math.Matrix.mult

SYNTAX
object `*(object with)
object ``*(object with)
object mult(object with)

DESCRIPTION
Matrix multiplication.

METHOD
Math.Matrix.norm2,
Math.Matrix.norm,
Math.Matrix.normv

SYNTAX
float norm()
float norm2()
object normv()

DESCRIPTION
Norm of the matrix, and the square of the norm of the matrix. (The later method is because you may skip a square root sometimes.)

This equals |A| or sqrt( A02 + A12 + ... + An2 ).

It is only usable with 1xn or nx1 matrices.

m->normv() is equal to m*(1.0/m->norm()), with the exception that the zero vector will still be the zero vector (no error).

METHOD
Math.Matrix.`-,
Math.Matrix.``-,
Math.Matrix.sub

SYNTAX
object `-()
object `-(object with)
object ``-(object with)
object sub(object with)

DESCRIPTION
Subtracts this matrix from another. A new matrix is returned. -m is equal to -1*m.

METHOD
Math.Matrix.transpose

SYNTAX
object transpose()

DESCRIPTION
Transpose of the matrix as a new object.

To contents