Click or drag to resize

DoubleMatrixDense Method (Int32, Int32, Double)

Creates a dense DoubleMatrix 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 DoubleMatrix Dense(
	int numberOfRows,
	int numberOfColumns,
	double[] data
)

Parameters

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

Return Value

Type: DoubleMatrix
The matrix having the specified size and data.
Exceptions
ExceptionCondition
ArgumentNullExceptiondata is null.
ArgumentOutOfRangeExceptionnumberOfRows is not positive.
-or-
numberOfColumns is not positive.
ArgumentExceptiondata has Length not equal to the multiplication of numberOfRows by numberOfColumns.
Remarks

DoubleMatrix dense instances allocate storage for each matrix entry. Sparse DoubleMatrix 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;

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

            // Create the data.
            var data = new double[6] {
               1,  2,  3,  4,  5,  6
            };

            // Create the matrix. Data are assumed as ColMajor ordered.
            var matrix = DoubleMatrix.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                4                
// 2                5                
// 3                6                
// 

See Also