Question

In BLAS level 1 there are *ASUM and *NRM2 that compute the L1 and L2 norms of vectors, but how does one compute the (signed) sum of a vector? There's got to be something better than filling another vector full of ones and doing a *DOT...

Was it helpful?

Solution

BLAS does not provide a horizontal sum operation like you are seeking, because it's not an operation that is frequently needed by linear algebra libraries.

Many DSP libraries do provide this operation; for example, on OS X and iOS you would use the vDSP_sve( ) function provided by the Accelerate framework. Unfortunately, available DSP libraries tend to vary a lot from platform to platform, so we would need to know more about what platform[s] you're targeting.

OTHER TIPS

One way is to use a dot product with a vector of ones, more specifically to use the cblas_caxpy function.

You can do a dot product where the second vector has an increment of zero. Using C it would be like this:

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

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

As seen in http://www.netlib.org/blas/blasqr.pdf, xAXPY supports vector summation.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top