hyperpoint:: added dot_d function

This commit is contained in:
Zeno Rogue 2021-05-17 14:22:19 +02:00
parent 3a9f81a248
commit eed8ba49ab
1 changed files with 7 additions and 3 deletions

View File

@ -96,11 +96,15 @@ struct hyperpoint : array<ld, MAXMDIM> {
);
}
// inner product
inline friend ld operator | (hyperpoint h1, hyperpoint h2) {
friend ld dot_d(int c, hyperpoint h1, hyperpoint h2) {
ld sum = 0;
for(int i=0; i<MXDIM; i++) sum += h1[i] * h2[i];
for(int i=0; i<c; i++) sum += h1[i] * h2[i];
return sum;
}
// Euclidean inner product
inline friend ld operator | (hyperpoint h1, hyperpoint h2) {
return dot_d(MXDIM, h1, h2);
}
};