Represents an arbitrarily sized matrix of double-precision floating point numbers. If you are working with a 4x4 matrix, then you may want to use the Transform class instead.

Constructors

Matrix

#Since v5.0
public Matrix(int rowCount, int columnCount)
Initializes a new instance of the matrix.
rowCount (int)A positive integer, or 0, for the number of rows.
columnCount (int)A positive integer, or 0, for the number of columns.
ArgumentOutOfRangeExceptionIf either rowCount, or columnCount or both are negative.

Matrix

#
protected Matrix(SerializationInfo info, StreamingContext context)
Protected constructor for internal use.
info (SerializationInfo)Serialization data.
context (StreamingContext)Serialization stream.

Matrix

#Since v5.0
public Matrix(Transform xform)
Initializes a new instance of the matrix based on a 4x4 matrix Transform.
xform (Transform)A 4x4 matrix to copy from.

Finalizer

~Matrix

#
~Matrix()
Passively reclaims unmanaged resources when the class user did not explicitly call Dispose().

Properties

ColumnCount

#Since v5.0
public int ColumnCount { get; }
Gets the amount of columns.

IsColumnOrthogonal

#Since v5.0
public bool IsColumnOrthogonal { get; }
Gets a value indicating whether the matrix is column orthogonal.

IsColumnOrthoNormal

#Since v5.0
public bool IsColumnOrthoNormal { get; }
Gets a value indicating whether the matrix is column orthonormal.

IsRowOrthogonal

#Since v5.0
public bool IsRowOrthogonal { get; }
Gets a value indicating whether the matrix is row orthogonal.

IsRowOrthoNormal

#Since v5.0
public bool IsRowOrthoNormal { get; }
Gets a value indicating whether the matrix is row orthonormal.

IsSquare

#Since v5.0
public bool IsSquare { get; }
Gets a value indicating whether this matrix has the same number of rows and columns. 0x0 matrices are not considered square.

IsValid

#Since v5.0
public bool IsValid { get; }
Gets a value indicating whether this matrix is valid.

RowCount

#Since v5.0
public int RowCount { get; }
Gets the amount of rows.

Indexers

this[]

#
public double this[int row, int column] { get; set; }
Gets or sets the matrix value at the given row and column indices.
The new value at [row, column].
row (int)Index of row to access.
column (int)Index of column to access.
The value at [row, column].

Methods

BackSolve

#Since v5.0
public double[] BackSolve(double zeroTolerance, double[] b)
Solves M*x=b where M is upper triangular with a unit diagonal and b is a column of values.
zeroTolerance (double)(>=0.0) used to test for "zero" values in b in under determined systems of equations.
b (double[])The values in B[RowCount],...,B[B.Length-1] are tested to make sure they are within "zeroTolerance".
Array of length ColumnCount on success. null on error.

BackSolvePoints

#Since v5.0
public Point3d[] BackSolvePoints(double zeroTolerance, Point3d[] b)
Solves M*x=b where M is upper triangular with a unit diagonal and b is a column of 3d points.
zeroTolerance (double)(>=0.0) used to test for "zero" values in b in under determined systems of equations.
b (Point3d[])The values in B[RowCount],...,B[B.Length-1] are tested to make sure they are "zero".
Array of length ColumnCount on success. null on error.

Dispose

#Since v5.0
public void Dispose()
Actively reclaims unmanaged resources that this instance uses.

Dispose

#
protected virtual void Dispose(bool disposing)
For derived class implementers.

This method is called with argument true when class user calls Dispose(), while with argument false when the Garbage Collector invokes the finalizer, or Finalize() method.

You must reclaim all used unmanaged resources in both cases, and can use this chance to call Dispose on disposable fields if the argument is true.

Also, you must call the base virtual method within your overriding method.

disposing (bool)true if the call comes from the Dispose() method; false if it comes from the Garbage Collector finalizer.

Duplicate

