Compute the product of elements of an array. More...

Modules

 mul
 The C++ interface for mul.
 
 af_mul
 the C interface for mul
 

Detailed Description

Compute the product of elements of an array.

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