IdaJS
    Preparing search index...

    Interface ArrayExtensions<T>

    Extends the Array prototype with additional mathematical operations with vectors.

    interface ArrayExtensions<T> {
        div(scalar: number): number[];
        magnitude(): number;
        minus(other: number[]): number[];
        mul(scalar: number): number[];
        plus(other: number[]): number[];
        random(): T;
        sqrMagnitude(): number;
    }

    Type Parameters

    • T
    Index

    Methods

    • Performs scalar division on all components of the array.

      Parameters

      • scalar: number

        The number to divide each array element by

      Returns number[]

      A new array with each element divided by the scalar

      Error if the argument is not a number or is zero

    • Calculates the magnitude (length) of the array as a vector. Uses the formula: √(x₁² + x₂² + ... + xₙ²)

      Returns number

      The magnitude of the array as a number

    • Performs element-wise subtraction between this array and another numeric array. Both arrays must have equal length.

      Parameters

      • other: number[]

        The numeric array to subtract from this array

      Returns number[]

      A new array with the results of element-wise subtraction

      Error if the argument is not an array or arrays have different lengths

    • Performs scalar multiplication on all components of the array.

      Parameters

      • scalar: number

        The number to multiply each array element by

      Returns number[]

      A new array with each element multiplied by the scalar

      Error if the argument is not a number

    • Performs element-wise addition between this array and another numeric array. Both arrays must have equal length.

      Parameters

      • other: number[]

        The numeric array to add to this array

      Returns number[]

      A new array with the results of element-wise addition

      Error if the argument is not an array or arrays have different lengths

    • Calculates the squared magnitude of the array as a vector (faster than magnitude). Uses the formula: x₁² + x₂² + ... + xₙ²

      Returns number

      The squared magnitude of the array as a number