CMatrix:Init
The Init method sets the first n x m CMatrix members to the same value.
CMatrix:Init( nRows, nCols ) CMatrix:Init( nRows, nCols, value ) where |
nRows is the number of rows to define.
nCols is the number of columns to set.
value is the target value to assign and may be a number, string, or other value that can be represented as a number. If omitted, it defaults to the number 0.
This method first empties the CMatrix and then defines all matrix members at row indices 1...n and column indices 1...m. After Init, the Cols method returns m and Rows returns n.
The following script fills a matrix of 8 rows x 4 columns with the number -1.5:
|
-- create a CMatrix |
|
-- set first 32 members |
|
-- result: M[5][3] = -1.5 |
The script below initializes a 5x5 matrix to all 0's:
|
-- create a CMatrix |
|
-- set first 5 x 5 members to 0 |
|
-- result: M[3][3] = 0 |