AFArray class
TOC
- Staitc methods
- constructor
- Methods
- Indexing Operations
- Assignment Operators
- Arithmetic Operators
- Logical Operators
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.
create(dim0, type, buffer, source, callback)
-> ArrayFire Documentationcreate(dim0, dim1, type, buffer, source, callback)
-> ArrayFire Documentationcreate(dim0, dim1, dim2, type, buffer, source, callback)
-> ArrayFire Documentationcreate(dim0, dim1, dim2, dim3, type, buffer, source, callback)
-> ArrayFire Documentationcreate(dims, buffer, source, callback)
-> ArrayFire Documentation
Arguments:
- dim0 .. dim3: Number - size of the dimension
- dims: Array|Dim4 - specifies sizes of the dimensions, eg:
[2, 1, 1]
ornew 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.
new AFArray()
: -> ArrayFire Documentationnew AFArray(dim0, type)
: -> ArrayFire Documentationnew AFArray(dim0, dim1, type)
: -> ArrayFire Documentationnew AFArray(dim0, dim1, dim2, type)
: -> ArrayFire Documentationnew AFArray(dim0, dim1, dim2, dim3, type)
: -> ArrayFire Documentationnew AFArray(dims, type)
: -> ArrayFire Documentation
Arguments:
- dim0 .. dim3: Number - size of the dimension
- dims: Array|Dim4 - specifies sizes of the dimensions, eg:
[2, 1, 1]
ornew 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.
elements()
-> ArrayFire Documentation
Result: Number
host()
Copy array data to host.
asynchronous, counterparts: hostAsync
, hostSync
host(callback)
-> ArrayFire Documentationhost(buffer, callback)
-> ArrayFire Documentation
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.
write(buffer, bytesToCopy, source, callback)
-> ArrayFire Documentation
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()
type()
-> ArrayFire Documentation
Result: array's element type, can be one of the values of dType object
dims()
dims()
-> ArrayFire Documentationdims(n)
-> ArrayFire Documentation
Result:
- of dims()
: array's dimensions info in a Dim4 object instance
- of dims(n)
: size of the specified dimension
numdims()
numdims()
-> ArrayFire Documentation
Result: number of dimensions of the array
numDims()
alias of numdims
bytes()
bytes()
-> ArrayFire Documentation
Result: size of the array in bytes
as()
Converts the array into another type.
as(type)
-> ArrayFire Documentation
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())`
copy()
-> ArrayFire Documentation
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
is<anything>
() -> ArrayFire Documentation
Result: actual type info (Boolean)
eval()
eval()
-> ArrayFire Documentation
Evaluate any JIT expressions to generate data for the array.
Indexing Operations
at()
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
- null: means
- def: Row|Rows|Col|Cols|Slice|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.
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.
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.
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
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
- null: means
- def: Row|Rows|Col|Cols|Slice|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
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
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