The BigMatrix
class implements an MxN matrix for situations and calculations where the usual 4x3 Matrix3 class is not adequate.
The BigMatrixRowArray
class implements an N element vector.
Each row in a BigMatrix value is a BigMatrixRowArray
value.
Only Float values can be stored in the elements of a BigMatrixRowArray
.
BigMatrix
and BigMatrixRowArray
values can be coerced to strings, but will be truncated to the first 20 items if the PrintAllElements context is off.Constructors
BigMatrix <rows> <columns>
Constructs a BigMatrix value with the given number of rows and columns.
All elements will be initially filled with 0.0 values.
Properties
<BigMatrix>.rows: Integer, read-only
<BigMatrix>.columns: Integer, read-only
Get the number of rows and number of columns in the BigMatrix value.
Operators
<BigMatrix> + <BigMatrix>
Adds the two BigMatrix values together.
Both BigMatrix values must have the same size
<BigMatrix>[<int_row>]
Returns the BigMatrixRowArray value of the indexed row. This value is not independent of the BigMatrix, so for example:
bm = BigMatrix 3 3
row1 = bm[1]
row1[1]=2.0
bm
--> #BigMatrix(
[2.00,0.00,0.00],
[0.00,0.00,0.00],
[0.00,0.00,0.00]
)
<BigMatrix>[<int_row>]= <float_array>
Sets the value of the BixMatrixRowArray at the specified index to the specified float array. The array does not need to have the same number of elements as the row. If it has fewer elements, those corresponding elements are set in the row. If there are more elements, the first n elements are copied, where n is the size of the BixMatrixRowArray. Available in 3ds Max 2021.1 Update and higher.
<BigMatrixRowArray>[<int_column>]
Returns the float value of the indexed column stored in the BigMatrixRowArray value.
<BigMatrixRowArray>[<int_column>]= <float_value>
Sets the value in the indexed column in the BigMatrixRowArray value.
Because accessors are themselves operands, these definitions are recursive, which means that you can string accessors together:
<BigMatrix>[<int_row>][<int_column>]
Returns the float value of the indexed row and column.
<BigMatrix>[<int_row>][<int_column>]= <float_value>
Sets the float value of the indexed row and column in the matrix.
Methods
invert <BigMatrix>
Inverts the matrix in place (the input BigMatrix is modified).
The return value is also the inverted matrix.
Note that this method only works if this matrix is "square" (if m = n).
transpose <BigMatrix>
Returns the transpose of <BigMatrix>
(result BigMatrix\[i\]\[j\]
= BigMatrix\[j\]\[i\]
).
clear <BigMatrix>
Frees all the elements and sets the matrix size to be 0x0
setSize <BigMatrix> <rows> <columns>
Deletes the current elements and sets the size of the matrix to <rows>
x <columns>
.
identity <BigMatrix> -- mapped function
If the number of rows and columns are not equal, this method does nothing.
If the number of rows and columns are equal, this method sets the matrix to the identity (diagonal elements = 1, all other elements = 0).
If the parameter is an array of matrices, this function returns the value OK
.
In both cases, the input BigMatrix values are set to the identity.
A BigMatrix object is a compound object, similar to an array of arrays. All of the BigMatrix methods operate directly on the components of the input BigMatrix. As described in Reference Assignment, this can cause complications if a BigMatrix object is referenced by more than one variable. If you assign a new value to an element of the matrix, or use any of the BigMatrix methods, the same object is still referenced by the variables.
This can be seen in the following example:
SCRIPT:
bm1=bigmatrix 2 2 for i=1 to 2 do for j=1 to 2 do bm1[i][j]=random 0 10 bm2=bm1 invert bm1 bm2
OUTPUT:
#BigMatrix( --result of line 1, contents of bm1 [0.00,0.00], [0.00,0.00] ) OK -- result of line 2 #BigMatrix( --result of line 3, contents of bm2 [4.00,6.00], [4.00,9.00] ) #BigMatrix( --result of line 4, contents of bm1 [0.75,-0.50], [-0.33,0.33] ) #BigMatrix( --result of line 5, contents of bm2 [0.75,-0.50], [-0.33,0.33] )