Click or drag to resize

ComplexMatrixDense Method (Complex)

Creates a dense ComplexMatrix instance having the same size and data of the specified two-dimensional array.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static ComplexMatrix Dense(
	Complex[,] data
)

Parameters

data
Type: System.NumericsComplex
The two-dimensional array containing matrix data.

Return Value

Type: ComplexMatrix
The matrix having the specified size and data.
Exceptions
ExceptionCondition
ArgumentNullExceptiondata is null.
ArgumentExceptiondata has at least a dimension along which the number of elements is zero.
Remarks

ComplexMatrix dense instances allocate storage for each matrix entry. Sparse ComplexMatrix instances can be created by calling method Sparse(Int32, Int32, Int32).

Examples

In the following example, some dense matrices are created from two-dimensional arrays.

Creation of dense matrices from two-dimensional arrays
using System;
using System.Numerics;

namespace Novacta.Analytics.CodeExamples
{
    public class ComplexDenseExample6  
    {
        public void Main()
        {
            // Set matrix dimensions.
            const int numberOfRows = 3;
            const int numberOfColumns = 2;

            // Create the data as an array having lower bounds equal to zero.
            var data = new Complex[numberOfRows, numberOfColumns]
                { { new Complex(1, -1), new Complex(2, -2) },
                  { new Complex(3, -3), new Complex(4, -4) },
                  { new Complex(5, -5), new Complex(6, -6) } };

            // Create the matrix. 
            var matrix = ComplexMatrix.Dense(data);
            Console.WriteLine("Creating from an array having zero lower bounds.");
            Console.WriteLine("The data matrix:");
            Console.WriteLine(matrix);

            Console.WriteLine();

            // Create the data as an array having non-zero lower bounds.
            int[] lowerBounds = { 2005, 1 };
            int[] lengths = { numberOfRows, numberOfColumns };
            data = (Complex[,])Array.CreateInstance(typeof(Complex),
                    lengths, lowerBounds);

            data[2005, 1] = new Complex(1, -1); 
            data[2006, 1] = new Complex(3, -3); 
            data[2007, 1] = new Complex(5, -5);

            data[2005, 2] = new Complex(2, -2);
            data[2006, 2] = new Complex(4, -4);
            data[2007, 2] = new Complex(6, -6);

            // Create the matrix. 
            matrix = ComplexMatrix.Dense(data);
            Console.WriteLine("Creating from an array having non-zero lower bounds.");
            Console.WriteLine("The data matrix:");
            Console.WriteLine(matrix);
        }
    }
}

// Executing method Main() produces the following output:
// 
// Creating from an array having zero lower bounds.
// The data matrix:
// (                1,               -1) (                2,               -2) 
// (                3,               -3) (                4,               -4) 
// (                5,               -5) (                6,               -6) 
// 
// 
// 
// Creating from an array having non-zero lower bounds.
// The data matrix:
// (                1,               -1) (                2,               -2) 
// (                3,               -3) (                4,               -4) 
// (                5,               -5) (                6,               -6) 
// 

See Also