  Matrix

← Back to list of classes

Description

Summary

Basic matrix implementation: https://en.wikipedia.org/wiki/Matrix_(mathematics)

Members

• #ctor (GenericTensor. Core. GenTensor{AngouriMath. Entity, AngouriMath. Entity. Matrix. EntityTensorWrapperOperations})

Summary

Creates a Matrix from an instance of GenTensor2.
Since only 2-dimensional matrices are supported, it will throw an exception if the number
of dimensions is too high or too low.

Parameter "innerMatrix"

The instance of a matrix. It will be copied inside. Make sure,
that it has exactly two dimensions. If a vector needs to be
created, make it a normal matrix with one column.

Exception "InvalidMatrixOperationException"

Is thrown if the number of dimensions of the passed
tensor is not 2.

• #ctor (System. Func{System. Int32[], AngouriMath. Entity}, System. Int32[])

Summary

List of dimensions
If you need matrix, list 2 dimensions
If you need vector, list 1 dimension (length of the vector)
You can't list 0 dimensions

Property

Summary

• AsScalar

Method

Summary

Casts the matrix to a scalar. It is only
possible if the matrix is 1x1 size.

Exception "InvalidMatrixOperationException"

Thrown if the matrix has size different from 1x1.

Property

• ColumnCount

Property

Summary

The number of columns of a matrix. It is 1 for vectors.

• Determinant

Property

Summary

Finds the symbolical determinant via Laplace's method

• GetEnumerator

Method

Summary

Gets the enumerator. It is required by the interface
IEnumerable, which lets us enumerate over the matrix or vector

Returns

• I (System. Int32, System. Int32)

Summary

Creates a rectangular identity matrix
with the given size

• I (System. Int32)

Summary

Creates a square identity matrix

Method

Method

Method

• InnerMatrix

Property

Summary

The inner matrix of type GenTensor2.

Method

• Inverse

Property

Summary

Returns an inverse matrix if it exists

• IsRowVector

Property

Summary

Checks whether it is a row vector, that is,
the matrix has only one row

• IsScalar

Property

Summary

Determines whether a matrix is a scalar, that is, a one-by-one matrix

• IsSquare

Property

Summary

Checks whether the matrix is square (has as many rows as columns)

• IsVector

Property

Summary

Checks whether the matrix only contains one
column.

• Item(System.Int32,System.Int32)

Property

Summary

Access the tensor if it is a matrix

• Item(System.Int32)

Property

Summary

Returns the i-th element of a vector, or the i-th row of a matrix.

Method

• MainDiagonal

Property

Summary

Returns a vector, where the i-th element
is the [i, i] element of the matrix. The number
of elements in it equals the minimum of RowCount and ColumnCount

• New (GenericTensor. Core. GenTensor{AngouriMath. Entity, AngouriMath. Entity. Matrix. EntityTensorWrapperOperations})

Method

Summary

Reuse the cache by returning the same object if possible

• op_Addition (AngouriMath. Entity. Matrix, AngouriMath. Entity. Matrix)

Method

Summary

The Add operator. Performs an active operation
(elementwise addition of two matrices or vectors)
and then applies inner simplification

• op_Implicit (System. String)~AngouriMath. Entity. Matrix

Method

Summary

Converts from string to specifically tensor

Parameter "expr"

From where to parse (available since 1.3)

• op_Multiply (AngouriMath. Entity. Matrix, AngouriMath. Entity. Matrix)

Method

Summary

The Multiply operator. Performs an active operation
(matrix multiplication of two matrices)
and then applies inner simplification

• op_Subtraction (AngouriMath. Entity. Matrix, AngouriMath. Entity. Matrix)

Method

Summary

The Subtract operator. Performs an active operation
(elementwise subtraction of two matrices or vectors)
and then applies inner simplification

• Pow (System. Int32)

Method

Summary

Performs a binary power of the matrix.
The matrix must be a square matrix.

Returns

A matrix to the given power with InnerSimplified
applied.

• Rank

Property

Summary

The number of linearly independent rows

• ReducedRowEchelonForm

Property

Summary

Reduced row echelon form via Gaussian elimination.

Method

• RowCount

Property

Summary

The number of rows for matrices. The number of elements for vectors.

• RowEchelonForm

Property

Summary

Matrix's form, transformed via Gaussian elimination.

• Shape

Property

Summary

List of Int32s that stand for dimensions

Method

Method

• T

Property

Summary

Changes the order of axes in matrix

• TensorPower (System. Int32)

Method

Summary

Returns the n-th power of the
given vector or matrix. It is
the same as sequential applying
n-1 TensorProduct(AngouriMath.Entity.Matrix,AngouriMath.Entity.Matrix) to this.

Parameter "exp"

The power, or the number
of operands in the a *** a *** ... *** a expression

Returns

Non-simplified tensor
powered vector or matrix. If it
initially had size n x m, it will have
the size of 2^n x 2^m.

• TensorProduct (AngouriMath. Entity. Matrix, AngouriMath. Entity. Matrix)

Method

Summary

Finds a tensor product of two matrices
https://en.wikipedia.org/wiki/Tensor_product

• ToString (System. Boolean)

Summary

Gets a string representation of the
given matrix/vector. If true is
passed, it will format the inner matrix
with new lines and paddings to make it
look like a matrix in plain monospace
text.

Parameter "multilineFormat"

Whether to format it into a matrix
format. If false is passed, it will
return the same as normal ToString.

• Trace

Property

Summary

The trace of a matrix. It is a sum of
all elements on the main diagonal

• With (System. Func{System. Int32, System. Int32, AngouriMath. Entity, AngouriMath. Entity})

Method

Summary

Returns a new matrix/vector of the same shape,
but with each element replaced by the user.

Parameter "elementByIndex"

Takes 2 ints which are row number and column
number of an element, and the current element
as the third argument.

Example

var re = O_4.With
((rowId, colId, element) => (rowId, colId, element) switch
{
(0, 1, _) => 1,
(1, 2, _) => 2,
(>1, 3, _) => 6,
(var a, var b, _) when a + b < 3 => 8,
_ => element
});
Console.WriteLine(re.ToString(multilineFormat: true));

The output is going to be:
Matrix[4 x 4]
8   1   8   0
8   8   2   0
8   0   0   6
0   0   0   6

Returns

A new matrix or vector with the same shape
(row count and column count).

• WithColumn (GenericTensor. Core. GenTensor{AngouriMath. Entity, AngouriMath. Entity. Matrix. EntityTensorWrapperOperations}, System. Int32, AngouriMath. Entity. Matrix)

Summary

Creates a new matrix with the specified column
set to a new column

• WithColumn (System. Int32, AngouriMath. Entity. Matrix)

Summary

Creates a new matrix with the specified column
set to a new column

• WithElement (System. Int32, AngouriMath. Entity)

Summary

Creates a new vector with the specified element being
set to a new value

• WithElement (System. Int32, System. Int32, AngouriMath. Entity)

Summary

Creates a new matrix with the specified element being
set to a new value

• WithRow (GenericTensor. Core. GenTensor{AngouriMath. Entity, AngouriMath. Entity. Matrix. EntityTensorWrapperOperations}, System. Int32, AngouriMath. Entity. Matrix)

Summary

Creates a new matrix with the specified row
set to a new row

• WithRow (System. Int32, AngouriMath. Entity. Matrix)

Summary

Creates a new matrix with the specified row
set to a new row

Angouri © 2019-2022 · Project's repo · Site's repo · Octicons