C# Class YAMP.MatrixValue

The class for representing a matrix value.
Inheritance: NumericValue, IFunction, ISetFunction
Mostra file Open project: FlorianRappl/YAMP Class Usage Examples

Public Methods

Method Description
Abs ( ) : ScalarValue

Computes the L2-Norm of the matrix (seen as a vector).

AddColumn ( Value value ) : MatrixValue

Adds a column specified by the type of the value to add-in. If it is a scalar value, then it is quite simple. For a matrix the geometry is important.

AddMM ( Value left, Value right ) : MatrixValue

Matrix + Matrix

AddMS ( Value left, Value right ) : MatrixValue

Matrix + Scalar

AddRow ( Value value ) : MatrixValue

Creates a new matrix with another row. The row is either simply a number (in this case the value is just inserted) or a matrix (then the geometry is important).

AddSM ( Value left, Value right ) : MatrixValue

Scalar + Matrix

Adjungate ( ) : MatrixValue

Computes the adjungated (transposed + c.c.) matrix.

Clear ( ) : void

Clears all entries.

Clone ( ) : MatrixValue

Creates a deep copy of the matrix.

ComplexDot ( MatrixValue w ) : ScalarValue

Produces a complex dot (this operand is c.c.) product of the given instance (seen as a vector) with another vector.

ComputeLargestStringContent ( ParseContext context ) : Int32

Gets the maximum length of any cell of the matrix by considering the given context.

Copy ( ) : Value

Creates a deep copy of the matrix.

Create ( Value value ) : MatrixValue

Creates a new matrix with the help of a specified value.

DeleteColumns ( int index, int count = 1 ) : void

Deletes the specified number of columns of the matrix.

DeleteRows ( int index, int count = 1 ) : void

Deletes the specified number of rows of the matrix.

Deserialize ( Byte content ) : Value

Creates a new matrix instance from the given content.

Det ( ) : ScalarValue

Computes the determinant of the matrix.

DivideMM ( Value left, Value right ) : MatrixValue

Matrix / Matrix

DivideMS ( Value left, Value right ) : MatrixValue

Matrix / Scalar

DivideSM ( Value left, Value right ) : MatrixValue

Scalar / Matrix

Dot ( MatrixValue w ) : ScalarValue

Produces a dot product of the given instance (seen as a vector) with another vector.

Equals ( object obj ) : bool

Takes a close look if two matrices are equivalent.

ForEach ( ScalarValue>.Func f ) : MatrixValue

Performs the operation f on each element of the matrix, creating a new matrix B where each entry is given by B_jk = f(A_jk).

FrobeniusNorm ( ) : double

Computes the Frobenius-norm of the matrix.

The Frobenius-norm of a matrix the square root of the sum of the squares of all the elements. In the case of a row or column vector, this reduces to the Euclidean vector norm.

GetColumnVector ( int i ) : MatrixValue

Gets the i-th column vector, i.e. a vector which is spanned over all rows of one column.

GetComplexMatrix ( ) : YAMP.ScalarValue[][]

Gets a real matrix of the complete matrix.

GetHashCode ( ) : int

Gives a first hint if two matrices can be equivalent.

GetRealMatrix ( ) : double[][]

Gets a real matrix of the complete matrix.

GetRealVector ( ) : double[]

Gets a real vector of the complete matrix.

GetRealVector ( int yoffset, int ylength, int xoffset, int xlength ) : double[]

Gets a real vector of a submatrix.

GetRowVector ( int j ) : MatrixValue

Gets the j-th row vector, i.e. a vector which is spanned over all columns of one row.

GetSubMatrix ( int y, int xoffset, int xfinal ) : MatrixValue

Creates a sub matrix of the given instance.

GetSubMatrix ( int yoffset, int yfinal, int xoffset, int xfinal ) : MatrixValue

Creates a sub matrix of the given instance.

InfinityNorm ( ) : double

Computes the ∞-norm of the matrix.

