CMatrix:Init


The Init method sets the first n x m CMatrix members to the same value.

Syntax

CMatrix:Init( n, m, value=0 )

bullet.gif    n is the number of rows to define.

bullet.gif    m is the number of columns to set.

bullet.gif    value is the target value to assign and may be a number, string, or other value. If omitted, it defaults to the number 0.

Remarks

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.

Example

The following script fills a matrix of 8 rows x 4 columns with the number -1.5:

M = new_matrix()

-- create a CMatrix

M:Init( 8, 4, -1.5 )

-- set first 32 members

Printf("M[5][3] = %lg", M:Get(5,3))

-- result: M[5][3] = -1.5

 

The next script initializes a 5x5 matrix to all 0's:

M = new_matrix()

-- create a CMatrix

M:Init( 5, 5 )

-- set first 5 x 5 members to 0

Printf("M[3][3] = %lg", M:Get(3,3) )

-- result: M[3][3] = 0

Related Topics

CMatrix class, Set


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.