the C interface for sum More...

All Elements

Parameters
[out]countScalar and on host
[in]numelThe number of elements in the vector.
[in]matThe input stream
afError af_sum_vector_S (float *h_dst, unsigned numel, const float *d_src)
 sum The value of a single precision vector More...
 
afError af_sum_vector_B (float *h_dst, unsigned numel, const bool *d_src)
 sum The value of a boolean vector More...
 
afError af_sum_vector_I (int *h_dst, unsigned numel, const int *d_src)
 sum The value of a 32-bit signed integer vector More...
 
afError af_sum_vector_U (unsigned *h_dst, unsigned numel, const unsigned *d_src)
 sum The value of a 32-bit unsigned integer vector More...
 
afError af_sum_vector_C (cfloat *h_dst, unsigned numel, const cfloat *d_src)
 sum The value of a single precision, complex vector More...
 
afError af_sum_vector_D (double *h_dst, unsigned numel, const double *d_src)
 sum The value of a double precision vector More...
 
afError af_sum_vector_Z (cdouble *h_dst, unsigned numel, const cdouble *d_src)
 sum The value of a double precision, complex vector More...
 

Along a Dimension

Parameters
[out]countvector and on device
[in]numelThe number of elements in the vector.
[in]matThe input stream
[in]batchThe number of input tiles.
afError af_sum_S (float *d_dst, unsigned ndims, const unsigned *dims, const float *d_src, int dim)
 sum the value along a dimension in single precision matrix More...
 
afError af_sum_B (float *d_dst, unsigned ndims, const unsigned *dims, const bool *d_src, int dim)
 sum the value along a dimension in boolean matrix More...
 
afError af_sum_I (int *d_dst, unsigned ndims, const unsigned *dims, const int *d_src, int dim)
 sum the value along a dimension in 32-bit signed integer matrix More...
 
afError af_sum_U (unsigned *d_dst, unsigned ndims, const unsigned *dims, const unsigned *d_src, int dim)
 sum the value along a dimension in 32-bit unsigned integer matrix More...
 
afError af_sum_C (cfloat *d_dst, unsigned ndims, const unsigned *dims, const cfloat *d_src, int dim)
 sum the value along a dimension in single precision, complex matrix More...
 
afError af_sum_D (double *d_dst, unsigned ndims, const unsigned *dims, const double *d_src, int dim)
 sum the value along a dimension in double precision matrix More...
 
afError af_sum_Z (cdouble *d_dst, unsigned ndims, const unsigned *dims, const cdouble *d_src, int dim)
 sum the value along a dimension in double precision, complex matrix More...
 

Detailed Description

the C interface for sum

Sum is a reduction operation that computes the arithmetic
sum of the elements in an array.

The first sum function sums elements along a specific dimension
of the array. The defualt dimension is the first non-singleton
dimension.
array a = constant(1,5,5);
//a = 1 1 1 1 1
// = 1 1 1 1 1
// = 1 1 1 1 1
// = 1 1 1 1 1
// = 1 1 1 1 1
b = sum(a); //b = [5]
// [5]
// [5]
// [5]
// [5]

The second form of sum is templated, and returns the sum of all array elements to the host.

float hx[] = { -3, -5, 2, -9 };
array x1(2,2, hx); // x1 = -3 2
// -5 -9
printf("%g\n", sum<float>(x1)); // -15

Function Documentation

afError af_sum_vector_S ( float *  h_dst,
unsigned  numel,
const float *  d_src 
)

sum The value of a single precision vector

afError af_sum_vector_B ( float *  h_dst,
unsigned  numel,
const bool *  d_src 
)

sum The value of a boolean vector

afError af_sum_vector_I ( int *  h_dst,
unsigned  numel,
const int *  d_src 
)

sum The value of a 32-bit signed integer vector

afError af_sum_vector_U ( unsigned *  h_dst,
unsigned  numel,
const unsigned *  d_src 
)

sum The value of a 32-bit unsigned integer vector

afError af_sum_vector_C ( cfloat h_dst,
unsigned  numel,
const cfloat d_src 
)

sum The value of a single precision, complex vector

afError af_sum_vector_D ( double *  h_dst,
unsigned  numel,
const double *  d_src 
)

sum The value of a double precision vector

afError af_sum_vector_Z ( cdouble h_dst,
unsigned  numel,
const cdouble d_src 
)

sum The value of a double precision, complex vector

afError af_sum_S ( float *  d_dst,
unsigned  ndims,
const unsigned *  dims,
const float *  d_src,
int  dim 
)

sum the value along a dimension in single precision matrix

afError af_sum_B ( float *  d_dst,
unsigned  ndims,
const unsigned *  dims,
const bool *  d_src,
int  dim 
)

sum the value along a dimension in boolean matrix

afError af_sum_I ( int *  d_dst,
unsigned  ndims,
const unsigned *  dims,
const int *  d_src,
int  dim 
)

sum the value along a dimension in 32-bit signed integer matrix

afError af_sum_U ( unsigned *  d_dst,
unsigned  ndims,
const unsigned *  dims,
const unsigned *  d_src,
int  dim 
)

sum the value along a dimension in 32-bit unsigned integer matrix

afError af_sum_C ( cfloat d_dst,
unsigned  ndims,
const unsigned *  dims,
const cfloat d_src,
int  dim 
)

sum the value along a dimension in single precision, complex matrix

afError af_sum_D ( double *  d_dst,
unsigned  ndims,
const unsigned *  dims,
const double *  d_src,
int  dim 
)

sum the value along a dimension in double precision matrix

afError af_sum_Z ( cdouble d_dst,
unsigned  ndims,
const unsigned *  dims,
const cdouble d_src,
int  dim 
)

sum the value along a dimension in double precision, complex matrix