The ∞-norm of a matrix is the largest row sum.

Inverse ( ) : MatrixValue

Computes the inverse (if it exists).

MatrixValue ( ) : System

Constructs a new matrix.

MatrixValue ( ScalarValue>.Dictionary values, Int32 rows, Int32 cols ) : System

Constructs a new matrix with the provided values and dimension.

MatrixValue ( Double values ) : System

Constructs a new matrix based on the given two dimensional array.

MatrixValue ( Double values, Int32 rows, Int32 cols ) : System

Constructs a new matrix based on the jagged double array.

MatrixValue ( Int32 rows, Int32 cols ) : System

Constructs a new matrix with the given dimension.

MatrixValue ( Int32 rows, Int32 cols, ScalarValue filling ) : System

Constructs a new matrix with the given dimension and sets each entry to the given value.

MatrixValue ( ScalarValue values, Int32 rows, Int32 cols ) : System

Constructs a new matrix based on the jagged double array.

Max ( ) : MatrixIndex

Gets the index for the maximum entry in the matrix.

Min ( ) : MatrixIndex

Gets the index for the minimum entry in the matrix.

ModuloMS ( Value left, Value right ) : MatrixValue

Matrix % Scalar

ModuloSM ( Value left, Value right ) : MatrixValue

Scalar % Matrix

MultiplyMM ( Value left, Value right ) : Value

Matrix * Matrix

MultiplyMS ( Value left, Value right ) : MatrixValue

Matrix * Scalar

MultiplySM ( Value left, Value right ) : MatrixValue

Scalar * Matrix

One ( int dimension ) : MatrixValue

Creates a new identity matrix of the given dimension.

One ( int rows, int columns ) : MatrixValue

Creates a new identity matrix of the given dimension.

OneNorm ( ) : double

Computes the 1-norm of the matrix.

The 1-norm of a matrix is the largest column sum.

Ones ( int rows, int cols ) : MatrixValue

Creates a matrix containing only ones.

Perform ( ParseContext context, Value argument ) : Value

The method used by YAMP to get values from a matrix.

Perform ( ParseContext context, Value argument, Value values ) : Value

Method used by YAMP to set values in a matrix.

PowMS ( Value basis, Value exponent ) : MatrixValue

Matrix ^ Scalar

PowSM ( Value basis, Value exponent ) : MatrixValue

Scalar ^ Matrix

Randomize ( ) : void

Goes over all rows and columns and randomizes the values.

Serialize ( ) : Byte[]

Serializes the current instance.

SetColumnVector ( int i, MatrixValue m ) : MatrixValue

Sets the i-th column vector to be of the given matrix.

SetRowVector ( int j, MatrixValue m ) : MatrixValue

Sets the j-th row vector to be of the given matrix.

SubtractMM ( Value left, Value right ) : Value

Matrix - Matrix

SubtractMS ( Value left, Value right ) : MatrixValue

Matrix - Scalar

SubtractSM ( Value left, Value right ) : MatrixValue

Scalar - Matrix

Sum ( ) : ScalarValue

Computes the sum of all entries.

ToArray ( ) : YAMP.ScalarValue[]

Copies the internal scalar values to a 1-dim. complex array.

ToString ( ParseContext context ) : String

Creates a standard string representation of the matrix.

ToString ( ParseContext context, Int32 exponent ) : String

Creates a standard string representation of the matrix.

Trace ( ) : ScalarValue

Computes the trace (sum over all elements on the diagonal) of the matrix.

Transpose ( ) : MatrixValue

Computes the transposed matrix.

VectorSort ( ) : MatrixValue

Sorts the values of the matrix and outputs the values in a new vector.

operator ( ) : System.Boolean

Inequality.

operator ( ) : MatrixValue

Multiplication.

this ( int i ) : ScalarValue

Gets or sets the i-th element of the matrix (counted rows-first).

this ( int j, int i ) : ScalarValue

Gets the element of the j-th row and i-th column.

Protected Methods

