| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- #include "types.h"
- #include <math.h>
- pyReal vecScalarProduct(const pyWord size, const pyReal * a, const pyReal * b) {
- pyWord i;
- pyReal s = 0.0;
- for(i = 0; i < size ; i ++) {
- s += a[i] * b[i];
- }
- return s;
- }
- pyReal vecNorm(const pyWord size, const pyReal * a) {
- pyWord i;
- pyReal s = 0.0;
- for(i = 0; i < size ; i ++) {
- s += a[i] * a[i];
- }
- return sqrt(s);
- }
- pyReal vecDistSquared(const pyWord size, const pyReal * a, const pyReal * b) {
- pyWord i;
- pyReal s = 0.0, d;
- for(i = 0; i < size ; i ++) {
- d = a[i] - b[i]
- s += d * d;
- }
- return s;
- }
- void vecSubst(const pyWord size, pyReal * dst, const pyReal * a, const pyReal * b ) {
- pyWord i;
- for(i = 0; i < size ; i ++) {
- dst[i] = a[i] - b[i];
- }
- }
- void vecScale(const pyWord size, pyReal * dst, pyReal s, const pyReal * a) {
- pyWord i;
- for(i = 0; i < size ; i ++) {
- dst[i] = s * a[i];
- }
- }
|