The C++ interface for mul. More...

array mul (const array &input, int dim=-1)
 
template<typename ty >
ty mul (const array &input)
 

Detailed Description

The C++ interface for mul.

The first mul function computes the product of elements
of the array along a particular dimension. This function
returns an array that is the size of the dimension specified
by the parameter.
float x[] = {5,1,7,3,2,5};
array input(2,3,x); // [5 7 2]
// [1 3 5]
// Along first non-singleton dimension (down columns)
array output = mul(input);
print(output); //output = [5 21 10]
//Along dimension 1 (rows)
array output = mul(input, 1);
print(output); //output = [70]
// [15]

The second mul function computes the product of all values of an array and returns the product to host memory.

float hx[] = { -3, -5, 2, -9 };
array x1(2,2, hx); // 2x2 matrix
array x2(4,1, hx); // 4x1 vector
printf("%g,%g\n", mul<float>(x1), mul<float>(x2)); // -270,-270

Function Documentation

array af::mul ( const array &  input,
int  dim = -1 
)
Parameters
[in]input
[in]dimdimension along which to operate (-1 indicates first non-singleton dimension)
Returns
array with values multiplied along the dimension dim in the input
Examples:
examples/getting_started/integer.cpp.
ty af::mul ( const array &  input)
Parameters
[in]input
Returns
multiplication of all values in the input array