How to calculate the sum of a 1D array with BLAS?

BLAS level 1 has * ASUM and * NRM2, which calculate the norms of the vectors L1 and L2, but how to calculate the (signed) sum of the vector? There should be something better than filling in another vector full of it and doing * DOT ...

+3
source share
4 answers

BLAS does not provide the horizontal sum operation, as you are looking for, because it is not the operation that linear algebra libraries often need.

Many DSP libraries provide this operation; for example, on OS X and iOS, you must use the feature vDSP_sve( )provided by the Accelerate framework. Unfortunately, the available DSP libraries vary greatly from platform to platform, so we will need to learn more about which platform you are targeting.

+3
source

One way is to use a point product with a unit vector, more specifically, use the cblas_caxpy function.

+1
source

, . C :

int n;
int ix = 1;
int iy = 0;
double y = 1.0;

ddot_(&n, x, &ix, &y, &iy);
+1

Source: https://habr.com/ru/post/1771215/


All Articles