Click or drag to resize

DoubleMatrixAsRowCollection Method

Returns the collection of rows in the DoubleMatrix.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public DoubleMatrixRowCollection AsRowCollection()

Return Value

Type: DoubleMatrixRowCollection
The collection of rows in this instance.
Examples

In the following example, the rows of a matrix are enumerated.

C#
using System;

namespace Novacta.Analytics.CodeExamples
{
    public class RowsEnumeratorExample0  
    {
        public void Main()
        {
            // Create a matrix.
            var data = new double[12] {
                1, 5,  9,
                2, 6, 10,
                3, 7, 11,
                4, 8, 12
            };
            var matrix = DoubleMatrix.Dense(4, 3, data, StorageOrder.RowMajor);
            Console.WriteLine("Data matrix:");
            Console.WriteLine(matrix);
            Console.WriteLine();

            // Get the collection of matrix rows.
            var rows = matrix.AsRowCollection();

            // Enumerate matrix rows.
            foreach (var row in rows) {
                Console.WriteLine("Row {0}: ", row.Index);
                Console.WriteLine(row);
            }
        }
    }
}

// Executing method Main() produces the following output:
// 
// Data matrix:
// 1                5                9                
// 2                6                10               
// 3                7                11               
// 4                8                12               
// 
// 
// 
// Row 0: 
// 1                5                9                
// Row 1: 
// 2                6                10               
// Row 2: 
// 3                7                11               
// Row 3: 
// 4                8                12

See Also