DoubleMatrixInPlaceTranspose Method |
Namespace: Novacta.Analytics
Let be a matrix, and consider its generic entry
where and
are the
number of rows and columns of , respectively.
The transpose of is the matrix
having rows and
columns, whose generic
entry is:
The method transforms this instance in its transpose.
In the following example, a matrix is transposed.
using System; namespace Novacta.Analytics.CodeExamples { public class InPlaceTransposeExample0 { public void Main() { // Create a matrix. var data = new double[20] { 1, 8, -3, 6, -2, 2, 2, 2, 0, 7, -3, 9, 3, 2, 9, 5, 2, -5, -1, -4 }; var matrix = DoubleMatrix.Dense(4, 5, data, StorageOrder.RowMajor); Console.WriteLine("Initial data matrix:"); Console.WriteLine(matrix); // Transpose the matrix. matrix.InPlaceTranspose(); Console.WriteLine(); Console.WriteLine("Transposed data matrix:"); Console.WriteLine(matrix); } } } // Executing method Main() produces the following output: // // Initial data matrix: // 1 8 -3 6 -2 // 2 2 2 0 7 // -3 9 3 2 9 // 5 2 -5 -1 -4 // // // // Transposed data matrix: // 1 2 -3 5 // 8 2 9 2 // -3 2 3 -5 // 6 0 2 -1 // -2 7 9 -4 //