DoubleMatrixRowIndex Property |
Namespace: Novacta.Analytics
Exception | Condition |
---|---|
ArgumentOutOfRangeException | value is less than zero. -or- value is greater than or equal to the NumberOfRows of the matrix of which this instance represents a row. |
In a matrix, entries are arranged in rows and columns. Zero-based indexes are assigned to rows and columns, so that each entry can be identified by the indexes of the specific row and column on which it lies.
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.
Property Index is the zero-based index assigned to the row in that matrix.
In the following example, the Index of a DoubleMatrixRow is modified, and its XData property is evaluated before and after that change.
using System; namespace Novacta.Analytics.CodeExamples { public class RowIndexDataExample0 { 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 the column corresponding to property XData. rows.XDataColumn = 2; // Get the a row in the collection var firstRow = rows[1]; // Get the XData value of the row. Console.WriteLine("XData for Row {0}: {1}", firstRow.Index, firstRow.XData); Console.WriteLine(); // Change the index of the row. firstRow.Index = 3; // Here the row represents the matrix row having index 3. // Get the XData value of the first row. Console.WriteLine("XData for Row {0}: {1}", firstRow.Index, firstRow.XData); Console.WriteLine(); } } } // Executing method Main() produces the following output: // // Data matrix: // 1 5 9 // 2 6 10 // 3 7 11 // 4 8 12 // // // // XData for Row 1: 10 // // XData for Row 3: 12