ComplexMatrixDiagonal Method (ComplexMatrix) |
Namespace: Novacta.Analytics
Exception | Condition |
---|---|
ArgumentNullException | mainDiagonal is null. |
Parameter mainDiagonal is a matrix storing the main diagonal data. Both NumberOfRows and NumberOfColumns of the created diagonal matrix will be equal to the Count of mainDiagonal. Note that mainDiagonal can have any size: if it is not a vector, its entries will be inserted in the main diagonal of the created diagonal matrix assuming ColumnMajor ordering.
In the following example, a diagonal matrix is created.
using System; using System.Numerics; namespace Novacta.Analytics.CodeExamples { public class ComplexDiagonalExample0 { public void Main() { // Create the main diagonal data. var data = new Complex[2] { new Complex(1, -1), new Complex(2, -2) }; // Create a matrix storing the main diagonal data. // Note that such matrix can have any size: if it is not // a vector, its entries will be inserted in the main // diagonal of the diagonal matrix assuming ColMajor ordering. var mainDiagonal = ComplexMatrix.Dense( 2, 1, data); Console.WriteLine("The matrix storing main diagonal data:"); Console.WriteLine(mainDiagonal); Console.WriteLine(); // Create the diagonal matrix. var diagonalMatrix = ComplexMatrix.Diagonal( mainDiagonal); Console.WriteLine("The diagonal matrix:"); Console.WriteLine(diagonalMatrix); } } } // Executing method Main() produces the following output: // // The matrix storing main diagonal data: // ( 1, -1) // ( 2, -2) // // // // The diagonal matrix: // ( 1, -1) ( 0, 0) // ( 0, 0) ( 2, -2) //