Do more. Code less. Free software for GPU computing.
<scroll to top>
Functions

Matrix multiply, inner and outer dot products

Linear Algebra

Functions

array operator* (const array &rhs) const
 Multiply two matrices.
template<typename ty >
ty inner (const array &x, const array &y)
 Inner (scalar) product between two vectors.
array inner (const array &X, const array &Y, int dim=-1)
 Dot product along a dimension.

array dot (const array &, const double)
array dot (const double, const array &)
array dot (const array &, const array &)

Function Documentation

array af::dot ( const array &  ,
const double   
)

matrix multiply

array operator* ( const array rhs) const [inline, inherited]

Multiply two matrices.

Use A*B to multiply two matrices (or a scalar and a matrix).

       array A = randu(3,4), B = randu(4,5);
       printf(A * B); // 3x5 matrix

In version v1.0, the * operator defaults to matrix multiply (see dot()), but you can change this default behavior to elementwise (see mul) via macros before including arrayfire.h:

       #define AF_TIMES_ELEMENTWISE // operator*() now defaults to elementwise multiply
       #include <arrayfire.h>
       ...
       array A = randu(3,4), B = randu(3,4), C = randu(4,5);
       printf(A * B); // 3x4 matrix
       // printf(A * C); // failure: dimension mismatch: 3x4 * 4x5

In the upcoming version v1.1, the default behavior will change to be elementwise multiply and the macro AF_TIMES_MATMUL will toggle back to matrix multiply. This transition will be noted in the v1.1 release notes at that time.

See also:
mul()
ty af::inner ( const array &  x,
const array &  y 
)

Inner (scalar) product between two vectors.

Parameters:
[in]x
[in]y
Returns:
inner product
See also:
dot
array af::inner ( const array &  X,
const array &  Y,
int  dim = -1 
)

Dot product along a dimension.

Parameters:
[in]X
[in]Y
[in]dimdimension along which to operate (-1 indicates first nonsingleton dimension)
Returns:
array of collapsed dimension from product
array af::dot ( const double  ,
const array &   
)
array af::dot ( const array &  ,
const array &   
)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines