ComplexMatrixVec Method |
Namespace: Novacta.Analytics
Let be a matrix, and consider its generic entry
where and
are the
number of rows and columns of , respectively.
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.
This method, when called on a ComplexMatrix instance
representing matrix , returns a new
ComplexMatrix instance that
represents a column vector, say ,
such that:
In the following example, a matrix is vectorized.
using System; using System.Numerics; namespace Novacta.Analytics.CodeExamples { public class ComplexVecExample0 { public void Main() { // Create a matrix. var data = new Complex[8] { new Complex(1, -1), new Complex(5, -5), new Complex(2, -2), new Complex(6, -6), new Complex(3, -3), new Complex(7, -7), new Complex(4, -4), new Complex(8, -8) }; var matrix = ComplexMatrix.Dense(4, 2, data, StorageOrder.RowMajor); Console.WriteLine("Initial data matrix:"); Console.WriteLine(matrix); // Get the vectorization of the data matrix. var vectorized = matrix.Vec(); Console.WriteLine(); Console.WriteLine("Vectorized data matrix:"); Console.WriteLine(vectorized); // Entries can also be vectorized using a read-only wrapper of the matrix. ReadOnlyComplexMatrix readOnlyMatrix = matrix.AsReadOnly(); Console.WriteLine(); Console.WriteLine("Vectorized read-only data matrix :"); Console.WriteLine(readOnlyMatrix.Vec()); } } } // Executing method Main() produces the following output: // // Initial data matrix: // ( 1, -1) ( 5, -5) // ( 2, -2) ( 6, -6) // ( 3, -3) ( 7, -7) // ( 4, -4) ( 8, -8) // // // // Vectorized data matrix: // ( 1, -1) // ( 2, -2) // ( 3, -3) // ( 4, -4) // ( 5, -5) // ( 6, -6) // ( 7, -7) // ( 8, -8) // // // // Vectorized read-only data matrix : // ( 1, -1) // ( 2, -2) // ( 3, -3) // ( 4, -4) // ( 5, -5) // ( 6, -6) // ( 7, -7) // ( 8, -8) //