ComplexMatrix Class |
Namespace: Novacta.Analytics
public class ComplexMatrix : IList<Complex>, ICollection<Complex>, IEnumerable<Complex>, IEnumerable, IReadOnlyList<Complex>, IReadOnlyCollection<Complex>, IComplexMatrixPatterns, IMatrixPatterns, IReadOnlyTabularCollection<Complex, ComplexMatrix>, ITabularCollection<Complex, ComplexMatrix>
The ComplexMatrix type exposes the following members.
Name | Description | |
---|---|---|
ComplexMatrix |
Initializes a new instance of the ComplexMatrix class
as a scalar matrix having the specified value.
|
Name | Description | |
---|---|---|
ColumnNames |
Exposes the dictionary of column names, keyed by column indexes.
| |
Count |
Gets the number of elements in this instance.
| |
HasColumnNames |
Gets a value indicating whether this instance has at least a named column.
| |
HasRowNames |
Gets a value indicating whether this instance has at least a named row.
| |
IsBidiagonal |
Gets a value indicating whether this instance is bidiagonal.
| |
IsColumnVector |
Gets a value indicating whether this instance is a column vector.
| |
IsDiagonal |
Gets a value indicating whether this instance is diagonal.
| |
IsHermitian |
Gets a value indicating whether this instance is Hermitian.
| |
IsHessenberg |
Gets a value indicating whether this instance is Hessenberg.
| |
IsLowerBidiagonal |
Gets a value indicating whether this instance is lower bidiagonal.
| |
IsLowerHessenberg |
Gets a value indicating whether this instance is lower Hessenberg.
| |
IsLowerTriangular |
Gets a value indicating whether this instance is lower triangular.
| |
IsReadOnly |
Gets a value indicating whether this instance is read-only.
| |
IsRowVector |
Gets a value indicating whether this instance is a row vector.
| |
IsScalar |
Gets a value indicating whether this instance is scalar.
| |
IsSkewHermitian |
Gets a value indicating whether this instance is Skew-Hermitian.
| |
IsSkewSymmetric |
Gets a value indicating whether this instance is skew symmetric.
| |
IsSquare |
Gets a value indicating whether this instance is square.
| |
IsSymmetric |
Gets a value indicating whether this instance is symmetric.
| |
IsTriangular |
Gets a value indicating whether this instance is triangular.
| |
IsTridiagonal |
Gets a value indicating whether this instance is tridiagonal.
| |
IsUpperBidiagonal |
Gets a value indicating whether this instance is upper bidiagonal.
| |
IsUpperHessenberg |
Gets a value indicating whether this instance is upper Hessenberg.
| |
IsUpperTriangular |
Gets a value indicating whether this instance is upper triangular.
| |
IsVector |
Gets a value indicating whether this instance is a vector.
| |
ItemInt32 |
Gets or sets the element of this instance corresponding to the specified linear
index.
| |
ItemIndexCollection, IndexCollection |
Gets or sets the elements of this instance corresponding to the specified row
and column indexes.
| |
ItemIndexCollection, Int32 |
Gets or sets the elements of this instance corresponding to the specified row
and column indexes.
| |
ItemIndexCollection, String |
Gets or sets the elements of this instance corresponding to
the specified row and column indexes.
| |
ItemInt32, IndexCollection |
Gets or sets the elements of this instance corresponding to the specified row
and column indexes.
| |
ItemInt32, Int32 |
Gets or sets the element of this instance corresponding to the
specified row and column indexes.
| |
ItemInt32, String |
Gets or sets the elements of this instance corresponding to the
specified row and column indexes.
| |
ItemString, IndexCollection |
Gets or sets the elements of this instance corresponding to
the specified row and column indexes.
| |
ItemString, Int32 |
Gets or sets the elements of this instance corresponding to the specified row
and column indexes.
| |
ItemString, String |
Gets or sets the elements of this instance corresponding to
the specified row and column indexes.
| |
LowerBandwidth |
Gets the lower bandwidth of this instance.
| |
Name |
Gets or sets the name of this instance.
| |
NumberOfColumns |
Gets the number of columns of this instance.
| |
NumberOfRows |
Gets the number of rows of this instance.
| |
RowNames |
Exposes the dictionary of row names, keyed by row indexes.
| |
StorageOrder |
Gets the storage order of this instance.
| |
StorageScheme |
Gets the storage scheme of this instance.
| |
UpperBandwidth |
Gets the upper bandwidth of this instance.
|
Name | Description | |
---|---|---|
Add(Complex, ComplexMatrix) |
Determines the addition of a scalar to a matrix.
| |
Add(ComplexMatrix, ComplexMatrix) |
Determines the sum of two matrices.
| |
Add(ComplexMatrix, DoubleMatrix) |
Determines the sum of two matrices.
| |
Add(ComplexMatrix, ReadOnlyDoubleMatrix) |
Determines the sum of two matrices.
| |
Add(ComplexMatrix, Complex) |
Determines the addition of a matrix to a scalar.
| |
Add(DoubleMatrix, ComplexMatrix) |
Determines the sum of two matrices.
| |
Add(ReadOnlyDoubleMatrix, ComplexMatrix) |
Determines the sum of two matrices.
| |
Apply |
Evaluates the specified function at each entry of this instance,
and returns a matrix whose entries are given by
the corresponding function values.
| |
AsColumnMajorDenseArray |
Returns a column major ordered, dense representation of this instance.
| |
AsReadOnly |
Returns a read-only representation of the ComplexMatrix.
| |
AsRowCollection |
Returns the collection of rows in the ComplexMatrix.
| |
AsRowCollection(IndexCollection) |
Returns the collection of the rows in the ComplexMatrix
corresponding to the specified indexes.
| |
Conjugate |
Returns the conjugate of this instance.
| |
ConjugateTranspose |
Returns the conjugate transpose of this instance.
| |
Contains | Determines whether the ICollectionT contains a specific value. | |
CopyTo | ||
Dense(Complex) |
Creates a dense ComplexMatrix instance having the same
size and data of the specified two-dimensional array.
| |
Dense(Int32, Int32) |
Creates a dense ComplexMatrix instance having the
specified size, and assigns zero to each matrix entry.
| |
Dense(Int32, Int32, IEnumerableComplex) |
Creates a dense ComplexMatrix instance having the
specified size, and assigns data to entries
assuming ColMajor ordering.
| |
Dense(Int32, Int32, Complex) |
Creates a dense ComplexMatrix instance having the
specified size, and assigns the same value to each matrix entry.
| |
Dense(Int32, Int32, Complex) |
Creates a dense ComplexMatrix instance having the
specified size, and assigns data to entries
assuming ColMajor ordering.
| |
Dense(Int32, Int32, IEnumerableComplex, StorageOrder) |
Creates a dense ComplexMatrix instance having the
specified size, and assigns data to entries
applying the given storage order.
| |
Dense(Int32, Int32, Complex, StorageOrder) |
Creates a dense ComplexMatrix instance having the
specified size, and assigns data to entries
applying the given storage order.
| |
Dense(Int32, Int32, Complex, Boolean) |
Creates a dense ComplexMatrix instance having the
specified size, and assigns data to entries,
possibly preventing copying operations before creation.
| |
Diagonal(ComplexMatrix) |
Creates a square ComplexMatrix instance having the specified
data on its main diagonal and zero otherwise.
| |
Diagonal(ReadOnlyComplexMatrix) |
Creates a square ComplexMatrix instance having the specified
data on its main diagonal and zero otherwise.
| |
Dispose |
Disposes this instance.
| |
Dispose(Boolean) |
Releases unmanaged and - optionally - managed resources.
| |
Divide(Complex, ComplexMatrix) |
Determines the division of a scalar by a matrix.
| |
Divide(ComplexMatrix, ComplexMatrix) |
Determines the division of a matrix by another.
| |
Divide(ComplexMatrix, DoubleMatrix) |
Determines the division of a matrix by another.
| |
Divide(ComplexMatrix, ReadOnlyDoubleMatrix) |
Determines the division of a matrix by another.
| |
Divide(ComplexMatrix, Complex) |
Determines the division of a matrix by a scalar.
| |
Divide(DoubleMatrix, ComplexMatrix) |
Determines the division of a matrix by another.
| |
Divide(ReadOnlyDoubleMatrix, ComplexMatrix) |
Determines the division of a matrix by another.
| |
ElementWiseMultiply(ComplexMatrix, ComplexMatrix) |
Determines the element wise product of two matrices.
| |
ElementWiseMultiply(ComplexMatrix, DoubleMatrix) |
Determines the element wise product of two matrices.
| |
ElementWiseMultiply(ComplexMatrix, ReadOnlyDoubleMatrix) |
Determines the element wise product of two matrices.
| |
ElementWiseMultiply(DoubleMatrix, ComplexMatrix) |
Determines the element wise product of two matrices.
| |
ElementWiseMultiply(ReadOnlyDoubleMatrix, ComplexMatrix) |
Determines the element wise product of two matrices.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize |
Finalizes an instance of the ComplexMatrix class.
(Overrides ObjectFinalize.) | |
Find |
Searches for entries in this instance that equal the specified value,
and returns their zero-based linear indexes.
| |
FindNonzero |
Searches for nonzero entries in this instance,
and returns their zero-based linear indexes.
| |
FindWhile |
Searches for entries in this instance that matches the conditions defined by the specified predicate,
and returns their zero-based linear indexes.
| |
FromComplex |
Converts
from Complex to ComplexMatrix.
| |
FromReadOnlyComplexMatrix |
Converts
from ReadOnlyComplexMatrix to ComplexMatrix.
| |
GetEnumerator |
Returns an enumerator that iterates through the collection.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetStorage |
Gets the elements currently stored in this instance.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Identity |
Creates a ComplexMatrix instance
representing the identity matrix having the specified dimension.
| |
IndexOf | Determines the index of a specific item in the IListT. | |
InPlaceApply |
Evaluates the specified function at each entry of this instance,
and substitutes each entry with its corresponding function value.
| |
InPlaceConjugate |
Transforms the entries of this instance in their complex conjugates.
| |
InPlaceConjugateTranspose |
Conjugate transposes this instance.
| |
InPlaceTranspose |
Transposes this instance.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Multiply(Complex, ComplexMatrix) |
Determines the multiplication of a scalar by a matrix.
| |
Multiply(ComplexMatrix, ComplexMatrix) |
Determines the product of two matrices.
| |
Multiply(ComplexMatrix, DoubleMatrix) |
Determines the product of two matrices.
| |
Multiply(ComplexMatrix, ReadOnlyDoubleMatrix) |
Determines the product of two matrices.
| |
Multiply(ComplexMatrix, Complex) |
Determines the multiplication of a matrix by a scalar.
| |
Multiply(DoubleMatrix, ComplexMatrix) |
Determines the product of two matrices.
| |
Multiply(ReadOnlyDoubleMatrix, ComplexMatrix) |
Determines the product of two matrices.
| |
Negate |
Determines the negation of a matrix.
| |
RemoveAllColumnNames |
Removes all column names.
| |
RemoveAllRowNames |
Removes all row names.
| |
RemoveColumnName |
Removes the name of the specified column.
| |
RemoveRowName |
Removes the name of the specified row.
| |
SetColumnName |
Sets the name of the specified column.
| |
SetRowName |
Sets the name of the specified row.
| |
Sparse |
Creates a sparse ComplexMatrix instance having the specified
size and initial capacity to store entries different from zero.
| |
Subtract(Complex, ComplexMatrix) |
Determines the subtraction of a matrix from a scalar.
| |
Subtract(ComplexMatrix, ComplexMatrix) |
Determines the difference between two matrices.
| |
Subtract(ComplexMatrix, DoubleMatrix) |
Determines the difference between two matrices.
| |
Subtract(ComplexMatrix, ReadOnlyDoubleMatrix) |
Determines the difference between two matrices.
| |
Subtract(ComplexMatrix, Complex) |
Determines the subtraction of a scalar from a matrix.
| |
Subtract(DoubleMatrix, ComplexMatrix) |
Determines the difference between two matrices.
| |
Subtract(ReadOnlyDoubleMatrix, ComplexMatrix) |
Determines the difference between two matrices.
| |
ToComplex |
Converts
from ComplexMatrix to Complex.
| |
ToString |
Returns a String that represents this instance.
(Overrides ObjectToString.) | |
Transpose |
Returns the transpose of this instance.
| |
TryGetColumnName |
Tries to get the name of the specified column.
| |
TryGetRowName |
Tries to get the name of the specified row.
| |
Vec |
Returns the vectorization of this instance.
| |
Vec(IndexCollection) |
Returns a column vector obtained by stacking the specified elements of this instance.
|
Name | Description | |
---|---|---|
Addition(Complex, ComplexMatrix) |
Determines the addition of a scalar to a matrix.
| |
Addition(ComplexMatrix, ComplexMatrix) |
Determines the sum of two matrices.
| |
Addition(ComplexMatrix, DoubleMatrix) |
Determines the sum of two matrices.
| |
Addition(ComplexMatrix, ReadOnlyDoubleMatrix) |
Determines the sum of two matrices.
| |
Addition(ComplexMatrix, Complex) |
Determines the addition of a matrix to a scalar.
| |
Addition(DoubleMatrix, ComplexMatrix) |
Determines the sum of two matrices.
| |
Addition(ReadOnlyDoubleMatrix, ComplexMatrix) |
Determines the sum of two matrices.
| |
Division(Complex, ComplexMatrix) |
Determines the division of a scalar by a matrix.
| |
Division(ComplexMatrix, ComplexMatrix) |
Determines the division of a matrix by another.
| |
Division(ComplexMatrix, DoubleMatrix) |
Determines the division of a matrix by another.
| |
Division(ComplexMatrix, ReadOnlyDoubleMatrix) |
Determines the division of a matrix by another.
| |
Division(ComplexMatrix, Complex) |
Determines the division of a matrix by a scalar.
| |
Division(DoubleMatrix, ComplexMatrix) |
Determines the division of a matrix by another.
| |
Division(ReadOnlyDoubleMatrix, ComplexMatrix) |
Determines the division of a matrix by another.
| |
(Complex to ComplexMatrix) |
Performs an explicit conversion
from Complex to ComplexMatrix.
| |
(ComplexMatrix to Complex) |
Performs an explicit conversion
from ComplexMatrix to Complex.
| |
(ReadOnlyComplexMatrix to ComplexMatrix) |
Performs an explicit conversion
from ReadOnlyComplexMatrix to ComplexMatrix.
| |
Multiply(Complex, ComplexMatrix) |
Determines the multiplication of a scalar by a matrix.
| |
Multiply(ComplexMatrix, ComplexMatrix) |
Determines the product of two matrices.
| |
Multiply(ComplexMatrix, DoubleMatrix) |
Determines the product of two matrices.
| |
Multiply(ComplexMatrix, ReadOnlyDoubleMatrix) |
Determines the product of two matrices.
| |
Multiply(ComplexMatrix, Complex) |
Determines the multiplication of a matrix by a scalar.
| |
Multiply(DoubleMatrix, ComplexMatrix) |
Determines the product of two matrices.
| |
Multiply(ReadOnlyDoubleMatrix, ComplexMatrix) |
Determines the product of two matrices.
| |
Subtraction(Complex, ComplexMatrix) |
Determines the subtraction of a matrix from a scalar.
| |
Subtraction(ComplexMatrix, ComplexMatrix) |
Determines the difference between two matrices.
| |
Subtraction(ComplexMatrix, DoubleMatrix) |
Determines the difference between two matrices.
| |
Subtraction(ComplexMatrix, ReadOnlyDoubleMatrix) |
Determines the difference between two matrices.
| |
Subtraction(ComplexMatrix, Complex) |
Determines the subtraction of a scalar from a matrix.
| |
Subtraction(DoubleMatrix, ComplexMatrix) |
Determines the difference between two matrices.
| |
Subtraction(ReadOnlyDoubleMatrix, ComplexMatrix) |
Determines the difference between two matrices.
| |
UnaryNegation |
Determines the negation of a matrix.
|
Name | Description | |
---|---|---|
ICollectionComplexAdd |
Adds an item to the ICollectionT.
This implementation always throws a NotSupportedException.
| |
ICollectionComplexClear |
Removes all items from the ICollectionT.
This implementation always throws a NotSupportedException.
| |
ICollectionComplexRemove |
Removes the first occurrence of a specific object from
the ICollectionT.
This implementation always throws a NotSupportedException.
| |
IEnumerableGetEnumerator | Returns an enumerator that iterates through a collection. | |
IListComplexInsert |
Inserts an item to the IListT at the specified index.
This implementation always throws a NotSupportedException.
| |
IListComplexRemoveAt |
Removes the IListT item
at the specified index.
This implementation always throws a NotSupportedException.
|
Instantiation
ComplexMatrix objects can be created using different storage schemes. To allocate storage for each matrix entry, so applying a Dense scheme, one can exploit one of the overloaded factory method Dense, such as Dense(Int32, Int32). On the contrary, method Sparse returns instances whose scheme is StorageScheme.CompressedRow, which means that storage is allocated for non-zero entries only, using a compressed sparse row scheme.
Indexing
In a matrix, entries are arranged in rows and columns. Zero-based indexes are assigned to rows and columns, so that each entry can be identified by the indexes of the specific row and column on which it lies.
Let be a matrix, and consider its generic entry
where and
are the
number of rows and columns of , respectively.
Entry can be set or get through the indexer ItemInt32, Int32. Further overloads of the indexer enable the access to sub-matrices, as well.
A linear index completely
identifies an entry,
assuming that entries are linearly ordered following the
ColumnMajor
data order. This means that entry has linear
index equal to , and matrix entries can be enumerated as
follows:
where is the Count of the matrix.
Given a linear index, the corresponding entry can be accessed via the indexer ItemInt32. In order to retrieve entries corresponding to multiple linear indexes simultaneously, linear indexers are also overloaded to accept IndexCollection instances, or strings as arguments.
Dimensions
The dimensions of a matrix can be inspected using the properties NumberOfRows and NumberOfColumns, Use the property Count to know how many entries are arranged in a matrix.
The following table reports some particular dimensions for which a property exists which can be evaluated to inspect if the dimensions hold true for a given matrix.
Matrix Property | Number of rows | Number of columns |
---|---|---|
IsScalar | 1 | 1 |
IsRowVector | 1 | Any |
IsColumnVector | Any | 1 |
In addition, property IsSquare returns true for matrices having the same number of rows and columns. You can also inspect property IsVector to verify if a matrix instance has only one row or column.
Diagonals
There are diagonals in .
The main diagonal of is also said the diagonal of order 0, and is the collection of entries such that .
If , then the matrix has
super-diagonals: for
, the
-th super-diagonal is the collection of entries
corresponding to the positions
If , the matrix has
sub-diagonals: for
, the
-th sub-diagonal is the collection of entries
corresponding to the positions
Bandwidths
The lower bandwidth of is the smallest integer, say , such that if .
The upper bandwidth of a matrix is the smallest integer, say , such that if .
These definitions imply that, if , then the sub-diagonal of order contains all zero entries, and if , then the super-diagonal of order contains all zero entries.
Properties LowerBandwidth and UpperBandwidth can be inspected to access the bandwidths of a given instance.
Patterns
The arrangement of zero entries in a matrix often follows a particular pattern. Some properties are defined which can be tested to verify if any of these patterns hold for a given matrix.
Relevant patterns can be described by means of lower and upper matrix bandwidths. For instance, an upper triangular matrix can be defined as a square matrix having sub-diagonals whose entries are all zero, or, equivalently, as a square matrix having a lower bandwidth equal to 0.
The following table reports some bandwidth-dependent patterns for which a property exists which can be evaluated to inspect if the pattern holds true for a given square matrix.
Matrix Pattern Property | Lower Bandwidth | Upper Bandwidth |
---|---|---|
IsLowerTriangular | Any | 0 |
IsUpperTriangular | 0 | Any |
IsLowerHessenberg | Any | 0 or 1 |
IsUpperHessenberg | 0 or 1 | Any |
IsDiagonal | 0 | 0 |
IsLowerBidiagonal | 0 or 1 | 0 |
IsUpperBidiagonal | 0 | 0 or 1 |
IsTridiagonal | 0 or 1 | 0 or 1 |
Finally, property IsTriangular can be inspected to verify if a matrix instance is lower or upper triangular, IsBidiagonal to verify if the instance is lower or upper bidiagonal, while property IsHessenberg returns a value indicating if a matrix instance is lower or upper Hessenberg.
Enumeration of entries and rows
Matrix values can be enumerated, and queried, using the "Linq to Objects" paradigm (see, e.g., the System.Linq documentation). Matrices can also be enumerated by rows using the iterator AsRowCollection. This means that you can apply the LINQ approach to retrieve data from a matrix: you write declarative code that describes what you want to retrieve and at what conditions, which can be specified to filter, order, and aggregate data as needed.
Memory usage
Matrix entries can be stored using different data schemes, as enumerated in StorageScheme.
The data currently stored can be accessed as an array through the GetStorage method.
Caution |
---|
This method is intended for advanced users and must always be used carefully. For performance reasons, the returned reference points directly to the matrix internal data. Do not call GetStorage if you do not have complete control of the instance you used to invoke the method. |
Method AsColumnMajorDenseArray always returns a ColumnMajor ordered array which is a dense representation of the matrix entries, irrespective of the specific data scheme used to implement the matrix. If the underlying scheme is Dense, such method returns a copy of the matrix data.
Serialization
Matrices can be loaded from, or saved to a CSV file through the CsvComplexMatrixSerializer class.
Matrices can also be represented as JSON strings, see JsonSerialization.