22 #ifndef __ND_GENERAL_VECTOR_H__
23 #define __ND_GENERAL_VECTOR_H__
25 #include "ndCoreStdafx.h"
29 T ndSQRH(
const T num,
const T den)
32 return T(sqrt(T(1.0f) + r * r));
36 T ndPythag(
const T a,
const T b)
40 return (absa > absb) ? (absa * ndSQRH(absb, absa)) : ((absb == T(0.0f) ? T(0.0f) : (absb * ndSQRH(absa, absb))));
44 T ndSign(
const T a,
const T b)
46 return (b >= T(0.0f)) ? (a >= T(0.0f) ? a : -a) : (a >= T(0.0f) ? -a : a);
51 T ndDotProduct(ndInt32 size,
const T*
const A,
const T*
const B)
54 for (ndInt32 i = 0; i < size; ++i)
56 val = val + A[i] * B[i];
57 ndAssert(ndCheckFloat(val));
63 void ndScaleSet(ndInt32 size, T*
const X,
const T*
const A, T scale)
65 for (ndInt32 i = 0; i < size; ++i)
68 ndAssert(ndCheckFloat(X[i]));
73 void ndAdd(ndInt32 size, T*
const X,
const T*
const A,
const T*
const B)
75 for (ndInt32 i = 0; i < size; ++i)
78 ndAssert(ndCheckFloat(X[i]));
83 void ndSub(ndInt32 size, T*
const X,
const T*
const A,
const T*
const B)
85 for (ndInt32 i = 0; i < size; ++i)
88 ndAssert(ndCheckFloat(X[i]));
93 void ndMul(ndInt32 size, T*
const X,
const T*
const A,
const T*
const B)
95 for (ndInt32 i = 0; i < size; ++i)
98 ndAssert(ndCheckFloat(X[i]));
103 void ndScaleAdd(ndInt32 size, T*
const X,
const T*
const A,
const T*
const B, T C)
105 for (ndInt32 i = 0; i < size; ++i)
107 X[i] = A[i] + B[i] * C;
108 ndAssert(ndCheckFloat(X[i]));
113 void ndMulAdd(ndInt32 size, T*
const X,
const T*
const A,
const T*
const B,
const T*
const C)
115 for (ndInt32 i = 0; i < size; ++i)
117 X[i] = A[i] + B[i] * C[i];
118 ndAssert(ndCheckFloat(X[i]));
123 void ndMulSub(ndInt32 size, T*
const X,
const T*
const A,
const T*
const B,
const T*
const C)
125 for (ndInt32 i = 0; i < size; ++i)
127 X[i] = A[i] - B[i] * C[i];
128 ndAssert(ndCheckFloat(X[i]));