public static DoubleMatrix Diagonal(
DoubleMatrix mainDiagonal
)
Public Shared Function Diagonal (
mainDiagonal As DoubleMatrix
) As DoubleMatrix
public:
static DoubleMatrix^ Diagonal(
DoubleMatrix^ mainDiagonal
)
static member Diagonal :
mainDiagonal : DoubleMatrix -> DoubleMatrix
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;
namespace Novacta.Analytics.CodeExamples
{
public class DiagonalExample0
{
public void Main()
{
// Create the main diagonal data.
var data = new double[6] {
1, 2, 3, 4, 5, 6
};
// 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 = DoubleMatrix.Dense(
2, 3, data);
Console.WriteLine("The matrix storing main diagonal data:");
Console.WriteLine(mainDiagonal);
Console.WriteLine();
// Create the diagonal matrix.
var diagonalMatrix = DoubleMatrix.Diagonal(
mainDiagonal);
Console.WriteLine("The diagonal matrix:");
Console.WriteLine(diagonalMatrix);
}
}
}
// Executing method Main() produces the following output:
//
// The matrix storing main diagonal data:
// 1 3 5
// 2 4 6
//
//
//
// The diagonal matrix:
// 1 0 0 0 0 0
// 0 2 0 0 0 0
// 0 0 3 0 0 0
// 0 0 0 4 0 0
// 0 0 0 0 5 0
// 0 0 0 0 0 6
//
//
ArgumentNullException | mainDiagonal is null. |