Table of Contents

Class Matrix

Namespace
NominalSystems.Maths
Assembly
NominalSystems.Maths.dll

[NominalSystems] A column-major matrix class

public sealed class Matrix : IEnumerable<double>, IEnumerable
Inheritance
Matrix
Implements

Constructors

Matrix()

Default constructor

public Matrix()

Matrix(IMatrix)

Default constructor

public Matrix(IMatrix a)

Parameters

a IMatrix

a matrix

Matrix(Matrix)

Default constructor

public Matrix(Matrix a)

Parameters

a Matrix

a matrix

Matrix(IEnumerable<Vector>)

public Matrix(IEnumerable<Vector> rows)

Parameters

rows IEnumerable<Vector>

Matrix(double[,])

Creates a Matrix from a 2D array

public Matrix(double[,] array)

Parameters

array double[,]

A 2D array

Matrix(int, int)

Default constructor

public Matrix(int r, int c)

Parameters

r int

row size

c int

column size

Matrix(int, int, IVector)

Default constructor

public Matrix(int r, int c, IVector a)

Parameters

r int

row size

c int

column size

a IVector

a matrix array

Matrix(int, int, double)

Default constructor

public Matrix(int r, int c, double x)

Parameters

r int

row size

c int

column size

x double

the default value

Matrix(uint, uint)

Default constructor

public Matrix(uint r, uint c)

Parameters

r uint

row size

c uint

column size

Fields

Values

The 'Matrix' values

public readonly double[] Values

Field Value

double[]

Properties

Absolute

Returns the absolute value of each value in the matrix

public Matrix Absolute { get; }

Property Value

Matrix

CholeskyFactor

Returns the Cholesky Factor matrix

public Matrix CholeskyFactor { get; }

Property Value

Matrix

Cols

The total column size

public uint Cols { get; }

Property Value

uint

Determinant

Returns the determinant for this matrix

public double Determinant { get; }

Property Value

double

Inverse

Returns the inverse of a 'Matrix'

public Matrix Inverse { get; }

Property Value

Matrix

this[int]

Get/Set 'Matrix' values

public double this[int i] { get; set; }

Parameters

i int

index

Property Value

double

this[int, int]

Get/Set 'Matrix' values

public double this[int r, int c] { get; set; }

Parameters

r int

row index

c int

column index

Property Value

double

this[uint]

Get/Set 'Matrix' values

public double this[uint i] { get; set; }

Parameters

i uint

index

Property Value

double

this[uint, uint]

Get/Set 'Matrix' values

public double this[uint r, uint c] { get; set; }

Parameters

r uint

row index

c uint

column index

Property Value

double

Rows

The total row size

public uint Rows { get; }

Property Value

uint

Transpose

Returns the Transposed matrix

public Matrix Transpose { get; }

Property Value

Matrix

UpperTriangularRFactor

Returns the upper triangular R factor

public Matrix UpperTriangularRFactor { get; }

Property Value

Matrix

Methods

CoeffDivide(Matrix, Matrix)

'Matrix' / 'Matrix' = 'Matrix' This is a coefficient divide

public static Matrix CoeffDivide(Matrix a, Matrix b)

Parameters

a Matrix
b Matrix

Returns

Matrix

CoeffMultiply(Matrix, Matrix)

'Matrix' * 'Matrix' = 'Matrix' This is a coefficient multiply

public static Matrix CoeffMultiply(Matrix a, Matrix b)

Parameters

a Matrix
b Matrix

Returns

Matrix

Equals(object)

public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Equals(object, double)

Determine whether the specified object is equal to the current matrix, with some specified precision

public bool Equals(object obj, double precision)

Parameters

obj object

The object to compare with the current object

precision double

The precision within which values are considered equal

Returns

bool

true if the specified object is equal to the current object; otherwise, false

GetColumn(int)

Get 'Matrix' column at index

public Vector GetColumn(int index)

Parameters

index int

column index

Returns

Vector

GetEnumerator()

public IEnumerator<double> GetEnumerator()

Returns

IEnumerator<double>

GetHashCode()

public override int GetHashCode()

Returns

int

GetRow(int)

Get 'Matrix' row at index

public Vector GetRow(int index)

Parameters

index int

row index

Returns

Vector

GetRow(uint)

Get 'Matrix' row at index

public Vector GetRow(uint index)

Parameters

index uint

row index

Returns

Vector

GetSubMatrix(int, int, int, int)

THIS FUNCTION NEEDS TO BE IMPROVED...

public Matrix GetSubMatrix(int row_index, int row_count, int col_index, int col_count)

Parameters

row_index int

the row index

row_count int

the row count

col_index int

the column index

col_count int

the column count

Returns

Matrix

IsZero()

Is 'Matrix' all zeros

public bool IsZero()

Returns

bool

Map(Matrix, Func<double, double, double>)

Map a 'Matrix' value into this matrix

