@d4c/numjs
    Preparing search index...

    Class NdArray

    Multidimensional, homogeneous array of fixed-size items

    The number of dimensions and items in an array is defined by its shape, which is a tuple of N positive integers that specify the sizes of each dimension. The type of items in the array is specified by a separate data-type object (dtype), one of which is associated with each NdArray.

    Index

    Constructors

    Properties

    selection: ndarray.NdArray

    Accessors

    • get dtype(): | "array"
      | "int8"
      | "int16"
      | "int32"
      | "uint8"
      | "uint8_clamped"
      | "uint16"
      | "uint32"
      | "float32"
      | "float64"
      | "generic"

      Data-type of the array’s elements.

      Returns
          | "array"
          | "int8"
          | "int16"
          | "int32"
          | "uint8"
          | "uint8_clamped"
          | "uint16"
          | "uint32"
          | "float32"
          | "float64"
          | "generic"

    • set dtype(
          dtype:
              | "array"
              | "int8"
              | "int16"
              | "int32"
              | "uint8"
              | "uint8_clamped"
              | "uint16"
              | "uint32"
              | "float32"
              | "float64"
              | "generic",
      ): void

      Parameters

      • dtype:
            | "array"
            | "int8"
            | "int16"
            | "int32"
            | "uint8"
            | "uint8_clamped"
            | "uint16"
            | "uint32"
            | "float32"
            | "float64"
            | "generic"

      Returns void

    • get ndim(): number

      Number of array dimensions.

      Returns number

      NdArray#ndim

    • get shape(): number[]

      The shape of the array

      Returns number[]

      NdArray#shape

    Methods

    • Stringify the array to make it readable in the console, by a human.

      Returns string

    • Returns the discrete, linear convolution of the array using the given filter.

      @note: Arrays must have the same dimensions and filter must be smaller than the array. @note: The convolution product is only given for points where the signals overlap completely. Values outside the signal boundary have no effect. This behaviour is known as the 'valid' mode. @note: Use optimized code for 3x3, 3x3x1, 5x5, 5x5x1 filters, FFT otherwise.

      Parameters

      Returns NdArray

    • Calculate the exponential of all elements in the array, element-wise.

      Parameters

      • copy: boolean = true

        set to false to modify the array rather than create a new one

      Returns NdArray

    • Return a sliced view of the array.

      Parameters

      • ...args: number[]

      Returns NdArray

      arr = nj.arange(4*4).reshape(4,4)
      // array([[ 0, 1, 2, 3],
      // [ 4, 5, 6, 7],
      // [ 8, 9, 10, 11],
      // [ 12, 13, 14, 15]])

      arr.hi(3,3)
      // array([[ 0, 1, 2],
      // [ 4, 5, 6],
      // [ 8, 9, 10]])

      arr.lo(1,1).hi(2,2)
      // array([[ 5, 6],
      // [ 9, 10]])
    • Return a shifted view of the array. Think of it as taking the upper left corner of the image and dragging it inward

      Parameters

      • ...args: number[]

      Returns NdArray

      arr = nj.arange(4*4).reshape(4,4)
      // array([[ 0, 1, 2, 3],
      // [ 4, 5, 6, 7],
      // [ 8, 9, 10, 11],
      // [ 12, 13, 14, 15]])
      arr.lo(1,1)
      // array([[ 5, 6, 7],
      // [ 9, 10, 11],
      // [ 13, 14, 15]])
    • Calculate the natural logarithm of all elements in the array, element-wise.

      Parameters

      • copy: boolean = true

        set to false to modify the array rather than create a new one

      Returns NdArray

    • Return a subarray by fixing a particular axis

      Parameters

      • ...axis: number[]

        a array whose element could be null or number

      Returns NdArray

      arr = nj.arange(4*4).reshape(4,4)
      // array([[ 0, 1, 2, 3],
      // [ 4, 5, 6, 7],
      // [ 8, 9, 10, 11],
      // [ 12, 13, 14, 15]])

      arr.pick(1)
      // array([ 4, 5, 6, 7])

      arr.pick(null, 1)
      // array([ 1, 5, 9, 13])
    • Gives a new shape to the array without changing its data.

      Parameters

      • ...shape: number[]

        The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.

      Returns NdArray

      a new view object if possible, a copy otherwise,

    • Gives a new shape to the array without changing its data.

      Parameters

      • shape: number[]

        The new shape should be compatible with the original shape. If an integer, then the result will be a 1-D array of that length. One shape dimension can be -1. In this case, the value is inferred from the length of the array and remaining dimensions.

      Returns NdArray

      a new view object if possible, a copy otherwise,

    • Calculate the positive square-root of all elements in the array, element-wise.

      Parameters

      • copy: boolean = true

        set to false to modify the array rather than create a new one

      Returns NdArray

    • Returns the standard deviation, a measure of the spread of a distribution, of the array elements.

      Parameters

      • Optionaloptions: { ddof: number }

        default {ddof:0}

      Returns number

    • Stringify the array to make it readable by a human.

      Returns string

    • Permute the dimensions of the array.

      Parameters

      • ...axes: number[]

      Returns NdArray

      arr = nj.arange(6).reshape(1,2,3)
      // array([[[ 0, 1, 2],
      // [ 3, 4, 5]]])

      arr.T
      // array([[[ 0],
      // [ 3]],
      // [[ 1],
      // [ 4]],
      // [[ 2],
      // [ 5]]])

      arr.transpose(1,0,2)
      // array([[[ 0, 1, 2]],
      // [[ 3, 4, 5]]])
    • Permute the dimensions of the array.

      Parameters

      • Optionalaxes: number[]

      Returns NdArray

      arr = nj.arange(6).reshape(1,2,3)
      // array([[[ 0, 1, 2],
      // [ 3, 4, 5]]])

      arr.T
      // array([[[ 0],
      // [ 3]],
      // [[ 1],
      // [ 4]],
      // [[ 2],
      // [ 5]]])

      arr.transpose(1,0,2)
      // array([[[ 0, 1, 2]],
      // [[ 3, 4, 5]]])
    • Parameters

      • arr: number | ArbDimNumArray | TypedArray | NdArray
      • Optionaldtype:
            | ArrayLikeConstructor
            | "array"
            | "int8"
            | "int16"
            | "int32"
            | "uint8"
            | "uint8_clamped"
            | "uint16"
            | "uint32"
            | "float32"
            | "float64"

      Returns NdArray