Method Description
ContainsIndex ( MatrixIndex index ) : bool

Does the matrix contain this index? If not then the value is zero.

GetIndex ( int i ) : MatrixIndex

Gets the matrix-index (row, column) of the 1-based 1-dim. index i.

GetIndex ( MatrixIndex index ) : ScalarValue

Gets the entry of the specified matrix-index entry in the dictionary. Please check if the element is in the dictionary anyway (ContainsIndex).

RegisterOperators ( ) : void

Registers all operators that are associated with the matrix.

Private Methods

Method Description
DeleteFullColumns ( List indices ) : void
DeleteFullRows ( List indices ) : void
LogicalSubscripting ( MatrixValue m ) : MatrixValue
LogicalSubscripting ( MatrixValue m, List indices ) : void

Method Details

Abs() public method

Computes the L2-Norm of the matrix (seen as a vector).
public Abs ( ) : ScalarValue
return ScalarValue

AddColumn() public method

Adds a column specified by the type of the value to add-in. If it is a scalar value, then it is quite simple. For a matrix the geometry is important.
public AddColumn ( Value value ) : MatrixValue
value Value The value to add in another column.
return MatrixValue

AddMM() public static method

Matrix + Matrix
public static AddMM ( Value left, Value right ) : MatrixValue
left Value Must be a matrix.
right Value Must be a matrix.
return MatrixValue

AddMS() public static method

Matrix + Scalar
public static AddMS ( Value left, Value right ) : MatrixValue
left Value Must be a matr.
right Value Must be a scalar.
return MatrixValue

AddRow() public method

Creates a new matrix with another row. The row is either simply a number (in this case the value is just inserted) or a matrix (then the geometry is important).
public AddRow ( Value value ) : MatrixValue
value Value The value to append as a row.
return MatrixValue

AddSM() public static method

Scalar + Matrix
public static AddSM ( Value left, Value right ) : MatrixValue
left Value Must be a scalar.
right Value Must be a matrix.
return MatrixValue

Adjungate() public method

Computes the adjungated (transposed + c.c.) matrix.
public Adjungate ( ) : MatrixValue
return MatrixValue

Clear() public method

Clears all entries.
public Clear ( ) : void
return void

Clone() public method

Creates a deep copy of the matrix.
public Clone ( ) : MatrixValue
return MatrixValue

ComplexDot() public method

Produces a complex dot (this operand is c.c.) product of the given instance (seen as a vector) with another vector.
public ComplexDot ( MatrixValue w ) : ScalarValue
w MatrixValue The second operand of the complex dot-product.
return ScalarValue

ComputeLargestStringContent() public method

Gets the maximum length of any cell of the matrix by considering the given context.
public ComputeLargestStringContent ( ParseContext context ) : Int32
context ParseContext The parse context which holds the state information.
return System.Int32

ContainsIndex() protected method

Does the matrix contain this index? If not then the value is zero.
protected ContainsIndex ( MatrixIndex index ) : bool
index MatrixIndex The matrix-index (row, column).
return bool

Copy() public method

Creates a deep copy of the matrix.
public Copy ( ) : Value
return Value

Create() public static method

Creates a new matrix with the help of a specified value.
public static Create ( Value value ) : MatrixValue
value Value The value to initialize the matrix with.
return MatrixValue

DeleteColumns() public method

Deletes the specified number of columns of the matrix.
public DeleteColumns ( int index, int count = 1 ) : void
index int The column index to start (1-based).
count int The number of columns to remove.
return void

DeleteRows() public method

Deletes the specified number of rows of the matrix.
public DeleteRows ( int index, int count = 1 ) : void
index int The row index to start (1-based).
count int The number of rows to remove.
return void

Deserialize() public method

Creates a new matrix instance from the given content.
public Deserialize ( Byte content ) : Value
content Byte The binary content.
return Value

Det() public method

Computes the determinant of the matrix.
public Det ( ) : ScalarValue
return ScalarValue

