Functions to create arrays
TOC
randu()
Create a random array sampled from uniform distribution.
randu(dim0, type)
: -> ArrayFire Documentationrandu(dim0, dim1, type)
: -> ArrayFire Documentationrandu(dim0, dim1, dim2, type)
: -> ArrayFire Documentationrandu(dim0, dim1, dim2, dim3, type)
: -> ArrayFire Documentationrandu(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
)
Result: the created AFArray instance.
randU()
alias of randu()
randn()
Create a random array sampled from normal distribution.
randn(dim0, type)
: -> ArrayFire Documentationrandn(dim0, dim1, type)
: -> ArrayFire Documentationrandn(dim0, dim1, dim2, type)
: -> ArrayFire Documentationrandn(dim0, dim1, dim2, dim3, type)
: -> ArrayFire Documentationrandn(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
)
Result: the created AFArray instance.
randN()
alias of randn()
identity()
Create an identity matrix (array with diagonal values 1).
identity(dim0, type)
: -> ArrayFire Documentationidentity(dim0, dim1, type)
: -> ArrayFire Documentationidentity(dim0, dim1, dim2, type)
: -> ArrayFire Documentationidentity(dim0, dim1, dim2, dim3, type)
: -> ArrayFire Documentationidentity(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
)
Result: the created AFArray instance.
range()
Creates an array with [0, n] values along the seqDim which is tiled across other dimensions.
range(dim0, seqDim, type)
: -> ArrayFire Documentationrange(dim0, dim1, seqDim, type)
: -> ArrayFire Documentationrange(dim0, dim1, dim2, seqDim, type)
: -> ArrayFire Documentationrange(dim0, dim1, dim2, dim3, seqDim, type)
: -> ArrayFire Documentationrange(dims, seqDim, 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)
- seqDim: Number - dimension along which [0, dim[seqDim] - 1] is generated, default is -1, which means the last specified dimension
- type: value of dType - can be one of the values of dType object (eg.
dType.f32
)
Result: the created AFArray instance.
iota()
Create an sequence [0, dims.elements - 1] and modify to specified dimensions dims and then tile it according to tileDims.
iota(dims, tileDims, type)
: -> ArrayFire Documentation
Arguments:
- **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 ) |
Result: the created AFArray instance.
diag()
Extract diagonal from a matrix when extract
is set to true
.
Create a diagonal marix from input array when extract
is set to false
.
diag(in, num, extract)
: -> ArrayFire Documentation
Arguments:
- in: AFArray - input array
- num: Number - diagonal index
- extract: Boolean - when true returns an array containing diagonal of tha matrix and when false returns a matrix with in as diagonal
constant()
Create an array filled with the specified value.
constant(value, dim0, type)
constant(value, dim0, dim1, type)
constant(value, dim0, dim1, dim2, type)
constant(value, dim0, dim1, dim2, dim3, type)
constant(value, dims, type)
Arguments:
- value: Number|Complex|String
- Number: number
- Complex: complex value
- String:: number value (to workaround JavaScript inability to hold int64 values)
- 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
)
Result: the created AFArray instance.