Click or drag to resize

ComplexMatrixDense Method (Int32, Int32, IEnumerableComplex)

Creates a dense ComplexMatrix instance having the specified size, and assigns data to entries assuming ColMajor ordering.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static ComplexMatrix Dense(
	int numberOfRows,
	int numberOfColumns,
	IEnumerable<Complex> data
)

Parameters

numberOfRows
Type: SystemInt32
The number of matrix rows.
numberOfColumns
Type: SystemInt32
The number of matrix columns.
data
Type: System.Collections.GenericIEnumerableComplex
The data assigned to matrix entries.

Return Value

Type: ComplexMatrix
The matrix having the specified size and data.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionnumberOfRows is not positive.
-or-
numberOfColumns is not positive.
ArgumentNullExceptiondata is null.
ArgumentException The number of items in data is not equal to the multiplication of numberOfRows by numberOfColumns.
Remarks

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

Parameter data is unidimensional, while matrix entries are bi-dimensional, since are defined by their row and column indexes. As a consequence, entries must be linearly ordered to define a correspondence between data and matrix entries. This method assumes that the order is by columns: matrix entries are ordered by their column index first, and entries laying on a given column are in turn ordered by their row index. This implies that the first numberOfRows entries in data will be assumed to contain the first column of the returned matrix, and so on.

Examples

In the following example, a dense matrix is created by passing data assumed to be ColMajor ordered.

Creation of a dense matrix with ColMajor ordered data
using System;
using System.Collections.Generic;
using System.Numerics;

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

            // Create the data.
            var data = new List<Complex>(6) {
                new Complex(1, -1),
                new Complex(2, -2),
                new Complex(3, -3),
                new Complex(4, -4),
                new Complex(5, -5),
                new Complex(6, -6)
            } as IEnumerable<Complex>;

            // Create the matrix. Data are assumed as ColMajor ordered.
            var matrix = ComplexMatrix.Dense(
                numberOfRows, numberOfColumns, data);
            Console.WriteLine("Assuming ColMajor ordered data.");
            Console.WriteLine("The data matrix:");
            Console.WriteLine(matrix);
        }
    }
}

// Executing method Main() produces the following output:
// 
// Assuming ColMajor ordered data.
// The data matrix:
// (                1,               -1) (                4,               -4) 
// (                2,               -2) (                5,               -5) 
// (                3,               -3) (                6,               -6) 
// 

See Also