Skip to content

Latest commit

 

History

History
391 lines (269 loc) · 14.4 KB

File metadata and controls

391 lines (269 loc) · 14.4 KB

AFArray class

-> ArrayFire Documentation

TOC

Staitc methods

AFArray.create()

asynchronous, counterparts: createAsync, createSync

Creates an AFArray instance of the specified dimensions, and copies data from the location specified by the buffer. Data can be reside on the host or on the device, the source argument specifies its location.

Arguments:

  • dim0 .. dim3: Number - size of the dimension
  • dims: Array|Dim4 - specifies sizes of the dimensions, eg: [2, 1, 1] or new Dim4(3, 4)
  • type: value of dType - can be one of the values of dType object (eg. dType.f32)
  • buffer: Buffer - data to copy to the device, or device pointer created by the alloc method.
  • source: value of source - can be one of the values of source object (eg. source.host)

Result: the created AFArray instance.

constructor

Arrays could be created as empty ones or by having a specified dimensions and element type.

Arguments:

  • dim0 .. dim3: Number - size of the dimension
  • dims: Array|Dim4 - specifies sizes of the dimensions, eg: [2, 1, 1] or new Dim4(3, 4)
  • type: value of dType - can be one of the values of dType object (eg. dType.f32)

Remarks:

In Fire.js type argument is not optional.

Methods

elements()

Get the number of elements in array.

Result: Number

host()

Copy array data to host.

asynchronous, counterparts: hostAsync, hostSync

Arguments:

  • buffer: Buffer - to hold array's values, must be atleast the size of the array.

Result: if buffer is not specified, then it will be created and returned, otherwise the result is undefined

copyToHost()

alias of host

scalar()

asynchronous, counterparts: scalarAsync, scalarSync

Get scalar value from the array (if its size is larger than one in any dimensions it gives the first value).

  • scalar(callback)

Result: Boolean|Number|String|Complex value in the array, type depends on the array's type.

value()

alias of scalar()

write()

Perform deep copy from host/device pointer to an existing array.

Arguments:

  • buffer: Buffer - data to copy to the array, or device pointer created by the alloc method.
  • bytesToCopy: bytes to copy
  • source: value of source - can be one of the values of source object (eg. source.host)

type()

Result: array's element type, can be one of the values of dType object

dims()

Result:

  • of dims(): array's dimensions info in a Dim4 object instance
  • of dims(n): size of the specified dimension

numdims()

Result: number of dimensions of the array

numDims()

alias of numdims

bytes()

Result: size of the array in bytes

as()

Converts the array into another type.

Arguments:

  • type: value of dType - can be one of the values of dType object (eg. dType.f32)

Result: AFArray instance holding reference the converted array

