# MMatrix

## Constants

Name | Type | Description
--- | --- | ---
kIdentity | MMatrix | Identity matrix.
kTolerance | float | Default tolerance for non-exact equality tests.

## Static Methods

None.

## Static Attributes

None.

## Constructors

Signature | Parameters | Description
--- | --- | ---
MMatrix() |  | Default constructor. Returns a new matrix set to the identity matrix.
MMatrix(src) | src - MMatrix | Copy constructor. Returns a new matrix with the same value as src.
MMatrix(values) | values - sequence of 16 float values or four tuples of four float values each. | Returns a new matrix whose elements are set to those given by values. Values are interpreted in row order, so the first four values make up the first row of the matrix, the second four values the second row of the matrix, and so on.

## Object Methods

Signature | Parameters | Returns | Description
--- | --- | --- | ---
getElement(row,col) | row - int col - int | float | Returns the matrix element specified by row and col. For retrieving single elements this is faster than indexing into the matrix as a sequence because it does not require the creation of an entire row tuple simply to retrieve one element from that row.
setElement(row,col,value) | row - int col - int value - float | New reference to self. | Set the matrix element specified by row and col to the given value.
transpose() |  | MMatrix | Returns a new matrix containing this matrix's transpose.
setToIdentity() |  | New reference to self. | Sets this matrix to the identity.
setToProduct(left, right) | left - MMatrix right - MMatrix | New reference to self. | Sets this matrix to the product of left and right.
inverse() |  | MMatrix | Returns a new matrix containing this matrix's nverse.
adjoint() |  | MMatrix | Returns a new matrix containing this matrix's adjoint.
homogenize() |  | MMatrix | Returns a new matrix containing the homogenized version of this matrix.
det4x4() |  | float | Returns this matrix's determinant.
det3x3() |  | float | Returns the determinant of the 3x3 matrix formed by the first 3 elements of the first 3 rows of this matrix.
isEquivalent(other, tolerance=kTolerance) | other - MMatrix tolerance - float | bool | Inexact equality test. Returns True if each element of this matrix is within tolerance of the corresponding element of other.
isSingular() |  | bool | Returns True if this matrix is singular.

## Object Attributes

None.

## Sequence Support

An MMatrix object is treated like a sequence of 16 float values, in row major order. Element assignment is supported.

len() returns 16.

Deletion, concatenation, repetition and slicing are not supported.

## Number Support

Operation | Result
--- | ---
MMatrix + MMatrix | Returns a new matrix which is the sum of the two matrices.
MMatrix += MMatrix | Adds the second matrix to the first and returns a new reference to the first.
MMatrix - MMatrix | Returns a new matrix which is the result of subtracting the second matrix from the first.
MMatrix -= MMatrix | Subtracts the second matrix from the first and returns a new reference to the first.
MMatrix * MMatrix | Returns a new matrix which is the product of the two matrices.
MMatrix *= MMatrix | Multiplies the first matrix by the second and returns a new reference to the first.
MMatrix * float | Returns a new matrix in which all of the elements of the given matrix have been multiplied by the given float.
float * MMatrix | Returns a new matrix in which all of the elements of the given matrix have been multiplied by the given float.
MMatrix *= float | Multiplies all the elements of the matrix by the float and returns a new reference to the matrix.

## Comparison Support

MMatrix == MMatrix | Exact equality test. True if each of the 16 elements of the first matrix is exactly equal to the corresponding element in the second matrix. No tolerance is applied.
MMatrix != MMatrix | Exact inequality test. True if any of the 16 elements in the first matrix is not exactly equal to the corresponding element in the second matrix. No tolerance is applied.

All other comparison operators will raise a TypeError exception.

© 2011 Autodesk, Inc. All rights reserved.