public void Map(Matrix a, Func<double, double, double> func)

Parameters

a Matrix

the value to map

func Func<double, double, double>

the map function

Map(Func<double, double>)

Map all value in this matrix

public void Map(Func<double, double> func)

Parameters

func Func<double, double>

the map function

Map(Func<double, int, double>)

Map all value in this matrix

public void Map(Func<double, int, double> func)

Parameters

func Func<double, int, double>

the map function

Map(Func<double, int, int, double>)

Map all value in this matrix

public void Map(Func<double, int, int, double> func)

Parameters

func Func<double, int, int, double>

the map function

SetColumn(int, Vector)

Set 'Matrix' column data at index

public void SetColumn(int index, Vector value)

Parameters

index int

column index

value Vector

column value

SetIdentity(double)

Set the matrix identity to some double. Default value is 1.0.

public void SetIdentity(double value = 1)

Parameters

value double

Value to set on Matrix diagonal

SetRow(int, Vector)

Set 'Matrix' row data at index

public void SetRow(int index, Vector value)

Parameters

index int

row index

value Vector

row value

SetSubMatrix(int, int, int, int, Matrix)

THIS FUNCTION NEEDS TO BE IMPROVED...

public void SetSubMatrix(int row_index, int row_count, int col_index, int col_count, Matrix m)

Parameters

row_index int

the row index

row_count int

the row count

col_index int

the column index

col_count int

the column count

m Matrix

the value to set

ToString()

public override string ToString()

Returns

string

ToString(string)

public string ToString(string format)

Parameters

format string

Returns

string

Operators

operator +(Matrix, Matrix)

Returns the addition of a 'Matrix' with a 'Matrix'

public static Matrix operator +(Matrix a, Matrix b)

Parameters

a Matrix
b Matrix

Returns

Matrix

operator +(Matrix, double)

Returns the addition of a 'double' with a 'Matrix'

public static Matrix operator +(Matrix a, double b)

Parameters

a Matrix
b double

Returns

Matrix

operator +(double, Matrix)

Returns the addition of a 'Matrix' with a 'double'

public static Matrix operator +(double a, Matrix b)

Parameters

a double
b Matrix

Returns

Matrix

operator /(Matrix, double)

Returns the division of a 'double' with a 'Matrix'

public static Matrix operator /(Matrix a, double b)

Parameters

a Matrix
b double

Returns

Matrix

operator /(double, Matrix)

Returns the division of a 'Matrix' with a 'double'

public static Matrix operator /(double a, Matrix b)

Parameters

a double
b Matrix

Returns

Matrix

operator ==(Matrix, Matrix)

Returns true if 'Matrix' is equal to 'Matrix'

public static bool operator ==(Matrix a, Matrix b)

Parameters

a Matrix

The 1st 'Matrix'

b Matrix

The 2nd 'Matrix'

Returns

bool

operator ==(Matrix, double)

Returns true if 'Matrix' is equal to 'double'

public static bool operator ==(Matrix a, double b)

Parameters

a Matrix

The 1st 'Matrix'

b double

The 2nd 'double'

Returns

bool

operator ==(double, Matrix)

Returns true if 'double' is equal to 'Matrix'

public static bool operator ==(double a, Matrix b)

Parameters

a double

The 1st 'double'

b Matrix

The 2nd 'Matrix'

Returns

bool

explicit operator Matrix(Vector3)

Casts a vector3 to a matrix as a column vector

public static explicit operator Matrix(Vector3 a)

Parameters

a Vector3

The vector3

Returns

Matrix

operator >(Matrix, Matrix)

Returns true if 'Matrix' is greater than 'Matrix'

public static bool operator >(Matrix a, Matrix b)

Parameters

a Matrix

The 1st 'Matrix'

b Matrix

The 2nd 'Matrix'

Returns

bool

operator >(Matrix, double)

Returns true if 'Matrix' is greater than 'double'

public static bool operator >(Matrix a, double b)

Parameters

a Matrix

The 1st 'Matrix'

b double

The 2nd 'double'

Returns

bool

operator >(double, Matrix)

Returns true if 'double' is greater than 'Matrix'

public static bool operator >(double a, Matrix b)

Parameters

a double

The 1st 'double'

b Matrix

The 2nd 'Matrix'

Returns

bool

operator >=(Matrix, Matrix)

Returns true if 'Matrix' is greater than or equal to 'Matrix'

public static bool operator >=(Matrix a, Matrix b)

Parameters

a Matrix

The 1st 'Matrix'

b Matrix

The 2nd 'Matrix'

Returns

bool

operator >=(Matrix, double)

Returns true if 'Matrix' is greater than or equal to 'double'

public static bool operator >=(Matrix a, double b)

Parameters

a Matrix

The 1st 'Matrix'

b double

The 2nd 'double'

Returns

bool

operator >=(double, Matrix)

Returns true if 'double' is greater than or equal to 'Matrix'

public static bool operator >=(double a, Matrix b)

Parameters

a double

The 1st 'double'

b Matrix

The 2nd 'Matrix'

Returns

bool

implicit operator Vector(Matrix)

Implicit cast 'Matrix' to 'Vector'

public static implicit operator Vector(Matrix a)

Parameters

a Matrix

Returns

Vector

implicit operator Matrix(Matrix3)

Implicit cast 'Matrix3' to 'Matrix'

public static implicit operator Matrix(Matrix3 a)

Parameters

a Matrix3

Returns

Matrix

implicit operator Matrix(Matrix4)

Implicit cast 'Matrix4' to 'Vector'

public static implicit operator Matrix(Matrix4 a)

Parameters

a Matrix4

Returns

Matrix

operator !=(Matrix, Matrix)

Returns true if 'Matrix' is not equal to 'Matrix'

public static bool operator !=(Matrix a, Matrix b)

Parameters

a Matrix

The 1st 'Matrix'

b Matrix

The 2nd 'Matrix'

Returns

bool

operator !=(Matrix, double)

Returns true if 'Matrix' is not equal to 'double'

public static bool operator !=(Matrix a, double b)

Parameters

a Matrix

The 1st 'Matrix'

b double

The 2nd 'double'

Returns

bool

operator !=(double, Matrix)

Returns true if 'double' is not equal to 'Matrix'

public static bool operator !=(double a, Matrix b)

Parameters

a double

The 1st 'double'

b Matrix

The 2nd 'Matrix'

Returns

bool

operator <(Matrix, Matrix)

Returns true if 'Matrix' is less than 'Matrix'

public static bool operator <(Matrix a, Matrix b)

Parameters

a Matrix

The 1st 'Matrix'

b Matrix

The 2nd 'Matrix'

Returns

bool

operator <(Matrix, double)

Returns true if 'Matrix' is less than 'double'

public static bool operator <(Matrix a, double b)

Parameters

a Matrix

The 1st 'Matrix'

b double

The 2nd 'double'

Returns

bool

operator <(double, Matrix)

Returns true if 'double' is less than 'Matrix'

public static bool operator <(double a, Matrix b)

Parameters

a double

The 1st 'double'

b Matrix

The 2nd 'Matrix'

Returns

bool

operator <=(Matrix, Matrix)

Returns true if 'Matrix' is less than or equal to 'Matrix'

public static bool operator <=(Matrix a, Matrix b)

Parameters

a Matrix

The 1st 'Matrix'

b Matrix

The 2nd 'Matrix'

Returns

bool

operator <=(Matrix, double)

Returns true if 'Matrix' is less than or equal to 'double'

public static bool operator <=(Matrix a, double b)

Parameters

a Matrix

The 1st 'Matrix'

b double

The 2nd 'double'

Returns

bool

operator <=(double, Matrix)

Returns true if 'double' is less than or equal to 'Matrix'

public static bool operator <=(double a, Matrix b)

Parameters

a double

The 1st 'double'

b Matrix

The 2nd 'Matrix'

Returns

bool

operator *(Matrix, Matrix)

Returns the multiplication of a 'Matrix' with a 'Matrix'

public static Matrix operator *(Matrix a, Matrix b)

Parameters

a Matrix
b Matrix

Returns

Matrix

operator *(Matrix, Vector)

public static Vector operator *(Matrix a, Vector b)

Parameters

a Matrix
b Vector

Returns

Vector

operator *(Matrix, double)

Returns the multiplication of a 'Matrix' with a 'double'

public static Matrix operator *(Matrix a, double b)

Parameters

a Matrix
b double

Returns

Matrix

operator *(Vector, Matrix)

Returns the multiplication of a 'Vector' with a 'Matrix'

public static Vector operator *(Vector a, Matrix b)

Parameters

a Vector
b Matrix

Returns

Vector

operator *(double, Matrix)

Returns the multiplication of a 'double' with a 'Matrix'

public static Matrix operator *(double a, Matrix b)

Parameters

a double
b Matrix

Returns

Matrix

operator -(Matrix, Matrix)

Returns the subtraction of a 'Matrix' with a 'Matrix'

public static Matrix operator -(Matrix a, Matrix b)

Parameters

a Matrix
b Matrix

Returns

Matrix

operator -(Matrix, double)

Returns the subtraction of a 'Matrix' with a 'double'

public static Matrix operator -(Matrix a, double b)

Parameters

a Matrix
b double

Returns

Matrix

operator -(double, Matrix)

Returns the subtraction of a 'double' with a 'Matrix'

public static Matrix operator -(double a, Matrix b)

Parameters

a double
b Matrix

Returns

Matrix

operator -(Matrix)

Returns the negation of a 'Matrix'

public static Matrix operator -(Matrix a)

Parameters

a Matrix

Returns

Matrix