A high-performance general-purpose compute library

Create an array from a scalar input value. More...

Functions

template<typename T >
array constant (T val, const dim4 &dims, const dtype ty=(af_dtype) dtype_traits< T >::ctype)
 C++ Interface to generate an array with elements set to a specified value. More...
 
template<typename T >
array constant (T val, const dim_t d0, const af_dtype ty=(af_dtype) dtype_traits< T >::ctype)
 C++ Interface to generate a 1-D array with elements set to a specified value. More...
 
template<typename T >
array constant (T val, const dim_t d0, const dim_t d1, const af_dtype ty=(af_dtype) dtype_traits< T >::ctype)
 C++ Interface to generate a 2-D array with elements set to a specified value. More...
 
template<typename T >
array constant (T val, const dim_t d0, const dim_t d1, const dim_t d2, const af_dtype ty=(af_dtype) dtype_traits< T >::ctype)
 C++ Interface to generate a 3-D array with elements set to a specified value. More...
 
template<typename T >
array constant (T val, const dim_t d0, const dim_t d1, const dim_t d2, const dim_t d3, const af_dtype ty=(af_dtype) dtype_traits< T >::ctype)
 C++ Interface to generate a 4-D array with elements set to a specified value. More...
 
AFAPI af_err af_constant (af_array *arr, const double val, const unsigned ndims, const dim_t *const dims, const af_dtype type)
 C Interface to generate an array with elements set to a specified value. More...
 
AFAPI af_err af_constant_complex (af_array *arr, const double real, const double imag, const unsigned ndims, const dim_t *const dims, const af_dtype type)
 C Interface to generate a complex array with elements set to a specified value. More...
 
AFAPI af_err af_constant_long (af_array *arr, const long long val, const unsigned ndims, const dim_t *const dims)
 C Interface to generate an array with elements set to a specified value. More...
 
AFAPI af_err af_constant_ulong (af_array *arr, const unsigned long long val, const unsigned ndims, const dim_t *const dims)
 C Interface to generate an array with elements set to a specified value. More...
 

Detailed Description

Create an array from a scalar input value.

Generate an array with elements set to a specified value.


Function Documentation

◆ af_constant()

AFAPI af_err af_constant ( af_array arr,
const double  val,
const unsigned  ndims,
const dim_t *const  dims,
const af_dtype  type 
)

C Interface to generate an array with elements set to a specified value.

Parameters
[out]arrconstant array
[in]valconstant value
[in]ndimssize of the dimension array
[in]dimsdimensions of the array to be generated
[in]typetype
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ af_constant_complex()

AFAPI af_err af_constant_complex ( af_array arr,
const double  real,
const double  imag,
const unsigned  ndims,
const dim_t *const  dims,
const af_dtype  type 
)

C Interface to generate a complex array with elements set to a specified value.

Parameters
[out]arrconstant complex array
[in]realreal constant value
[in]imagimaginary constant value
[in]ndimssize of the dimension array
[in]dimsdimensions of the array to be generated
[in]typetype, c32 or c64
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ af_constant_long()

AFAPI af_err af_constant_long ( af_array arr,
const long long  val,
const unsigned  ndims,
const dim_t *const  dims 
)

C Interface to generate an array with elements set to a specified value.

Output type is s64.

Parameters
[out]arrconstant array
[in]valconstant value
[in]ndimssize of the dimension array
[in]dimsdimensions of the array to be generated
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ af_constant_ulong()

AFAPI af_err af_constant_ulong ( af_array arr,
const unsigned long long  val,
const unsigned  ndims,
const dim_t *const  dims 
)

C Interface to generate an array with elements set to a specified value.

Output type is u64.

Parameters
[out]arrconstant array
[in]valconstant value
[in]ndimssize of the dimension array
[in]dimsdimensions of the array to be generated
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ constant() [1/5]

array constant ( val,
const dim4 dims,
const dtype  ty = (af_dtypedtype_traits< T >::ctype 
)

C++ Interface to generate an array with elements set to a specified value.

Parameters
[in]valconstant value
[in]dimsdimensions of the array to be generated
[in]tytype
Returns
constant array
Examples
financial/heston_model.cpp, graphics/gravity_sim.cpp, and unified/basic.cpp.

◆ constant() [2/5]

array constant ( val,
const dim_t  d0,
const af_dtype  ty = (af_dtypedtype_traits< T >::ctype 
)

C++ Interface to generate a 1-D array with elements set to a specified value.

Parameters
[in]valconstant value
[in]d0size of the first dimension
[in]tytype
Returns
constant 1-D array

◆ constant() [3/5]

array constant ( val,
const dim_t  d0,
const dim_t  d1,
const af_dtype  ty = (af_dtypedtype_traits< T >::ctype 
)

C++ Interface to generate a 2-D array with elements set to a specified value.

Parameters
[in]valconstant value
[in]d0size of the first dimension
[in]d1size of the second dimension
[in]tytype
Returns
constant 2-D array

◆ constant() [4/5]

array constant ( val,
const dim_t  d0,
const dim_t  d1,
const dim_t  d2,
const af_dtype  ty = (af_dtypedtype_traits< T >::ctype 
)

C++ Interface to generate a 3-D array with elements set to a specified value.

Parameters
[in]valconstant value
[in]d0size of the first dimension
[in]d1size of the second dimension
[in]d2size of the third dimension
[in]tytype
Returns
constant 3-D array

◆ constant() [5/5]

array constant ( val,
const dim_t  d0,
const dim_t  d1,
const dim_t  d2,
const dim_t  d3,
const af_dtype  ty = (af_dtypedtype_traits< T >::ctype 
)

C++ Interface to generate a 4-D array with elements set to a specified value.

Parameters
[in]valconstant value
[in]d0size of the first dimension
[in]d1size of the second dimension
[in]d2size of the third dimension
[in]d3size of the fourth dimension
[in]tytype
Returns
constant 4-D array