Click or drag to resize

DoubleMatrixRowItem Property (Int32)

Gets or sets the entry of the DoubleMatrixRow having the specified column index.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public double this[
	int columnIndex
] { get; set; }

Parameters

columnIndex
Type: SystemInt32

Property Value

Type: Double
The row entry corresponding to the specified column index.
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptioncolumnIndex is not a valid column index for the matrix from which this row has been collected.
Remarks

A DoubleMatrixRow instance represents a row of a DoubleMatrix. More thoroughly, since each DoubleMatrixRow is an item in a DoubleMatrixRowCollection, such matrix can be inspected by getting the Matrix property of the given collection.

If setting, the ItemInt32 indexer fires the PropertyChanged event notifying that the name of the changed property is "[" + j + ]", where j is a string representation of columnIndex, and the new value becomes the entry of Matrix having row and column indexes given by Index and columnIndex, respectively.

If columnIndex equals any value returned by XDataColumn, YDataColumn, or ZDataColumn, then the PropertyChanged event is also fired to notify that properties XData, YData, or ZData have changed values, respectively.

Examples

In the following example, all rows in a matrix are collected, and the indexer is applied to set specific row entries.

C#
using System;

namespace Novacta.Analytics.CodeExamples
{
    public class RowIndexerExample0  
    {
        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();

            // Set a column index.
            var columnIndex = 1;

            // Set the row entries corresponding to the specified column index:
            // this code updates the data matrix, too.
            foreach (var row in rows) {
                row[columnIndex] = row.Index * 100.0; 
            }

            Console.WriteLine("Updated data matrix:");
            Console.WriteLine(matrix);
            Console.WriteLine();
        }
    }
}

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

See Also