public static ComplexMatrix Diagonal(
ReadOnlyComplexMatrix mainDiagonal
)
Public Shared Function Diagonal (
mainDiagonal As ReadOnlyComplexMatrix
) As ComplexMatrix
public:
static ComplexMatrix^ Diagonal(
ReadOnlyComplexMatrix^ mainDiagonal
)
static member Diagonal :
mainDiagonal : ReadOnlyComplexMatrix -> ComplexMatrix
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(1, -1),
new(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)
//
//
ArgumentNullException | mainDiagonal is null. |