Click or drag to resize

ComplexMatrixItem Property (IndexCollection, Int32)

Gets or sets the elements 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 ComplexMatrix this[
	IndexCollection rowIndexes,
	int columnIndex
] { get; set; }

Parameters

rowIndexes
Type: Novacta.AnalyticsIndexCollection
The zero-based row indexes of the elements to get or set.
columnIndex
Type: SystemInt32
The zero-based column index of the elements to get or set.

Property Value

Type: ComplexMatrix
A tabular collection formed by the elements corresponding to the specified row and column indexes.

Implements

IReadOnlyTabularCollectionTValue, TCollectionItemIndexCollection, Int32
ITabularCollectionTValue, TCollectionItemIndexCollection, Int32
Exceptions
ExceptionCondition
ArgumentNullExceptionrowIndexes is null.
-or-
value is null.
ArgumentOutOfRangeExceptionrowIndexes contains an index which is greater than or equal to the number of rows of this instance.
-or-
columnIndex is less than zero.
-or-
columnIndex is greater than or equal to the number of columns of this instance.
ArgumentException The number of columns in value is greater than 1.
-or-
The number of rows in value is not equal to the Count of rowIndexes.
Remarks

When setting elements simultaneously, the value must be a tabular collection having a number of rows equal to the number of specified row indexes, and a number of columns equal to the number of specified column indexes.

Examples

In the following example, some matrix elements are simultaneously accessed.

C#
using System;
using System.Numerics;

namespace Novacta.Analytics.CodeExamples
{
    public class ComplexMatrixIndexerExample10  
    {
        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 some row indexes.
            var rowIndexes = IndexCollection.Range(1, 3);
            Console.WriteLine();
            Console.WriteLine("Row indexes: {0}", rowIndexes);

            // Specify a column index.
            int columnIndex = 0;
            Console.WriteLine();
            Console.WriteLine("Column index: {0}", columnIndex);

            // Specify the value matrix.
            var valueData = new Complex[3] {
                new Complex(20, -20),
                new Complex(30, -30),
                new Complex(40, -40)
            };
            var value = ComplexMatrix.Dense(3, 1, valueData, StorageOrder.RowMajor);
            Console.WriteLine();
            Console.WriteLine("Value matrix:");
            Console.WriteLine(value);

            // Set the entries having the specified indexes to the value matrix.
            matrix[rowIndexes, columnIndex] = value;

            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 entries:");
            Console.WriteLine(readOnlyMatrix[rowIndexes, 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 indexes: 1, 2, 3
// 
// Column index: 0
// 
// Value matrix:
// (               20,              -20) 
// (               30,              -30) 
// (               40,              -40) 
// 
// 
// 
// Updated data matrix:
// (                1,               -1) (                5,               -5) 
// (               20,              -20) (                6,               -6) 
// (               30,              -30) (                7,               -7) 
// (               40,              -40) (                8,               -8) 
// 
// 
// 
// Updated matrix entries:
// (               20,              -20) 
// (               30,              -30) 
// (               40,              -40) 
// 

See Also