Click or drag to resize

ComplexMatrixAsRowCollection Method (IndexCollection)

Returns the collection of the rows in the ComplexMatrix corresponding to the specified indexes.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public ComplexMatrixRowCollection AsRowCollection(
	IndexCollection rowIndexes
)

Parameters

rowIndexes
Type: Novacta.AnalyticsIndexCollection
The indexes of the rows to collect.

Return Value

Type: ComplexMatrixRowCollection
The collection of the specified rows in this instance.
Exceptions
ExceptionCondition
ArgumentNullExceptionrowIndexes is null.
ArgumentOutOfRangeExceptionrowIndexes contains an index which is greater than or equal to the NumberOfRows of this instance.
Examples

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

C#
using System;
using System.Numerics;

namespace Novacta.Analytics.CodeExamples
{
    public class ComplexRowsEnumeratorExample1  
    {
        public void Main()
        {
            // Create a matrix.
            var data = new Complex[8] {
                new Complex(1, -1), new Complex(5, -5),
                new Complex(2, -2), new Complex(6, -6),
                new Complex(3, -3), new Complex(7, -7),
                new Complex(4, -4), new Complex(8, -8)
            };
            var matrix = ComplexMatrix.Dense(4, 2, data, StorageOrder.RowMajor);
            Console.WriteLine("Data matrix:");
            Console.WriteLine(matrix);
            Console.WriteLine();

            // Specify the rows to enumerate.
            var rowIndexes = IndexCollection.FromArray(new int[6] { 0, 0, 1, 2, 3, 2 });

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

            // Enumerate the specified 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,               -1) (                5,               -5) 
// (                2,               -2) (                6,               -6) 
// (                3,               -3) (                7,               -7) 
// (                4,               -4) (                8,               -8) 
// 
// 
// 
// Row 0: 
// (                1,               -1) (                5,               -5) 
// Row 0: 
// (                1,               -1) (                5,               -5) 
// Row 1: 
// (                2,               -2) (                6,               -6) 
// Row 2: 
// (                3,               -3) (                7,               -7) 
// Row 3: 
// (                4,               -4) (                8,               -8) 
// Row 2: 
// (                3,               -3) (                7,               -7)

See Also