A high-performance general-purpose compute library

Generate an identity matrix. More...

Functions

AFAPI array identity (const dim4 &dims, const dtype ty=f32)
 C++ Interface to generate an identity array. More...
 
AFAPI array identity (const dim_t d0, const dtype ty=f32)
 C++ Interface to generate a 1-D identity array. More...
 
AFAPI array identity (const dim_t d0, const dim_t d1, const dtype ty=f32)
 C++ Interface to generate a 2-D identity array. More...
 
AFAPI array identity (const dim_t d0, const dim_t d1, const dim_t d2, const dtype ty=f32)
 C++ Interface to generate a 3-D identity array. More...
 
AFAPI array identity (const dim_t d0, const dim_t d1, const dim_t d2, const dim_t d3, const dtype ty=f32)
 C++ Interface to generate a 4-D identity array. More...
 
AFAPI af_err af_identity (af_array *out, const unsigned ndims, const dim_t *const dims, const af_dtype type)
 C Interface to generate an identity array. More...
 

Detailed Description

Generate an identity matrix.

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 
)

C Interface to generate an identity array.

Parameters
[out]outidentity array
[in]ndimsnumber of dimensions
[in]dimssize
[in]typetype
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ identity() [1/5]

AFAPI array identity ( const dim4 dims,
const dtype  ty = f32 
)

C++ Interface to generate an identity array.

Parameters
[in]dimssize
[in]tytype
Returns
identity array

◆ identity() [2/5]

AFAPI array identity ( const dim_t  d0,
const dim_t  d1,
const dim_t  d2,
const dim_t  d3,
const dtype  ty = f32 
)

C++ Interface to generate a 4-D identity array.

Parameters
[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
identity array

◆ identity() [3/5]

AFAPI array identity ( const dim_t  d0,
const dim_t  d1,
const dim_t  d2,
const dtype  ty = f32 
)

C++ Interface to generate a 3-D identity array.

Parameters
[in]d0size of the first dimension
[in]d1size of the second dimension
[in]d2size of the third dimension
[in]tytype
Returns
identity array

◆ identity() [4/5]

AFAPI array identity ( const dim_t  d0,
const dim_t  d1,
const dtype  ty = f32 
)

C++ Interface to generate a 2-D identity array.

Parameters
[in]d0size of the first dimension
[in]d1size of the second dimension
[in]tytype
Returns
identity array

◆ identity() [5/5]

AFAPI array identity ( const dim_t  d0,
const dtype  ty = f32 
)

C++ Interface to generate a 1-D identity array.

Parameters
[in]d0size of the first dimension
[in]tytype
Returns
identity array