Create an identity array with diagonal values 1. More...

Functions

AFAPI array identity (const dim4 &dims, const dtype ty=f32)
 
AFAPI array identity (const dim_t d0, const dtype ty=f32)
 
AFAPI array identity (const dim_t d0, const dim_t d1, const dtype ty=f32)
 
AFAPI array identity (const dim_t d0, const dim_t d1, const dim_t d2, const dtype ty=f32)
 
AFAPI array identity (const dim_t d0, const dim_t d1, const dim_t d2, const dim_t d3, const dtype ty=f32)
 
AFAPI af_err af_identity (af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)
 

Detailed Description

Create an identity array with diagonal values 1.

array a = identity(5, 3);
// a [5 3 1 1]
// 1.0000 0.0000 0.0000
// 0.0000 1.0000 0.0000
// 0.0000 0.0000 1.0000
// 0.0000 0.0000 0.0000
// 0.0000 0.0000 0.0000

Function Documentation

◆ af_identity()

AFAPI af_err af_identity ( af_array out,
const unsigned  ndims,
const dim_t *const  dims,
const af_dtype  type 
)
Parameters
[out]outis the generated array
[in]ndimsis size of dimension array dims
[in]dimsis the array containing sizes of the dimension
[in]typeis the type of array to generate

◆ identity() [1/5]

AFAPI array af::identity ( const dim4 dims,
const dtype  ty = f32 
)
Parameters
[in]dimsis dim4 for size of all dimensions
[in]tyis the type of array to generate
Returns
an identity array of specified dimension and type
Examples
benchmarks/cg.cpp, and lin_algebra/cholesky.cpp.

◆ identity() [2/5]

AFAPI array af::identity ( const dim_t  d0,
const dim_t  d1,
const dim_t  d2,
const dim_t  d3,
const dtype  ty = f32 
)
Parameters
[in]d0is size of first dimension
[in]d1is size of second dimension
[in]d2is size of third dimension
[in]d3is size of fourth dimension
[in]tyis the type of array to generate
Returns
an identity array of specified dimension and type

◆ identity() [3/5]

AFAPI array af::identity ( const dim_t  d0,
const dim_t  d1,
const dim_t  d2,
const dtype  ty = f32 
)
Parameters
[in]d0is size of first dimension
[in]d1is size of second dimension
[in]d2is size of third dimension
[in]tyis the type of array to generate
Returns
an identity array of specified dimension and type

◆ identity() [4/5]

AFAPI array af::identity ( const dim_t  d0,
const dim_t  d1,
const dtype  ty = f32 
)
Parameters
[in]d0is size of first dimension
[in]d1is size of second dimension
[in]tyis the type of array to generate
Returns
an identity array of specified dimension and type

◆ identity() [5/5]

AFAPI array af::identity ( const dim_t  d0,
const dtype  ty = f32 
)
Parameters
[in]d0is size of first dimension
[in]tyis the type of array to generate
Returns
an identity array of specified dimension and type
afcl::array
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:327
af::identity
AFAPI array identity(const dim4 &dims, const dtype ty=f32)