copy())`

Result: new AFArray instance holding a deep copy of the array

isempty(), isscalar(), isvector(), isrow(), iscolumn(), iscomplex(), isreal(), isdouble(), issingle(), isrealfloating(), isfloating(), isinteger(), isbool()

aliases respectively: isEmpty, isScalar, isVector, isRow, isColumn, isComplex, isReal, isDouble, isSingle, isRealFloating, isFloating, isInteger, isBool

Result: actual type info (Boolean)

eval()

Evaluate any JIT expressions to generate data for the array.

Indexing Operations

at()

-> ArrayFire Documentation

  • at(s0)
  • at(s0, s1)
  • at(s0, s1, s2)
  • at(s0, s1, s2, s3)
  • at(def)

Arguments:

  • s0 .. s3: null|String|Number|Seq|AFArray
    • null: means "span"
    • String: can be "span"
    • Number: element's index, or -1 which means the last element
    • Seq: sequence of values
    • AFArray: array holding the index value
  • def: Row|Rows|Col|Cols|Slice|Slices
    • Row: specified row
    • Rows: specified rows
    • Col: specified column
    • Cols: specified columns
    • Slice: specified slice
    • Slices: specified slices

Result: AFArray instance holding reference to the the specified region of the original array

row(), rows()

Gets a reference of a row in a 2D AFArray.

-> ArrayFire Documentation

  • row(index)
  • rows(firstIndex, lastIndex)

Arguments:

  • index, fistIndex, lastIndex: Number - a row index or a range of row indices

Result: AFArray instance holding reference to the specified region of the original 2D array

col(), cols()

Gets a reference of a column in a 2D AFArray.

-> ArrayFire Documentation

  • col(index)
  • cols(firstIndex, lastIndex)

Arguments:

  • index, fistIndex, lastIndex: Number - a column index or a range of column indices

Result: AFArray instance holding reference to the specified region of the original 2D array

slice(), slices()

Gets a reference of a matrix in a 3D AFArray.

-> ArrayFire Documentation

  • slice(index)
  • slices(firstIndex, lastIndex)

Arguments:

  • index, fistIndex, lastIndex: Number - a matrix index or a range of matrix indices

Result: AFArray instance holding reference to the specified region of the original 3D array

Assignment Operators

-> ArrayFire Documentation

  • assign(other) operator =
  • set(other) operator = (alias of assign)
  • addAssign(other) operator +=
  • subAssign(other) operator -=
  • mulAssign(other) operator *=
  • divAssign(other) operator /=
  • assign(s0, other) operator =
  • set(s0, other) operator = (alias of assign)
  • addAssign(s0, other) operator +=
  • subAssign(s0, other) operator -=
  • mulAssign(s0, other) operator *=
  • divAssign(s0, other) operator /=
  • assign(s0, s1, other) operator =
  • set(s0, s1, other) operator = (alias of assign)
  • addAssign(s0, s1, other) operator +=
  • subAssign(s0, s1, other) operator -=
  • mulAssign(s0, s1, other) operator *=
  • divAssign(s0, s1, other) operator /=
  • assign(s0, s1, s2, other) operator =
  • set(s0, s1, s2, other) operator = (alias of assign)
  • addAssign(s0, s1, s2, other) operator +=
  • subAssign(s0, s1, s2, other) operator -=
  • mulAssign(s0, s1, s2, other) operator *=
  • divAssign(s0, s1, s2, other) operator /=
  • assign(s0, s1, s2, s3, other) operator =
  • set(s0, s1, s2, s3, other) operator = (alias of assign)
  • addAssign(s0, s1, s2, s3, other) operator +=
  • subAssign(s0, s1, s2, s3, other) operator -=
  • mulAssign(s0, s1, s2, s3, other) operator *=
  • divAssign(s0, s1, s2, s3, other) operator /=
  • assign(def, other) operator =
  • set(def, other) operator = (alias of assign)
  • addAssign(def, other) operator +=
  • subAssign(def, other) operator -=
  • mulAssign(def, other) operator *=
  • divAssign(def, other) operator /=

Arguments:

  • s0 .. s3: null|String|Number|Seq|AFArray lhs index
    • null: means "span"
    • String: can be "span"
    • Number: element's index, or -1 which means the last element
    • Seq: sequence of values
    • AFArray: array holding the index value
  • def: Row|Rows|Col|Cols|Slice|Slices
    • Row: specified row
    • Rows: specified rows
    • Col: specified column
    • Cols: specified columns
    • Slice: specified slice
    • Slices: specified slices
  • other: AFArray|Number|Complex|String
    • AFArray: rhs array
    • Number: rhs number
    • Complex: rhs complex value
    • String:: rhs number value (to workaround JavaScript inability to hold int64 values)

Result: assignee AFArray instance

Arithmetic Operators

-> ArrayFire Documentation

  • add(other) operator +
  • sub(other) operator -
  • mul(other) operator *
  • div(other) operator /
  • bitshiftl(other) operator <<
  • bitShiftL(other) operator << (alias of bitshiftl)
  • bitshiftr(other) operator <<
  • bitShiftR(other) operator << (alias of bitshiftr)

Arguments:

  • other: AFArray|Number|Complex|String
    • AFArray: rhs array
    • Number: rhs number
    • Complex: rhs complex value
    • String:: rhs number value (to workaround JavaScript inability to hold int64 values)

Result: AFArray instance holding the operation's result

Logical Operators

-> ArrayFire Documentation

  • neg() operator -
  • not() operator !
  • lt(other) operator <
  • gt(other) operator >
  • le(other) operator <=
  • ge(other) operator >=
  • eq(other) operator ==
  • neq(other) operator !=
  • and(other) operator &&
  • or(other) operator ||
  • bitAnd(other) operator &
  • bitOr(other) operator |
  • bitXor(other) operator ^

Arguments:

  • other: AFArray|Number|Complex|String
    • AFArray: rhs array
    • Number: rhs number
    • Complex: rhs complex value
    • String:: rhs number value (to workaround JavaScript inability to hold int64 values)

Result: AFArray instance holding the operation's result