Click or drag to resize

ComplexMatrixItem Property (Int32, Int32)

Gets or sets the element of this instance corresponding to the specified row and column indexes.

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

Parameters

rowIndex
Type: SystemInt32
The zero-based row index of the element to get or set.
columnIndex
Type: SystemInt32
The zero-based column index of the element to get or set.

Property Value

Type: Complex
The element corresponding to the specified row and column indexes.

Implements

IReadOnlyTabularCollectionTValue, TCollectionItemInt32, Int32
ITabularCollectionTValue, TCollectionItemInt32, Int32
Exceptions
ExceptionCondition
ArgumentOutOfRangeExceptionrowIndex 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.
Examples

In the following example, a matrix element is accessed using its row and column indexes.

C#
using System;
using System.Numerics;

namespace Novacta.Analytics.CodeExamples
{
    public class ComplexMatrixIndexerExample00  
    {
        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("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 = 0;
            Console.WriteLine();
            Console.WriteLine("Column index: {0}", columnIndex);

            // Set the corresponding entry.
            matrix[rowIndex, columnIndex] = new Complex(20, -20);

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

            // Entries can also be accessed using a read-only wrapper of the matrix.
            ReadOnlyComplexMatrix 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:
// (                1,               -1) (                5,               -5) 
// (                2,               -2) (                6,               -6) 
// (                3,               -3) (                7,               -7) 
// (                4,               -4) (                8,               -8) 
// 
// 
// 
// Row index: 1
// 
// Column index: 0
// 
// Updated data matrix:
// (                1,               -1) (                5,               -5) 
// (               20,              -20) (                6,               -6) 
// (                3,               -3) (                7,               -7) 
// (                4,               -4) (                8,               -8) 
// 
// 
// 
// Updated matrix entry:
// (20, -20)

See Also