public double this[
int rowIndex,
int columnIndex
] { get; set; }
Public Default Property Item (
rowIndex As Integer,
columnIndex As Integer
) As Double
Get
Set
public:
virtual property double default[int rowIndex, int columnIndex] {
double get (int rowIndex, int columnIndex) sealed;
void set (int rowIndex, int columnIndex, double value) sealed;
}
abstract Item : float with get, set
override Item : float with get, set
In the following example, a matrix element is accessed using its row and column indexes.
using System;
namespace Novacta.Analytics.CodeExamples
{
public class MatrixIndexerExample00
{
public void Main()
{
// Create a matrix.
var data = new double[6] {
10, 20, 30,
40, 50, 60
};
var matrix = DoubleMatrix.Dense(2, 3, data, StorageOrder.RowMajor);
Console.WriteLine("Initial data matrix:");
Console.WriteLine(matrix);
// Specify a row index.
int rowIndex = 1;
Console.WriteLine();
Console.WriteLine("Row index: {0}", rowIndex);
// Specify a column index.
int columnIndex = 2;
Console.WriteLine();
Console.WriteLine("Column index: {0}", columnIndex);
// Set the corresponding entry.
matrix[rowIndex, columnIndex] = -60.0;
Console.WriteLine();
Console.WriteLine("Updated data matrix:");
Console.WriteLine(matrix);
// Entries can also be accessed using a read-only wrapper of the matrix.
ReadOnlyDoubleMatrix readOnlyMatrix = matrix.AsReadOnly();
Console.WriteLine();
Console.WriteLine("Updated matrix entry:");
Console.WriteLine(readOnlyMatrix[rowIndex, columnIndex]);
}
}
}
// Executing method Main() produces the following output:
//
// Initial data matrix:
// 10 20 30
// 40 50 60
//
//
//
// Row index: 1
//
// Column index: 2
//
// Updated data matrix:
// 10 20 30
// 40 50 -60
//
//
//
// Updated matrix entry:
// -60
ArgumentOutOfRangeException | rowIndex is less than zero. -or- rowIndex is equal to or greater than NumberOfRows. -or- columnIndex is less than zero. -or- columnIndex is equal to or greater than NumberOfColumns. |