Category:Linear Algebra Functions (OBSE)

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

These functions treat Arrays as vectors and matrices, performing standard linear algebra operations on them.

Internally, matrices are two-dimensional arrays, where the elements of the outer array each arrays holding the rows. Therefore, A[i][j] refers to the jth element of the ith row, in keeping with common mathematical convention.

To be a matrix, the array must be one or two dimensional, contain only numerical values, and in the case of two-dimensional arrays, every row in the array must have the same length. These functions will always fail if an input does not meet these criteria.

Some functions require that the matrix be square, which means that its height and width are equal.

Other functions further require that the matrix be a vector, that is, either be a one-dimensional array, or a two-dimensional array where there is either only one sub-array (a row vector), or every sub-array has only one element (a column vector).

One-dimensional arrays may be used as vectors, but these functions will not assume that they are either row or column vectors. In most cases, this is not important, but in some it is. For example, with MatrixMultiply, the value changes based on which of the vectors is a column vector and which is a row vector (see the function description for more information). In such ambiguous cases, the functions will not work; use ForceRowVector or ForceColumnVector to resolve such ambiguities. If a function does not indicate such a situation, one-dimensional arrays will work for a vector just fine.

These functions returns 0 if they fail for whatever reason (incompatible matrix dimensions is the most common reason). In some cases (e.g. MatrixDeterminant), 0 is also a valid return value, so it is the scripter's responsibility to ensure that the matrix is acceptable for the function.