Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Array1D<T>

Type parameters

  • T: "float32" | "int32" | "bool"

Hierarchy

Index

Constructors

constructor

  • new Array1D(data: NDArrayData<T>, dtype: T): Array1D

Properties

dtype

dtype: T

The data type for the array.

shape

shape: [number]

size

size: number

Number of elements in the ndarray.

Protected strides

strides: number[]

Number of elements to skip in each dimension when indexing. See https://docs.scipy.org/doc/numpy/reference/generated /numpy.ndarray.strides.html

Accessors

rank

  • get rank(): number

Methods

add

  • add(value: number, i: number): void

as1D

as2D

  • as2D(rows: number, columns: number): Array2D<T>

as3D

  • as3D(rows: number, columns: number, depth: number): Array3D<T>

as4D

  • as4D(rows: number, columns: number, depth: number, depth2: number): Array4D<T>

asScalar

asType

data

  • data(): Promise<DataTypes[T]>
  • Asynchronously downloads the values from the NDArray. Returns a promise that resolves when the data is ready.

    Returns Promise<DataTypes[T]>

dataSync

  • dataSync(): DataTypes[T]
  • Synchronously downloads the values from the NDArray. This blocks the UI thread until the values are ready, which can cause performance issues.

    Returns DataTypes[T]

dispose

  • dispose(): void

equals

fill

  • fill(value: number): void

flatten

get

  • get(i: number): number

getData

  • getData(): NDArrayData<T>

getTexture

  • getTexture(): WebGLTexture

getTextureShapeRC

  • getTextureShapeRC(): [number, number]

getValues

  • getValues(): DataTypes[T]

getValuesAsync

  • getValuesAsync(): Promise<DataTypes[T]>

inGPU

  • inGPU(): boolean

indexToLoc

  • indexToLoc(index: number): [number]

locToIndex

  • locToIndex(loc: [number]): number

reshape

  • reshape(newShape: number[]): NDArray<T>

set

  • set(value: number, i: number): void

val

  • val(i: number): Promise<number>

Static fromPixels

  • fromPixels(pixels: ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, numChannels?: number): Array3D<"int32">
  • Parameters

    • pixels: ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement
    • Default value numChannels: number = 3

    Returns Array3D<"int32">

Static like

  • like<G, T>(another: T): T
  • Creates a ndarray with the same values/shape as the specified ndarray.

    Type parameters

    • G: "float32" | "int32" | "bool"

    • T: NDArray<G>

    Parameters

    • another: T

    Returns T

Static make

  • make<T>(shape: number[], data: NDArrayData<T>, dtype?: T): NDArray<T>
  • Makes a new ndarray with the provided shape and values. Values should be in a flat array.

    Type parameters

    • T: "float32" | "int32" | "bool"

    Parameters

    • shape: number[]
    • data: NDArrayData<T>
    • Optional dtype: T

    Returns NDArray<T>

Static new

  • new<T>(values: DataTypes[T] | number[] | boolean[], dtype?: T): Array1D<T>
  • Type parameters

    • T: "float32" | "int32" | "bool"

    Parameters

    • values: DataTypes[T] | number[] | boolean[]
    • Optional dtype: T

    Returns Array1D<T>

Static rand

  • rand<T>(shape: number[], randFunction: function, dtype?: T): NDArray<T>
  • Type parameters

    • T: "float32" | "int32" | "bool"

    Parameters

    • shape: number[]
    • randFunction: function
        • (): number
        • Returns number

    • Optional dtype: T

    Returns NDArray<T>

Static randNormal

  • randNormal<T>(shape: [number], mean?: number, stdDev?: number, dtype?: T, seed?: number): Array1D<T>
  • Type parameters

    • T: "float32" | "int32"

    Parameters

    • shape: [number]
    • Default value mean: number = 0
    • Default value stdDev: number = 1
    • Optional dtype: T
    • Optional seed: number

    Returns Array1D<T>

Static randTruncatedNormal

  • randTruncatedNormal<T>(shape: [number], mean?: number, stdDev?: number, dtype?: T, seed?: number): Array1D<T>
  • Type parameters

    • T: "float32" | "int32"

    Parameters

    • shape: [number]
    • Default value mean: number = 0
    • Default value stdDev: number = 1
    • Optional dtype: T
    • Optional seed: number

    Returns Array1D<T>

Static randUniform

  • randUniform<T>(shape: [number], a: number, b: number, dtype?: T): Array1D<T>

Static zeros

  • zeros<T>(shape: [number], dtype?: T): Array1D<T>

Static zerosLike

  • zerosLike<G, T>(another: T): T
  • Creates a ndarray of zeros with the same shape as the specified ndarray.

    Type parameters

    • G: "float32" | "int32" | "bool"

    • T: NDArray<G>

    Parameters

    • another: T

    Returns T

Generated using TypeDoc