MAIDR Documentation - v3.39.0
    Preparing search index...

    Class MathUtilAbstract

    Mathematical utility functions for common operations across the codebase. These utilities help reduce code duplication while maintaining type safety.

    Index

    Methods

    • Safely finds the minimum value from an array of numbers. Returns Infinity for empty arrays (mathematically correct: empty set has no minimum). This prevents subtle bugs where 0 might be confused with actual data.

      Parameters

      • values: number[]

        Array of numbers to find minimum from

      Returns number

      The minimum value or Infinity if array is empty

    • Safely finds the maximum value from an array of numbers. Returns -Infinity for empty arrays (mathematically correct: empty set has no maximum). This prevents subtle bugs where 0 might be confused with actual data.

      Parameters

      • values: number[]

        Array of numbers to find maximum from

      Returns number

      The maximum value or -Infinity if array is empty

    • Finds the minimum value from a 2D array of numbers.

      Parameters

      • values: number[][]

        2D array of numbers

      Returns number

      The minimum value across all nested arrays

    • Finds the maximum value from a 2D array of numbers.

      Parameters

      • values: number[][]

        2D array of numbers

      Returns number

      The maximum value across all nested arrays

    • Finds min and max from an array in a single pass. More efficient than separate min/max calls for large arrays. Returns { min: Infinity, max: -Infinity } for empty arrays.

      Parameters

      • values: number[]

        Array of numbers

      Returns { min: number; max: number }

      Object with min and max properties

    • Finds min and max from a 2D array in a single pass.

      Parameters

      • values: number[][]

        2D array of numbers

      Returns { min: number; max: number }

      Object with min and max properties