A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
dot
ArrayFire Functions | ArrayFire Functions by Category » Linear Algebra » BLAS operations

## Functions
template<typename T >
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 | 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.
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.

## 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] | out | dot product of `lhs` and `rhs`
  [in] | lhs | input array on the left-hand side
  [in] | rhs | input array on the right-hand side
  [in] | optLhs | `lhs` options, only AF_MAT_NONE and AF_MAT_CONJ are supported
  [in] | optRhs | `rhs` 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] | real | real component of the dot product
  [out] | imag | imaginary component of the dot product
  [in] | lhs | input array on the left-hand side
  [in] | rhs | input array on the right-hand side
  [in] | optLhs | `lhs` options, only AF_MAT_NONE and AF_MAT_CONJ are supported
  [in] | optRhs | `rhs` 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]

template<typename T >

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));
af::array
A multi dimensional data container.
Definition array.h:37
af::dot
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.
af::randu
AFAPI array randu(const dim4 &dims, const dtype ty, randomEngine &r)
C++ Interface to create an array of random numbers uniformly distributed.
af_print
#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

  T | type of the output

Parameters

  [in] | lhs | input array on the left-hand side
  [in] | rhs | input array on the right-hand side
  [in] | optLhs | `lhs` options, only AF_MAT_NONE and AF_MAT_CONJ are supported
  [in] | optRhs | `rhs` 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 )