C# Class LitDev.LDMatrix

Mostrar archivo Open project: litdev1/LitDev

Public Methods

Method Description
Add ( Primitive matrix1, Primitive matrix2, Primitive result ) : Primitive

Add two matrices, the number of rows and columns of the 3 matrices given must be the same. Alternatively, if the second matrix is a scalar number then it is added to each element of the first matrix.

Copy ( Primitive matrix1, Primitive matrix2 ) : Primitive

Copy one matrix to an existing matrix. The dimensions of the 2 matrices must be the same.

CopyNew ( Primitive matrix ) : Primitive

Copy one matrix to a new matrix.

CopyToSBArray ( Primitive matrix ) : Primitive

Copy LDMatrix type to SmallBasic array type. The reverse operation (SmallBasic to LDMatrix) isn't possible becuase the SmallBasic indexes are not necessarily contiguous integers.

Create ( Primitive rows, Primitive cols ) : Primitive

Create a matrix object. Row and column matrices can be defined with rows = 1 or cols = 1 respectively.

Delete ( Primitive matrix ) : Primitive

Delete an existing matrix (not generally required, but can save memory if lots of matrices are created).

GetValue ( Primitive matrix, Primitive row, Primitive col ) : Primitive

Get value in matrix.

Inverse ( Primitive matrix, Primitive inverse ) : Primitive

Calculate the inverse of a matrix (using Gaussian Elimination). The number of rows and columns of the matrix and inverse must be the same (square matrices). A singular matrix returns "SINGULAR" and the inverse matrix will be incorrect.

Multiply ( Primitive matrix1, Primitive matrix2, Primitive result ) : Primitive

Multiply two matrices, the number of columns of the first and rows of the second matrix must be the same. The number of rows and columns of the result matrix must be the rows of the first and columns of the second. Alternatively, if the second matrix is a scalar number then it is multiplied by each element of the first matrix and the dimensions of the first and result must be the same.

SetValue ( Primitive matrix, Primitive row, Primitive col, Primitive value ) : Primitive

Set value in matrix.

Transpose ( Primitive matrix, Primitive transpose ) : Primitive

Calculate the transpose of a matrix. The number of rows and columns of the matrix and transpose must be reversed (cols = rows and vice versa).

View ( Primitive matrix, Primitive modal ) : void

View a matrix for dubugging purposes.

Private Methods

Method Description
getMatrix ( string name ) : Matrix
getNewNumber ( ) : int

Method Details

Add() public static method

Add two matrices, the number of rows and columns of the 3 matrices given must be the same. Alternatively, if the second matrix is a scalar number then it is added to each element of the first matrix.
public static Add ( Primitive matrix1, Primitive matrix2, Primitive result ) : Primitive
matrix1 Primitive The first matrix.
matrix2 Primitive The second matrix (or scalar value).
result Primitive The result matrix.
return Primitive

Copy() public static method

Copy one matrix to an existing matrix. The dimensions of the 2 matrices must be the same.
public static Copy ( Primitive matrix1, Primitive matrix2 ) : Primitive
matrix1 Primitive /// The matrix to copy from. ///
matrix2 Primitive /// The matrix to copy to. ///
return Primitive

CopyNew() public static method

Copy one matrix to a new matrix.
public static CopyNew ( Primitive matrix ) : Primitive
matrix Primitive /// The matrix to copy. ///
return Primitive

CopyToSBArray() public static method

Copy LDMatrix type to SmallBasic array type. The reverse operation (SmallBasic to LDMatrix) isn't possible becuase the SmallBasic indexes are not necessarily contiguous integers.
public static CopyToSBArray ( Primitive matrix ) : Primitive
matrix Primitive /// The matrix name. ///
return Primitive

Create() public static method

Create a matrix object. Row and column matrices can be defined with rows = 1 or cols = 1 respectively.
public static Create ( Primitive rows, Primitive cols ) : Primitive
rows Primitive The number of rows.
cols Primitive The number of columns.
return Primitive

Delete() public static method

Delete an existing matrix (not generally required, but can save memory if lots of matrices are created).
public static Delete ( Primitive matrix ) : Primitive
matrix Primitive /// The matrix name. ///
return Primitive

GetValue() public static method

Get value in matrix.
public static GetValue ( Primitive matrix, Primitive row, Primitive col ) : Primitive
matrix Primitive /// The matrix name. ///
row Primitive /// The row at which to get the value (indexed starting from 1). ///
col Primitive /// The column at which to get the value (indexed starting from 1). ///
return Primitive

Inverse() public static method

Calculate the inverse of a matrix (using Gaussian Elimination). The number of rows and columns of the matrix and inverse must be the same (square matrices). A singular matrix returns "SINGULAR" and the inverse matrix will be incorrect.
public static Inverse ( Primitive matrix, Primitive inverse ) : Primitive
matrix Primitive The matrix to invert (unmodified by inversion).
inverse Primitive The inverse matrix.
return Primitive

Multiply() public static method

Multiply two matrices, the number of columns of the first and rows of the second matrix must be the same. The number of rows and columns of the result matrix must be the rows of the first and columns of the second. Alternatively, if the second matrix is a scalar number then it is multiplied by each element of the first matrix and the dimensions of the first and result must be the same.
public static Multiply ( Primitive matrix1, Primitive matrix2, Primitive result ) : Primitive
matrix1 Primitive The first matrix.
matrix2 Primitive The second matrix (or scalar value).
result Primitive The result matrix.
return Primitive

SetValue() public static method

Set value in matrix.
public static SetValue ( Primitive matrix, Primitive row, Primitive col, Primitive value ) : Primitive
matrix Primitive /// The matrix name. ///
row Primitive /// The row at which to add the value (indexed starting from 1). ///
col Primitive /// The column at which to add the value (indexed starting from 1). ///
value Primitive /// The value. ///
return Primitive

Transpose() public static method

Calculate the transpose of a matrix. The number of rows and columns of the matrix and transpose must be reversed (cols = rows and vice versa).
public static Transpose ( Primitive matrix, Primitive transpose ) : Primitive
matrix Primitive The matrix to transpose.
transpose Primitive The resulting transposed matrix.
return Primitive

View() public static method

View a matrix for dubugging purposes.
public static View ( Primitive matrix, Primitive modal ) : void
matrix Primitive The matrix to display.
modal Primitive The matrix display will pause all other actions until it is closed. ("True" or "False").
return void