Working with Matrices

CMatrix Class


The CMatrix class manages a 2-dimensional matrix. The members (or elements) of the matrix are usually numbers but may be any type of value, such as strings or other types. The class implements a matrix as a 2-dimensional table of (row, CArray) pairs, with each row being a CArray of (column, value) pairs. Note that many of these methods are available using lua tables and the lua table package (see the lua reference books or the documentation at https://lua.org).

CMatrix Class Topics

See the detailed description of the CMatrix class in Working with Matrices.

Usage

Construction

Object = new_matrix()

Object = CMatrix:new()

Destruction

Object:delete()

Creation - Non-class Functions

This function is normally used to create a new CMatrix object as an alternative to the class-based new method.

new_matrix

Creates a new instance of the CMatrix class.

Construction and Destruction - Class Methods

new

Creates a new instance of the CMatrix class. Various constructors are available.

delete

Deletes the instance of the CMatrix object.

Operations

Empty

Empties the contents of the CMatrix but does not delete it.

Copy

Copies this CMatrix to a new CMatrix

Dump

Lists all matrix elements in a text window.

GetRow

Returns the CArray used for a row.

Get

Returns the value at a (row, column) position in the matrix.

RowExists

Returns true if a specified row exists.

Exists

Returns true if a value exists at the (row, column) index.

Set

Sets the value at a row, column index.

RemoveRow

Deletes an entire row from the matrix.

Remove

Removes the value at a (row,column) index.

Init

Initializes all row x column entries to a value.

Members

Returns a count of total defined members.

Rows

Returns the number the maximum row index used.

RowsUsed

Returns the number of rows initialized.

Cols

Returns the maximum column index used in any row.

ColsUsed

Returns the number of columns initialized in any row.

Count

Returns the number of rows initialized.

Math Operations

Normalize

Normalizes to a volume of 1.0.

Volume

Returns the sum of all matrix members.

Related Topics

CArray

CSet

 


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