Click or drag to resize

IndexPartitionCreate Method (DoubleMatrixRowCollection)

Creates a partition of positions in a collection of DoubleMatrixRow elements by aggregating those positions occupied by a same element.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static IndexPartition<DoubleMatrixRow> Create(
	DoubleMatrixRowCollection elements
)

Parameters

elements
Type: Novacta.AnalyticsDoubleMatrixRowCollection
The collection of rows whose positions are to be partitioned.

Return Value

Type: IndexPartitionDoubleMatrixRow
The partition of row indexes in the specified collection.
Exceptions
ExceptionCondition
ArgumentNullExceptionelements is null.
Examples

In the following example, the row indexes of a matrix are partitioned by the contents of its rows. Each part is identified by a distinct row, the part identifier, and contains the indexes of the rows which are equal to the identifier.

Partitioning the rows of a matrix by their contents
using System;

namespace Novacta.Analytics.CodeExamples
{
    public class IndexPartitionExample1  
    {
        public void Main()
        {
            // Create a matrix.
            var data = new double[18] {
                0,0,1,
                0,0,1,
                0,1,0,
                0,1,0,
                1,0,0,
                1,0,0
            };
            var matrix = DoubleMatrix.Dense(6, 3, data, StorageOrder.RowMajor);

            // Partition the matrix row indexes by the contents of each row:
            // a part is created for each distinct row.
            var partition = IndexPartition.Create(matrix.AsRowCollection());

            // Each part is identified by its corresponding row and contains
            // the indexes of the rows which are equal to the identifier.
            Console.WriteLine();
            foreach (var identifier in partition.Identifiers) {
                Console.WriteLine("Part identifier: {0}", identifier);
                Console.WriteLine("     indexes: {0}", partition[identifier]);
                Console.WriteLine();
            }
        }
    }
}

// Executing method Main() produces the following output:
// 
// 
// Part identifier: 0                0                1                
//      indexes: 0, 1
// 
// Part identifier: 0                1                0                
//      indexes: 2, 3
// 
// Part identifier: 1                0                0                
//      indexes: 4, 5

See Also