Skip to content

Latest commit

 

History

History
557 lines (346 loc) · 10.8 KB

File metadata and controls

557 lines (346 loc) · 10.8 KB

🏭 StridedView

Constructors

public: *

Parameters:

  • data: - The underlying 1D storage for the multidimensional array
  • shape: - The shape of the array (Default: [data.length, 1])
  • stride: - The stride of the array (Default: row major, [1, shape[0])
  • offset: - The offset of the array (Default: 0)

Methods

⚙️ get

Method Type
get (x: number, y: number) => T or undefined

Parameters:

  • x: - The x coordinate
  • y: - The y coordinate

⚙️ set

Method Type
set (x: number, y: number, value: T) => void

Parameters:

  • x: - The x coordinate
  • y: - The y coordinate
  • value: - The value to set

⚙️ forEach

Method Type
forEach (callbackFn: MapCallback<T, void>) => void

Parameters:

  • callbackFn: - The function to execute on each element

⚙️ reduce

Method Type
reduce <R>(callbackFn: ReduceCallback<T, R>, initialValue: R) => R

Parameters:

  • callbackFn: - The function to execute on each element, returning the new accumulator value
  • initialValue: - The initial value of the accumulator

⚙️ fill

Method Type
fill (value: T) => this

Parameters:

  • value: - The value to fill the view with

⚙️ floodFill

Method Type
floodFill (pos: [number, number], value: T, topology?: Topology, predicate?: ((target: T, current: T) => boolean) or undefined) => this

Parameters:

  • pos: - Position to start the flood fill
  • value: - The value to fill the view with
  • topology: - The topology of the flood fill (4 or 8)
  • predicate: - The predicate to determine if a cell should be filled

⚙️ update

Method Type
update (callbackFn: MapCallback<T, T>) => this

Parameters:

  • callbackFn: - The function to execute on each element, returning the new value

⚙️ place

Method Type
place (sub: StridedView<T>, [x, y]: [number, number]) => this

Parameters:

  • sub: - The subview to place
  • pos: - The position to place the subview

⚙️ placeWith

Method Type
placeWith <R>(sub: StridedView<R>, pos: [number, number], callbackFn: MapCallback<R, T>) => this

Parameters:

  • sub: - The subview to place
  • pos: - The position to place the subview
  • callbackFn: - The function to execute on each element, returning the new value

⚙️ map

Method Type
map <R>(callbackFn: MapCallback<T, R>) => StridedView<R>

Parameters:

  • callbackFn: - The function to execute on each element, returning the new value

⚙️ copy

Method Type
copy () => StridedView<T>

⚙️ reshape

Method Type
reshape (shape: [number, number]) => StridedView<T>

Parameters:

  • shape: - The new shape of the array

⚙️ transpose

Method Type
transpose () => StridedView<T>

⚙️ lo

Method Type
lo ([x, y]: [number, number]) => StridedView<T>

Parameters:

  • pos: - The position of the lower bound

⚙️ hi

Method Type
hi (shape: [number, number]) => StridedView<T>

Parameters:

  • shape: - The shape of the upper bound

⚙️ slice

Method Type
slice ([x, y]: [number, number], shape?: [number, number] or undefined) => StridedView<T>

Parameters:

  • begin: - The coordinates to start the slice from
  • shape: - The size of the slice (Default: [shape[0] - begin[0], shape[1] - begin[1])

⚙️ col

Method Type
col (col: number) => StridedView<T>

Parameters:

  • col: - The index of the column

⚙️ row

Method Type
row (row: number) => StridedView<T>

Parameters:

  • row: - The index of the row

⚙️ flip

Method Type
flip (dim?: Dim) => StridedView<T>

Parameters:

  • dim: - The dimension of the axis (Default: 0, 0 = x, 1 = y)

⚙️ scale

Method Type
scale (scale: [number, number]) => StridedView<T>

⚙️ reverse

Method Type
reverse () => StridedView<T>

⚙️ rotate90

Method Type
rotate90 () => StridedView<T>

⚙️ neighborhood

Method Type
neighborhood (pos: [number, number], distance?: number) => StridedView<T>

Parameters:

  • pos: - The position of the center of the neighborhood
  • distance: - The distance from the center of the neighborhood

⚙️ flat

Method Type
flat () => StridedView<T>

⚙️ indexOf

Method Type
indexOf (value: T) => [number, number]

Parameters:

  • value: - The value to search for

⚙️ includes

Method Type
includes (value: T) => boolean

Parameters:

  • value: - The value to search for

⚙️ some

Method Type
some (callbackFn: MapCallback<T, boolean>) => boolean

Parameters:

  • callbackFn: -

⚙️ every

Method Type
every (callbackFn: MapCallback<T, boolean>) => boolean

Parameters:

  • callbackFn: -

⚙️ findIndex

Method Type
findIndex (callbackFn: MapCallback<T, boolean>) => [number, number]

Parameters:

  • callbackFn: -

⚙️ findIndices

Method Type
findIndices (callbackFn?: MapCallback<T, boolean> or undefined) => [number, number][]

⚙️ sample

Method Type
sample (k?: number, callbackFn?: MapCallback<T, boolean> or undefined) => [number, number][]

⚙️ serialize

Method Type
serialize () => { shape: [number, number]; stride: [number, number]; offset: number; data: Data<T>; }

⚙️ toString

Method Type
toString () => string

⚙️ join

Method Type
join (colSep?: string, rowSep?: string) => string

Parameters:

  • colSep: - The separator between columns (default: ",")
  • rowSep: - The separator between rows (default: "\n")

⚙️ toArrays

Method Type
toArrays () => T[][]

⚙️ toArray

Method Type
toArray () => T[]

⚙️ of

Method Type
of <T>(array: Data<T>, shape?: [number, number] or undefined) => StridedView<T>

Parameters:

  • array: - The underlying 1D storage for the multidimensional array
  • shape: - The shape of the view

⚙️ from

Method Type
from <T>(array: T[][]) => StridedView<T>

Parameters:

  • array: - A 2D array to create a view from

⚙️ range

Method Type
range (shape: [number, number], start?: number, step?: number) => StridedView<number>

Parameters:

  • shape: - The shape of the range
  • start: - The starting value of the range (Default: 0)
  • step: - The step between values in the range (Default: 1)

⚙️ zeros

Method Type
zeros (shape: [number, number]) => StridedView<number>

Parameters:

  • shape: - The shape of the array

⚙️ ones

Method Type
ones (shape: [number, number]) => StridedView<number>

Parameters:

  • shape: - The shape of the array

⚙️ identity

Method Type
identity (length: number) => StridedView<number>

Parameters:

  • length: - The length of the identity matrix

⚙️ diagonal

Method Type
diagonal (array: number[]) => StridedView<number>

Parameters:

  • array: - The array to create a diagonal matrix from (i.e. the diagonal values)

⚙️ fill

Method Type
fill <T>(shape: [number, number], value: T) => StridedView<T>

Parameters:

  • shape: - The shape of the view
  • value: - The value to fill the array with

⚙️ random

Method Type
random (shape: [number, number], randFn?: (() => number) or undefined) => StridedView<number>

Parameters:

  • shape: - The shape of the view
  • randFn: - The random number generator function (Default: Math.random)

⚙️ empty

Method Type
empty <T>(shape: [number, number]) => StridedView<T>

⚙️ isStridedView

Method Type
isStridedView <T>(obj: any) => obj is StridedView<T>

Parameters:

  • obj: - The object to check

Properties

⚙️ stride

Property Type
stride [number, number]

⚙️ shape

Property Type
shape [number, number]

⚙️ offset

Property Type
offset number