I have a question on the implementation of the L2-norm. If I'm not mistaken, the implementation resides in the file blas.cpp and is the first function (line 24, fingerprint: double vectornorm2(const ap::real_1d_array& x, int i1, int i2).

For convenience:

**Code:**

double vectornorm2(const ap::real_1d_array& x, int i1, int i2)

{

double result;

int n;

int ix;

double absxi;

double scl;

double ssq;

n = i2-i1+1;

if( n<1 )

{

result = 0;

return result;

}

if( n==1 )

{

result = fabs(x(i1));

return result;

}

scl = 0;

ssq = 1;

for(ix = i1; ix <= i2; ix++)

{

if( ap::fp_neq(x(ix),0) )

{

absxi = fabs(x(ix));

if( ap::fp_less(scl,absxi) )

{

ssq = 1+ssq*ap::sqr(scl/absxi);

scl = absxi;

}

else

{

ssq = ssq+ap::sqr(absxi/scl);

}

}

}

result = scl*sqrt(ssq);

return result;

}

On

http://mathworld.wolfram.com/VectorNorm.html I've read that the L2-norm of a vector is a really simple function, but I can't see how the implementation executes this method.

Could anybody explain it to me?

Thanks in advance!