Options
All
  • Public
  • Public/Protected
  • All
Menu

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.

Hierarchy

  • NdArray

Index

Constructors

constructor

Properties

selection

selection: ndarray.NdArray<number[] | ndarray.TypedArray | GenericArray<number>>

Accessors

T

dtype

  • get dtype(): "array" | "int8" | "uint8" | "uint8_clamped" | "int16" | "uint16" | "int32" | "uint32" | "float32" | "float64" | "generic"
  • set dtype(dtype: "array" | "int8" | "uint8" | "uint8_clamped" | "int16" | "uint16" | "int32" | "uint32" | "float32" | "float64" | "generic"): void
  • Data-type of the array’s elements.

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

  • Data-type of the array’s elements.

    Parameters

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

    Returns void

ndim

  • get ndim(): number

shape

  • get shape(): number[]

size

  • get size(): number

Methods

[custom]

  • [custom](): string
  • Stringify the array to make it readable in the console, by a human.

    Returns string

add

assign

clone

convolve

  • 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

diag

divide

dot

equal

exp

  • 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

fftconvolve

flatten

get

  • get(...args: number[]): number

hi

  • Return a sliced view of the array.

    example
    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]])

    Parameters

    • Rest ...args: number[]

    Returns NdArray

iteraxis

  • iteraxis(axis: number, cb: (xi: NdArray, i: number) => void): void

lo

  • Return a shifted view of the array. Think of it as taking the upper left corner of the image and dragging it inward

    example
    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]])

    Parameters

    • Rest ...args: number[]

    Returns NdArray

log

  • 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

max

  • max(): number

mean

  • mean(): number

min

  • min(): number

mod

multiply

negative

pick

  • Return a subarray by fixing a particular axis

    example
    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])

    Parameters

    • Rest ...axis: number[]

      a array whose element could be null or number

    Returns NdArray

pow

reshape

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

    Parameters

    • Rest ...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,

  • Parameters

    • shape: number[]

    Returns NdArray

round

set

  • set(...args: number[]): number

slice

  • slice(...args: (number | number[])[]): NdArray

sqrt

  • 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

std

  • std(options?: { ddof: number }): number
  • Returns the standard deviation, a measure of the spread of a distribution, of the array elements.

    Parameters

    • Optional options: { ddof: number }

      default {ddof:0}

      • ddof: number

    Returns number

step

subtract

sum

  • sum(): number

toJSON

  • toJSON(): string

toString

  • toString(): string

tolist

transpose

  • transpose(...axes: number[]): NdArray
  • transpose(axes?: number[]): NdArray
  • Permute the dimensions of the array.

    example
    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

    • Rest ...axes: number[]

    Returns NdArray

  • Parameters

    • Optional axes: number[]

    Returns NdArray

valueOf

Static new

Generated using TypeDoc