Skip to content

Module_Statistics_ExtremeValueFinder

cyclone_dll edited this page Jul 6, 2026 · 8 revisions

Location: Home / Statistics module / Extreme value finder

Statistics module

Extreme value finder

Vorcyc.Mathematics.Statistics.ExtremeValueFinder is a class that provides methods for finding the maximum and minimum values in a sequence. The class uses optimized algorithms to obtain both the maximum and minimum in a single pass.

All methods below are located in class: Vorcyc.Mathematics.Statistics.ExtremeValueFinder


📒Contents


Vorcyc.Mathematics.Statistics.ExtremeValueFinder class

Vorcyc.Mathematics.Statistics.ExtremeValueFinder is a class that provides methods for finding the maximum and minimum values in a sequence.

Methods

1. FindExtremeValue method

Finds the maximum and minimum values in a sequence.

  • public static (float max, float min) FindExtremeValue(this float[] array, int start, int length)

    • Finds the maximum and minimum values in the specified range of a float array.
    • Parameters:
      • array: The float array.
      • start: The starting index of the range.
      • length: The length of the range.
    • Returns: A tuple containing the maximum and minimum values in the specified range.
  • public static (T max, T min) FindExtremeValue<T>(this T[] array, int start, int length) where T : INumber<T>

    • Finds the maximum and minimum values in the specified range of an array.
    • Parameters:
      • array: The array.
      • start: The starting index of the range.
      • length: The length of the range.
    • Returns: A tuple containing the maximum and minimum values in the specified range.
  • public static (float max, float min) FindExtremeValue(this float[] array)

    • Finds the maximum and minimum values in a float array.
    • Parameters:
      • array: The float array.
    • Returns: A tuple containing the maximum and minimum values in the array.
  • public static (T max, T min) FindExtremeValue<T>(this T[] array) where T : INumber<T>

    • Finds the maximum and minimum values in an array.
    • Parameters:
      • array: The array.
    • Returns: A tuple containing the maximum and minimum values in the array.
  • public static (float max, float min) FindExtremeValue(this ArraySegment<float> arraySegment)

    • Finds the maximum and minimum values in a float array segment.
    • Parameters:
      • arraySegment: The float array segment.
    • Returns: A tuple containing the maximum and minimum values in the array segment.
  • public static (T max, T min) FindExtremeValue<T>(this ArraySegment<T> arraySegment) where T : INumber<T>

    • Finds the maximum and minimum values in an array segment.
    • Parameters:
      • arraySegment: The array segment.
    • Returns: A tuple containing the maximum and minimum values in the array segment.
  • public static (float max, float min) FindExtremeValue(this Span<float> span)

    • Finds the maximum and minimum values in a float Span.
    • Parameters:
      • span: The float Span.
    • Returns: A tuple containing the maximum and minimum values in the Span.

Code example

The following example uses several methods from the ExtremeValueFinder class, with comments in the sample:

using System;
using Vorcyc.Mathematics.Statistics;

public class ExtremeValueFinderExample
{
    public static void Main()
    {
        // Define a float array
        float[] floatArray = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f };

        // Find maximum and minimum in the array
        var (maxFloat, minFloat) = floatArray.FindExtremeValue();
        Console.WriteLine($"Max value in float array: {maxFloat}, Min value in float array: {minFloat}");

        // Find maximum and minimum in a specified range of the array
        var (maxFloatRange, minFloatRange) = floatArray.FindExtremeValue(1, 3);
        Console.WriteLine($"Max value in float array range: {maxFloatRange}, Min value in float array range: {minFloatRange}");

        // Define an integer array
        int[] intArray = { 1, 2, 3, 4, 5 };

        // Find maximum and minimum in the array
        var (maxInt, minInt) = intArray.FindExtremeValue();
        Console.WriteLine($"Max value in int array: {maxInt}, Min value in int array: {minInt}");

        // Find maximum and minimum in a specified range of the array
        var (maxIntRange, minIntRange) = intArray.FindExtremeValue(1, 3);
        Console.WriteLine($"Max value in int array range: {maxIntRange}, Min value in int array range: {minIntRange}");

        // Define a float array segment
        ArraySegment<float> floatSegment = new ArraySegment<float>(floatArray, 1, 3);

        // Find maximum and minimum in the array segment
        var (maxFloatSegment, minFloatSegment) = floatSegment.FindExtremeValue();
        Console.WriteLine($"Max value in float array segment: {maxFloatSegment}, Min value in float array segment: {minFloatSegment}");

        // Define an integer array segment
        ArraySegment<int> intSegment = new ArraySegment<int>(intArray, 1, 3);

        // Find maximum and minimum in the array segment
        var (maxIntSegment, minIntSegment) = intSegment.FindExtremeValue();
        Console.WriteLine($"Max value in int array segment: {maxIntSegment}, Min value in int array segment: {minIntSegment}");

        // Define a float Span
        Span<float> floatSpan = new Span<float>(floatArray);

        // Find maximum and minimum in the Span
        var (maxFloatSpan, minFloatSpan) = floatSpan.FindExtremeValue();
        Console.WriteLine($"Max value in float span: {maxFloatSpan}, Min value in float span: {minFloatSpan}");
    }
}

Language / 语言: English · 简体中文


Home


首页

Clone this wiki locally