Click or drag to resize

StatMin Method (DoubleMatrix)

Returns the minimum value and the linear index of its first occurrence in the specified data.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static IndexValuePair Min(
	DoubleMatrix data
)

Parameters

data
Type: Novacta.AnalyticsDoubleMatrix
The data to search for a minimum.

Return Value

Type: IndexValuePair
The pair given by the minimum data value and its first linear index.
Exceptions
ExceptionCondition
ArgumentNullExceptiondata is null.
Remarks
The method returns an IndexValuePair structure which exposes the minimum data value through property Value, while the corresponding first linear position can be inspected by getting property Index.
Note Note
In the Novacta.Analytics assembly, positions of matrix entries are interpreted as linearly ordered following a column major ordering.
Examples

In the following example, the smallest entry of the specified data is computed.

C#
using System;

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

            // Return the smallest entry of the specified data. 
            var dataMin = Stat.Min(matrix);

            Console.WriteLine();
            Console.WriteLine("Data minimum is {0} on linear position {1}",
                dataMin.Value, dataMin.Index);

            // Min is overloaded to accept data as a read-only matrix:
            // return the smallest entry using a read-only wrapper of 
            // the data matrix.
            ReadOnlyDoubleMatrix readOnlyMatrix = matrix.AsReadOnly();
            var readOnlyDataMin = Stat.Min(readOnlyMatrix);

            Console.WriteLine();
            Console.WriteLine("Using read-only data. Minimum is {0} on linear position {1}",
                readOnlyDataMin.Value, readOnlyDataMin.Index);
        }
    }
}

// Executing method Main() produces the following output:
// 
// The data matrix:
// -1               -2               
// 2                3                
// 3                -4               
// 
// 
// 
// Data minimum is -4 on linear position 5
// 
// Using read-only data. Minimum is -4 on linear position 5

See Also