Level 1 BLAS functions ********************************************************************/
| 151 | Level 1 BLAS functions |
| 152 | ********************************************************************/ |
| 153 | double ap::vdotproduct(const double *v0, int stride0, const double *v1, int stride1, int n) |
| 154 | { |
| 155 | double result = 0; |
| 156 | int i; |
| 157 | if( stride0!=1 || stride1!=1 ) |
| 158 | { |
| 159 | // |
| 160 | // slow general code |
| 161 | // |
| 162 | for(i=0; i<n; i++, v0+=stride0, v1+=stride1) |
| 163 | result += (*v0)*(*v1); |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | // |
| 168 | // optimized code for stride=1 |
| 169 | // |
| 170 | int n4 = n/4; |
| 171 | int nleft = n%4; |
| 172 | for(i=0; i<n4; i++, v0+=4, v1+=4) |
| 173 | result += v0[0]*v1[0]+v0[1]*v1[1]+v0[2]*v1[2]+v0[3]*v1[3]; |
| 174 | for(i=0; i<nleft; i++, v0++, v1++) |
| 175 | result += v0[0]*v1[0]; |
| 176 | } |
| 177 | return result; |
| 178 | } |
| 179 | |
| 180 | ap::complex ap::vdotproduct(const ap::complex *v0, int stride0, const char *conj0, const ap::complex *v1, int stride1, const char *conj1, int n) |
| 181 | { |