Click or drag to resize

DoubleMatrixFind Method

Searches for entries in this instance that equal the specified value, and returns their zero-based linear indexes.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public IndexCollection Find(
	double value
)

Parameters

value
Type: SystemDouble
The value to search for.

Return Value

Type: IndexCollection
The collection of zero-based linear indexes of the entries that matches the value, if found; otherwise null.
Remarks

Matrix entries are interpreted as well ordered following a column major ordering. The position of an entry in such well ordering is referred to as the linear position of that entry.

Examples

In the following example, the negative entries of a data matrix are found.

C#
using System;

namespace Novacta.Analytics.CodeExamples
{
    public class FindExample0  
    {
        public void Main()
        {
            // Create a matrix.
            var data = new double[6] {
               -1,  2,
                2, -3,
                3,  4,
            };
            var matrix = DoubleMatrix.Dense(3, 2, data, StorageOrder.RowMajor);
            Console.WriteLine("The data matrix:");
            Console.WriteLine(matrix);

            // Set the value to search for.
            double value = 2.0;

            // Find entries equal to value 2.0.
            var indexes = matrix.Find(value);

            Console.WriteLine();
            Console.WriteLine("Linear indexes of entries equal to 2.0 in data:");
            Console.WriteLine(indexes);

            // Find is available for read-only matrices:
            // find entries equal to 2.0 using a read-only wrapper of the data matrix.
            ReadOnlyDoubleMatrix readOnlyMatrix = matrix.AsReadOnly();
            indexes = readOnlyMatrix.Find(value);

            Console.WriteLine();
            Console.WriteLine("Using read-only data. Linear indexes of entries equal to 2.0:");
            Console.WriteLine(indexes);
        }
    }
}

// Executing method Main() produces the following output:
// 
// The data matrix:
// -1               2                
// 2                -3               
// 3                4                
// 
// 
// 
// Linear indexes of entries equal to 2.0 in data:
// 1, 3
// 
// Using read-only data. Linear indexes of entries equal to 2.0:
// 1, 3

See Also