DivideMM() public static method

Matrix / Matrix
public static DivideMM ( Value left, Value right ) : MatrixValue
left Value Must be a matrix.
right Value Must be a matrix.
return MatrixValue

DivideMS() public static method

Matrix / Scalar
public static DivideMS ( Value left, Value right ) : MatrixValue
left Value Must be a matr.
right Value Must be a scalar.
return MatrixValue

DivideSM() public static method

Scalar / Matrix
public static DivideSM ( Value left, Value right ) : MatrixValue
left Value Must be a scalar.
right Value Must be a matrix.
return MatrixValue

Dot() public method

Produces a dot product of the given instance (seen as a vector) with another vector.
public Dot ( MatrixValue w ) : ScalarValue
w MatrixValue The second operand of the dot-product.
return ScalarValue

Equals() public method

Takes a close look if two matrices are equivalent.
public Equals ( object obj ) : bool
obj object The other matrix (otherwise it is false).
return bool

ForEach() public method

Performs the operation f on each element of the matrix, creating a new matrix B where each entry is given by B_jk = f(A_jk).
public ForEach ( ScalarValue>.Func f ) : MatrixValue
f ScalarValue>.Func The function to use.
return MatrixValue

FrobeniusNorm() public method

Computes the Frobenius-norm of the matrix.

The Frobenius-norm of a matrix the square root of the sum of the squares of all the elements. In the case of a row or column vector, this reduces to the Euclidean vector norm.

public FrobeniusNorm ( ) : double
return double

GetColumnVector() public method

Gets the i-th column vector, i.e. a vector which is spanned over all rows of one column.
public GetColumnVector ( int i ) : MatrixValue
i int The index of the column to get the vector from.
return MatrixValue

GetComplexMatrix() public method

Gets a real matrix of the complete matrix.
public GetComplexMatrix ( ) : YAMP.ScalarValue[][]
return YAMP.ScalarValue[][]

GetHashCode() public method

Gives a first hint if two matrices can be equivalent.
public GetHashCode ( ) : int
return int

GetIndex() protected method

Gets the matrix-index (row, column) of the 1-based 1-dim. index i.
protected GetIndex ( int i ) : MatrixIndex
i int The 1-based index. The i-th element is requested.
return MatrixIndex

GetIndex() protected method

Gets the entry of the specified matrix-index entry in the dictionary. Please check if the element is in the dictionary anyway (ContainsIndex).
protected GetIndex ( MatrixIndex index ) : ScalarValue
index MatrixIndex The matrix-index (row, column).
return ScalarValue

GetRealMatrix() public method

Gets a real matrix of the complete matrix.
public GetRealMatrix ( ) : double[][]
return double[][]

GetRealVector() public method

Gets a real vector of the complete matrix.
public GetRealVector ( ) : double[]
return double[]

GetRealVector() public method

Gets a real vector of a submatrix.
public GetRealVector ( int yoffset, int ylength, int xoffset, int xlength ) : double[]
yoffset int The offset in rows.
ylength int The length in rows.
xoffset int The offset in columns.
xlength int The length in columns.
return double[]

GetRowVector() public method

Gets the j-th row vector, i.e. a vector which is spanned over all columns of one row.
public GetRowVector ( int j ) : MatrixValue
j int The index of the row to get the vector from.
return MatrixValue

GetSubMatrix() public method

Creates a sub matrix of the given instance.
public GetSubMatrix ( int y, int xoffset, int xfinal ) : MatrixValue
y int Row-indices to consider.
xoffset int Horizontal offset in columns.
xfinal int Final column-index.
return MatrixValue

GetSubMatrix() public method

Creates a sub matrix of the given instance.
public GetSubMatrix ( int yoffset, int yfinal, int xoffset, int xfinal ) : MatrixValue
yoffset int Vertical offset in rows.
yfinal int Final row-index.
xoffset int Horizontal offset in columns.
xfinal int Final column-index.
return MatrixValue

InfinityNorm() public method

