| 22 | #include "blas.h" |
| 23 | |
| 24 | double vectornorm2(const ap::real_1d_array& x, int i1, int i2) |
| 25 | { |
| 26 | double result; |
| 27 | int n; |
| 28 | int ix; |
| 29 | double absxi; |
| 30 | double scl; |
| 31 | double ssq; |
| 32 | |
| 33 | n = i2-i1+1; |
| 34 | if( n<1 ) |
| 35 | { |
| 36 | result = 0; |
| 37 | return result; |
| 38 | } |
| 39 | if( n==1 ) |
| 40 | { |
| 41 | result = fabs(x(i1)); |
| 42 | return result; |
| 43 | } |
| 44 | scl = 0; |
| 45 | ssq = 1; |
| 46 | for(ix = i1; ix <= i2; ix++) |
| 47 | { |
| 48 | if( ap::fp_neq(x(ix),0) ) |
| 49 | { |
| 50 | absxi = fabs(x(ix)); |
| 51 | if( ap::fp_less(scl,absxi) ) |
| 52 | { |
| 53 | ssq = 1+ssq*ap::sqr(scl/absxi); |
| 54 | scl = absxi; |
| 55 | } |
| 56 | else |
| 57 | { |
| 58 | ssq = ssq+ap::sqr(absxi/scl); |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | result = scl*sqrt(ssq); |
| 63 | return result; |
| 64 | } |
| 65 | |
| 66 | |
| 67 | int vectoridxabsmax(const ap::real_1d_array& x, int i1, int i2) |
nothing calls this directly
no outgoing calls
no test coverage detected