Click or drag to resize

DoubleMatrixRow Class

Represents a row in a matrix of doubles.
Inheritance Hierarchy
SystemObject
  Novacta.AnalyticsDoubleMatrixRow

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public sealed class DoubleMatrixRow : IEnumerable<double>, 
	IEnumerable, INotifyPropertyChanged, IEquatable<DoubleMatrixRow>, IComparable<DoubleMatrixRow>, 
	IComparable

The DoubleMatrixRow type exposes the following members.

Properties
  NameDescription
Public propertyCode exampleIndex
Gets or sets the index of the DoubleMatrixRow.
Public propertyCode exampleItemInt32
Gets or sets the entry of the DoubleMatrixRow having the specified column index.
Public propertyItemString
Gets or sets the entry of the DoubleMatrixRow having the specified column index.
Public propertyLength
Gets the length of the DoubleMatrixRow.
Public propertyName
Gets the name of the DoubleMatrixRow.
Public propertyCode exampleXData
Gets or sets the entry of the DoubleMatrixRow having the column index specified by the XDataColumn property of the DoubleMatrixRowCollection of which the row is an item.
Public propertyCode exampleYData
Gets or sets the entry of the DoubleMatrixRow having the column index specified by the YDataColumn property of the DoubleMatrixRowCollection of which the row is an item.
Public propertyCode exampleZData
Gets or sets the entry of the DoubleMatrixRow having the column index specified by the ZDataColumn property of the DoubleMatrixRowCollection of which the row is an item.
Top
Methods
  NameDescription
Public methodCompareTo(DoubleMatrixRow)
Compares the current object with another object of the same type.
Public methodCompareTo(Object)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
Public methodEquals(DoubleMatrixRow)
Indicates whether the current object is equal to another object of the same type.
Public methodEquals(Object)
Determines whether the specified Object is equal to the current Object.
(Overrides ObjectEquals(Object).)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through a collection.
Public methodGetHashCode
Returns a hash code for this instance.
(Overrides ObjectGetHashCode.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStatic memberToDoubleMatrix
Converts from DoubleMatrixRow to DoubleMatrix.
Public methodToString
Returns a String that represents this instance.
(Overrides ObjectToString.)
Top
Events
  NameDescription
Public eventPropertyChanged
Occurs when a property of the DoubleMatrixRow changed.
Top
Operators
  NameDescription
Public operatorStatic memberEquality
Returns a value that indicates whether a DoubleMatrixRow instance is equal to another DoubleMatrixRow instance.
Public operatorStatic memberGreaterThan
Returns a value that indicates whether a DoubleMatrixRow instance is greater than another DoubleMatrixRow instance.
Public operatorStatic memberGreaterThanOrEqual
Returns a value that indicates whether a DoubleMatrixRow instance is greater than or equal to another DoubleMatrixRow instance.
Public operatorStatic member(DoubleMatrixRow to DoubleMatrix)
Performs an implicit conversion from DoubleMatrixRow to DoubleMatrix.
Public operatorStatic memberInequality
Returns a value that indicates whether a DoubleMatrixRow instance is not equal to another DoubleMatrixRow instance.
Public operatorStatic memberLessThan
Returns a value that indicates whether a DoubleMatrixRow instance is less than another DoubleMatrixRow instance.
Public operatorStatic memberLessThanOrEqual
Returns a value that indicates whether a DoubleMatrixRow instance is less than or equal to another DoubleMatrixRow instance.
Top
Explicit Interface Implementations
Remarks

Instantiation

You cannot directly instantiate a DoubleMatrixRow. Instead, rows in a DoubleMatrix instance can be collected by calling the overloaded method AsRowCollection. Such methods return a DoubleMatrixRowCollection object, whose items have type DoubleMatrixRow.

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.

Comparison

DoubleMatrixRow instances are quasi-lexicographically ordered. This means that instances are firstly ordered by their Length, and then, within rows having the same length, by lexicographic order.

This also means that when tested for equality, DoubleMatrixRow instances are considered equal if and only if they have the same Length and, for each column index, entries corresponding to such index are equal, too.

Data binding

Entries of a DoubleMatrixRow instance corresponding to a specific column index can be get or set through the indexer ItemInt32. When the indexer sets the entry, the row fires the PropertyChanged event, notifying that the name of the changed property is "Item[]"; as a consequence, subscribers to the event can't know what is the column index of the changed entry. This can be problematic if you want to use DoubleMatrixRow instances as binding sources, for example when binding charts or grids to matrix data.

To overcome such difficulties, the DoubleMatrixRow class defines, among others, the XData property. This property returns a specific entry of the row, that one having as column index the value returned by the XDataColumn property of the DoubleMatrixRowCollection which the row belongs to. In this way, XData can be easily used as a path property when binding to DoubleMatrixRow sources.

If set, the XData property fires the PropertyChanged event, and the new value becomes the entry of Matrix having row and column indexes given by Index and XDataColumn, respectively.

Additional not indexed properties are YData and ZData.

Examples

In the following example, the rows of a matrix are enumerated.

C#
using System;

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

            // Enumerate matrix rows.
            foreach (var row in rows) {
                Console.WriteLine("Row {0}: ", row.Index);
                Console.WriteLine(row);
            }
        }
    }
}

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

In the following example, the first half of the rows in a matrix is collected. Then the Index of the items in the collection is modified so that, after that change, the same items represent the second half of the matrix rows.

C#
using System;

namespace Novacta.Analytics.CodeExamples
{
    public class RowIndexDataExample1  
    {
        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 the first two matrix rows.
            var rows = matrix.AsRowCollection(IndexCollection.Range(0,1));

            // Enumerate the specified matrix rows.
            foreach (var row in rows) {
                Console.WriteLine("Row {0}: ", row.Index);
                Console.WriteLine(row);
            }

            // Change the indexes of the rows in the collection,
            // so that they represent the last two matrix rows.
            rows[0].Index = 2;
            rows[1].Index = 3;

            // Enumerate the specified matrix rows.
            Console.WriteLine();
            foreach (var row in rows) {
                Console.WriteLine("Row {0}: ", row.Index);
                Console.WriteLine(row);
            }

        }
    }
}

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

See Also