Computes the ∞-norm of the matrix.

The ∞-norm of a matrix is the largest row sum.

public InfinityNorm ( ) : double
return double

Inverse() public method

Computes the inverse (if it exists).
public Inverse ( ) : MatrixValue
return MatrixValue

MatrixValue() public method

Constructs a new matrix.
public MatrixValue ( ) : System
return System

MatrixValue() public method

Constructs a new matrix with the provided values and dimension.
public MatrixValue ( ScalarValue>.Dictionary values, Int32 rows, Int32 cols ) : System
values ScalarValue>.Dictionary The values to assign.
rows System.Int32 The number of rows in the new matrix.
cols System.Int32 The number of columns in the matrix.
return System

MatrixValue() public method

Constructs a new matrix based on the given two dimensional array.
public MatrixValue ( Double values ) : System
values Double The values which set the dimensions and starting values of the matrix.
return System

MatrixValue() public method

Constructs a new matrix based on the jagged double array.
public MatrixValue ( Double values, Int32 rows, Int32 cols ) : System
values Double The values to use.
rows System.Int32 The number of rows in the new matrix.
cols System.Int32 The number of columns in the matrix.
return System

MatrixValue() public method

Constructs a new matrix with the given dimension.
public MatrixValue ( Int32 rows, Int32 cols ) : System
rows System.Int32 The number of rows.
cols System.Int32 The number of columns.
return System

MatrixValue() public method

Constructs a new matrix with the given dimension and sets each entry to the given value.
public MatrixValue ( Int32 rows, Int32 cols, ScalarValue filling ) : System
rows System.Int32
cols System.Int32
filling ScalarValue
return System

MatrixValue() public method

Constructs a new matrix based on the jagged double array.
public MatrixValue ( ScalarValue values, Int32 rows, Int32 cols ) : System
values ScalarValue The values to use.
rows System.Int32 The number of rows in the new matrix.
cols System.Int32 The number of columns in the matrix.
return System

Max() public method

Gets the index for the maximum entry in the matrix.
public Max ( ) : MatrixIndex
return MatrixIndex

Min() public method

Gets the index for the minimum entry in the matrix.
public Min ( ) : MatrixIndex
return MatrixIndex

ModuloMS() public static method

Matrix % Scalar
public static ModuloMS ( Value left, Value right ) : MatrixValue
left Value Must be a matr.
right Value Must be a scalar.
return MatrixValue

ModuloSM() public static method

Scalar % Matrix
public static ModuloSM ( Value left, Value right ) : MatrixValue
left Value Must be a scalar.
right Value Must be a matrix.
return MatrixValue

MultiplyMM() public static method

Matrix * Matrix
public static MultiplyMM ( Value left, Value right ) : Value
left Value Must be a matrix.
right Value Must be a matrix.
return Value

MultiplyMS() public static method

Matrix * Scalar
public static MultiplyMS ( Value left, Value right ) : MatrixValue
left Value Must be a matr.
right Value Must be a scalar.
return MatrixValue

MultiplySM() public static method

Scalar * Matrix
public static MultiplySM ( Value left, Value right ) : MatrixValue
left Value Must be a scalar.
right Value Must be a matrix.
return MatrixValue

One() public static method

Creates a new identity matrix of the given dimension.
public static One ( int dimension ) : MatrixValue
dimension int The rank of the identity matrix.
return MatrixValue

One() public static method

Creates a new identity matrix of the given dimension.
public static One ( int rows, int columns ) : MatrixValue
rows int The number of rows of the identity matrix.
columns int The number of columns of the identity matrix.
return MatrixValue

OneNorm() public method

Computes the 1-norm of the matrix.

The 1-norm of a matrix is the largest column sum.

public OneNorm ( ) : double
return double

Ones() public static method

Creates a matrix containing only ones.
public static Ones ( int rows, int cols ) : MatrixValue
rows int The number of rows in the new matrix.
cols int The number of columns in the new matrix.
return MatrixValue

