A high-performance general-purpose compute library

Compute the dot product. More...

Functions

template<typename T >
dot (const array &lhs, const array &rhs, const matProp optLhs=AF_MAT_NONE, const matProp optRhs=AF_MAT_NONE)
 C++ Interface to compute the dot product. More...
 
AFAPI array dot (const array &lhs, const array &rhs, const matProp optLhs=AF_MAT_NONE, const matProp optRhs=AF_MAT_NONE)
 
AFAPI af_err af_dot (af_array *out, const af_array lhs, const af_array rhs, const af_mat_prop optLhs, const af_mat_prop optRhs)
 C Interface to compute the dot product. More...
 
AFAPI af_err af_dot_all (double *real, double *imag, const af_array lhs, const af_array rhs, const af_mat_prop optLhs, const af_mat_prop optRhs)
 C Interface to compute the dot product, scalar result returned on host. More...
 

Detailed Description

Compute the dot product.

Scalar dot product between two vectors, also referred to as the inner product.


Function Documentation

◆ af_dot()

AFAPI af_err af_dot ( af_array out,
const af_array  lhs,
const af_array  rhs,
const af_mat_prop  optLhs,
const af_mat_prop  optRhs 
)

C Interface to compute the dot product.

Scalar dot product between two vectors, also referred to as the inner product.

// compute scalar dot product
array x = randu(100), y = randu(100);
print(dot<float>(x,y));
Parameters
[out]outdot product of lhs and rhs
[in]lhsinput array on the left-hand side
[in]rhsinput array on the right-hand side
[in]optLhslhs options, only AF_MAT_NONE and AF_MAT_CONJ are supported
[in]optRhsrhs options, only AF_MAT_NONE and AF_MAT_CONJ are supported
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ af_dot_all()

AFAPI af_err af_dot_all ( double *  real,
double *  imag,
const af_array  lhs,
const af_array  rhs,
const af_mat_prop  optLhs,
const af_mat_prop  optRhs 
)

C Interface to compute the dot product, scalar result returned on host.

Scalar dot product between two vectors. Also referred to as the inner product. Returns the result as a host scalar.

Parameters
[out]realreal component of the dot product
[out]imagimaginary component of the dot product
[in]lhsinput array on the left-hand side
[in]rhsinput array on the right-hand side
[in]optLhslhs options, only AF_MAT_NONE and AF_MAT_CONJ are supported
[in]optRhsrhs options, only AF_MAT_NONE and AF_MAT_CONJ are supported
Returns
AF_SUCCESS, if function returns successfully, else an af_err code is given

◆ dot() [1/2]

T dot ( const array lhs,
const array rhs,
const matProp  optLhs = AF_MAT_NONE,
const matProp  optRhs = AF_MAT_NONE 
)

C++ Interface to compute the dot product.

Scalar dot product between two vectors, also referred to as the inner product.

// compute scalar dot product
array x = randu(100), y = randu(100);
af_print(dot(x, y));
// OR
printf("%f\n", dot<float>(x, y));
A multi dimensional data container.
Definition: array.h:37
T dot(const array &lhs, const array &rhs, const matProp optLhs=AF_MAT_NONE, const matProp optRhs=AF_MAT_NONE)
C++ Interface to compute the dot product.
AFAPI array randu(const dim4 &dims, const dtype ty, randomEngine &r)
C++ Interface to create an array of random numbers uniformly distributed.
#define af_print(...)
Definition: util.h:148

Parameters optLhs and optRhs can only be one of AF_MAT_NONE or AF_MAT_CONJ. The conjugate dot product can be computed by setting optLhs = AF_MAT_CONJ and optRhs = AF_MAT_NONE.

This function is not supported in GFOR.

Template Parameters
Ttype of the output
Parameters
[in]lhsinput array on the left-hand side
[in]rhsinput array on the right-hand side
[in]optLhslhs options, only AF_MAT_NONE and AF_MAT_CONJ are supported
[in]optRhsrhs options, only AF_MAT_NONE and AF_MAT_CONJ are supported
Returns
dot product of lhs and rhs

◆ dot() [2/2]

AFAPI array dot ( const array lhs,
const array rhs,
const matProp  optLhs = AF_MAT_NONE,
const matProp  optRhs = AF_MAT_NONE 
)