#Since v5.1
[ConstOperation] public Matrix Duplicate()
Create a duplicate of this matrix.
An exact duplicate of this matrix.

GetHashCode

#
[ConstOperation] public override int GetHashCode()
Gets the hash code for this matrix. The hash code will change when the matrix changes so you cannot change matrices while they are stored in hash tables.
Hash code.

GetObjectData

#Since v9.0
[ConstOperation] public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a System.Runtime.Serialization.SerializationInfo with the data needed to serialize the target object.
info (SerializationInfo)The System.Runtime.Serialization.SerializationInfo to populate with data.
context (StreamingContext)The destination (see System.Runtime.Serialization.StreamingContext) for this serialization.

Invert

#Since v5.0
public bool Invert(double zeroTolerance)
Modifies this matrix to become its own inverse.

Matrix might be non-invertible (singular) and the return value will be false.

zeroTolerance (double)The admitted tolerance for 0.
true if operation succeeded; otherwise false.

RowReduce

#Since v5.0
public int RowReduce(double zeroTolerance, double[] b, out double pivot)
Row reduces a matrix as the first step in solving M*X=b where b is a column of values.
Remarks: The matrix itself is row reduced so that the result is an upper triangular matrix with 1's on the diagonal.
zeroTolerance (double)(>=0.0) zero tolerance for pivot test. If the absolute value of a pivot is <= zero_tolerance, then the pivot is assumed to be zero.
b (double[])an array of RowCount values that is row reduced with the matrix.
pivot (out double)the value of the smallest pivot is returned here.
Rank of the matrix.

RowReduce

#Since v5.0
public int RowReduce(double zeroTolerance, out double determinant, out double pivot)
Row reduces a matrix to calculate rank and determinant.
Remarks: The matrix itself is row reduced so that the result is an upper triangular matrix with 1's on the diagonal.
zeroTolerance (double)(>=0.0) zero tolerance for pivot test. If a the absolute value of a pivot is <= zeroTolerance, then the pivot is assumed to be zero.
determinant (out double)value of determinant is returned here.
pivot (out double)value of the smallest pivot is returned here.
Rank of the matrix.

RowReduce

#Since v5.0
public int RowReduce(double zeroTolerance, Point3d[] b, out double pivot)
Row reduces a matrix as the first step in solving M*X=b where b is a column of 3d points.
Remarks: The matrix itself is row reduced so that the result is an upper triangular matrix with 1's on the diagonal.
zeroTolerance (double)(>=0.0) zero tolerance for pivot test. If the absolute value of a pivot is <= zero_tolerance, then the pivot is assumed to be zero.
b (Point3d[])An array of RowCount 3d points that is row reduced with the matrix.
pivot (out double)The value of the smallest pivot is returned here.
Rank of the matrix.

Scale

#Since v5.0
public void Scale(double s)
Modifies the current matrix by multiplying its values by a number.
s (double)A scale factor.

SetDiagonal

#Since v5.0
public void SetDiagonal(double d)
Sets diagonal value and zeros off all non-diagonal values.
d (double)The new diagonal value.

SwapColumns

#Since v5.0
public bool SwapColumns(int columnA, int columnB)
Exchanges two columns.
columnA (int)A first column.
columnB (int)Another column.
true if operation succeeded; otherwise false.

SwapRows

#Since v5.0
public bool SwapRows(int rowA, int rowB)
Exchanges two rows.
rowA (int)A first row.
rowB (int)Another row.
true if operation succeeded; otherwise false.

Transpose

#Since v5.0
public bool Transpose()
Modifies this matrix to be its transpose.

This is like swapping rows with columns.

http://en.wikipedia.org/wiki/Transpose

true if operation succeeded; otherwise false.

Zero

#Since v5.0
public void Zero()
Sets all values inside the matrix to zero.

Operators

OperationResultDescription
Matrix+MatrixMatrixAdds two matrices and returns a new sum matrix.
Matrix*MatrixMatrixMultiplies two matrices and returns a new product matrix.