Perform() public method

The method used by YAMP to get values from a matrix.
public Perform ( ParseContext context, Value argument ) : Value
context ParseContext The context where this is happening.
argument Value The 1-dim or 2-dim indices.
return Value

Perform() public method

Method used by YAMP to set values in a matrix.
public Perform ( ParseContext context, Value argument, Value values ) : Value
context ParseContext The context where this is happening.
argument Value The indices (1-dim or 2-dim).
values Value The value(s) to set.
return Value

PowMS() public static method

Matrix ^ Scalar
public static PowMS ( Value basis, Value exponent ) : MatrixValue
basis Value Must be a matr.
exponent Value Must be a scalar.
return MatrixValue

PowSM() public static method

Scalar ^ Matrix
public static PowSM ( Value basis, Value exponent ) : MatrixValue
basis Value Must be a scalar.
exponent Value Must be a matrix.
return MatrixValue

Randomize() public method

Goes over all rows and columns and randomizes the values.
public Randomize ( ) : void
return void

RegisterOperators() protected method

Registers all operators that are associated with the matrix.
protected RegisterOperators ( ) : void
return void

Serialize() public method

Serializes the current instance.
public Serialize ( ) : Byte[]
return Byte[]

SetColumnVector() public method

Sets the i-th column vector to be of the given matrix.
public SetColumnVector ( int i, MatrixValue m ) : MatrixValue
i int The index of the column to set the vector to.
m MatrixValue The matrix with values to set the i-th column to.
return MatrixValue

SetRowVector() public method

Sets the j-th row vector to be of the given matrix.
public SetRowVector ( int j, MatrixValue m ) : MatrixValue
j int The index of the row to set the vector to.
m MatrixValue The matrix with values to set the j-th row to.
return MatrixValue

SubtractMM() public static method

Matrix - Matrix
public static SubtractMM ( Value left, Value right ) : Value
left Value Must be a matrix.
right Value Must be a matrix.
return Value

SubtractMS() public static method

Matrix - Scalar
public static SubtractMS ( Value left, Value right ) : MatrixValue
left Value Must be a matrix.
right Value Must be a scalar.
return MatrixValue

SubtractSM() public static method

Scalar - Matrix
public static SubtractSM ( Value left, Value right ) : MatrixValue
left Value Must be a scalar.
right Value Must be a matrix.
return MatrixValue

Sum() public method

Computes the sum of all entries.
public Sum ( ) : ScalarValue
return ScalarValue

ToArray() public method

Copies the internal scalar values to a 1-dim. complex array.
public ToArray ( ) : YAMP.ScalarValue[]
return YAMP.ScalarValue[]

ToString() public method

Creates a standard string representation of the matrix.
public ToString ( ParseContext context ) : String
context ParseContext The parse content.
return String

ToString() public method

Creates a standard string representation of the matrix.
public ToString ( ParseContext context, Int32 exponent ) : String
context ParseContext The parse content.
exponent System.Int32 The global exponent that is in use.
return String

Trace() public method

Computes the trace (sum over all elements on the diagonal) of the matrix.
public Trace ( ) : ScalarValue
return ScalarValue

Transpose() public method

Computes the transposed matrix.
public Transpose ( ) : MatrixValue
return MatrixValue

VectorSort() public method

Sorts the values of the matrix and outputs the values in a new vector.
public VectorSort ( ) : MatrixValue
return MatrixValue

operator() public static method

Inequality.
public static operator ( ) : System.Boolean
return System.Boolean

operator() public static method

Multiplication.
public static operator ( ) : MatrixValue
return MatrixValue

this() public method

Gets or sets the i-th element of the matrix (counted rows-first).
public this ( int i ) : ScalarValue
i int The 1-based index.
return ScalarValue

this() public method

Gets the element of the j-th row and i-th column.
public this ( int j, int i ) : ScalarValue
j int The 1-based row index.
i int The 1-based column index.
return ScalarValue