36     inline Vector4D ( 
const float * v) : x((S)v[0]), y((S)v[1]), z((S)v[2]), t((S)v[3]) {}
    39     inline Vector4D ( 
const double * v) : x((S)v[0]), y((S)v[1]), z((S)v[2]), t((S)v[3]) {}
    42     inline Vector4D ( S v) : x(v), y(v), z(v), t(v) {}
    45     inline Vector4D ( S vx, S vy, S vz, S vw) : x(vx), y(vy), z(vz), t(vw) {}
   138         return x==0 && y==0 && z==0 && t==0;
   187     return Vector4D<S> ( v1.x+v2.x, v1.y+v2.y, v1.z+v2.z, v1.t+v2.t );
   190 template<
class S, 
class S2> 
   195 template<
class S, 
class S2> 
   203     return Vector4D<S> ( v1.x-v2.x, v1.y-v2.y, v1.z-v2.z, v1.t-v2.t );
   206 template<
class S, 
class S2> 
   211 template<
class S, 
class S2>
   219     return Vector4D<S> ( v1.x*v2.x, v1.y*v2.y, v1.z*v2.z, v1.t*v2.t );
   222 template<
class S, 
class S2>
   224     return Vector4D<S> ( v.x*s, v.y*s, v.z*s , v.t*s );
   227 template<
class S, 
class S2> 
   235     return Vector4D<S> ( v1.x/v2.x, v1.y/v2.y, v1.z/v2.z, v1.t/v2.t );
   238 template<
class S, 
class S2>
   243 template<
class S, 
class S2> 
   251     return s1.x == s2.x && s1.y == s2.y && s1.z == s2.z && s1.t == s2.t;
   257     return s1.x != s2.x || s1.y != s2.y || s1.z != s2.z || s1.t != s2.t;
   267     return t.x*v.x + t.y*v.y + t.z*v.z + t.t*v.t;    
   284     S l = v.x*v.x + v.y*v.y + v.z*v.z + v.t*v.t;
   285     return ( fabs ( l-1. ) < VECTOR_EPSILON*VECTOR_EPSILON ) ? 1. : sqrt ( l );
   291     return v.x*v.x + v.y*v.y + v.z*v.z + v.t*v.t;
   297     S l = v.x*v.x + v.y*v.y + v.z*v.z + v.t*v.t;
   298     if ( fabs ( l-1. ) < VECTOR_EPSILON*VECTOR_EPSILON )
   300     else if ( l > VECTOR_EPSILON*VECTOR_EPSILON )
   302         S fac = 1./sqrt ( l );
   303         return Vector4D<S> ( v.x*fac, v.y*fac, v.z*fac , v.t*fac );
   314     S l = v.x*v.x + v.y*v.y + v.z*v.z + v.t*v.t;
   315     if ( fabs ( l-1. ) < VECTOR_EPSILON*VECTOR_EPSILON ) {
   317     } 
else if ( l > VECTOR_EPSILON*VECTOR_EPSILON ) {
   331     snprintf ( buf,256,
"[%+4.6f,%+4.6f,%+4.6f,%+4.6f]", ( 
double ) ( *
this ) [0], ( 
double ) ( *
this ) [1], ( 
double ) ( *
this ) [2] , ( 
double ) ( *
this ) [3] );
   334     return std::string ( buf );
   342 std::ostream& operator<< ( std::ostream& os, const Vector4D<S>& i ) {
   352     is >> c >> i[0] >> dummy >> i[1] >> dummy >> i[2] >> dummy >> i[3] >> c;
   367 template<
class T> 
inline Vec4 
toVec4 ( T v ) {
   368     return Vec4 ( v[0],v[1],v[2],v[3] );
   370 template<
class T> 
inline Vec4i toVec4i ( T v ) {
   371     return Vec4i( v[0],v[1],v[2],v[3] );
   379 template<> 
inline Vec4 clamp<Vec4>(
const Vec4& a, 
const Vec4& b, 
const Vec4& c) {
   380     return Vec4 ( clamp(a.x, b.x, c.x),
   381                   clamp(a.y, b.y, c.y),
   382                   clamp(a.z, b.z, c.z),
   383                   clamp(a.t, b.t, c.t) );    
   385 template<> 
inline Vec4 safeDivide<Vec4>(
const Vec4 &a, 
const Vec4& b) { 
   386     return Vec4(safeDivide(a.x,b.x), safeDivide(a.y,b.y), safeDivide(a.z,b.z), safeDivide(a.t,b.t));
   388 template<> 
inline Vec4 nmod<Vec4>(
const Vec4& a, 
const Vec4& b) {
   389     return Vec4(nmod(a.x,b.x),nmod(a.y,b.y),nmod(a.z,b.z) ,nmod(a.t,b.t) );
   397 #define BUILD_INDEX_4D \   398     Real px=pos.x-0.5f, py=pos.y-0.5f, pz=pos.z-0.5f, pt=pos.t-0.5f; \   403     Real s1 = px-(Real)xi, s0 = 1.-s1; \   404     Real t1 = py-(Real)yi, t0 = 1.-t1; \   405     Real f1 = pz-(Real)zi, f0 = 1.-f1; \   406     Real g1 = pt-(Real)ti, g0 = 1.-g1; \   408     if (px < 0.) { xi = 0; s0 = 1.0; s1 = 0.0; } \   409     if (py < 0.) { yi = 0; t0 = 1.0; t1 = 0.0; } \   410     if (pz < 0.) { zi = 0; f0 = 1.0; f1 = 0.0; } \   411     if (pt < 0.) { ti = 0; g0 = 1.0; g1 = 0.0; } \   412     if (xi >= size.x-1) { xi = size.x-2; s0 = 0.0; s1 = 1.0; } \   413     if (yi >= size.y-1) { yi = size.y-2; t0 = 0.0; t1 = 1.0; } \   414     if (zi >= size.z-1) { zi = size.z-2; f0 = 0.0; f1 = 1.0; }  \   415     if (ti >= size.t-1) { ti = size.t-2; g0 = 0.0; g1 = 1.0; }  \   417     const int sY = size.x;       419 static inline void checkIndexInterpol4d(
const Vec4i& size, 
int idx) {
   420     if (idx<0 || idx > size.x * size.y * size.z * size.t) {
   421         std::ostringstream s;
   422         s << 
"Grid interpol4d dim " << size << 
" : index " << idx << 
" out of bound ";
   428 inline T interpol4d(
const T* data, 
const Vec4i& size, 
const IndexInt sZ, 
const IndexInt sT, 
const Vec4& pos) {
   430     IndexInt idx = (IndexInt)xi + sY * (IndexInt)yi + sZ * (IndexInt)zi + sT * (IndexInt)ti;
   431     DEBUG_ONLY(checkIndexInterpol4d(size,idx)); 
   432     DEBUG_ONLY(checkIndexInterpol4d(size,idx+sX+sY+sZ+sT));
   434     return( ((data[idx]      *t0 + data[idx+sY]      *t1) * s0
   435            + (data[idx+sX]   *t0 + data[idx+sX+sY]   *t1) * s1) * f0
   436            +((data[idx+sZ]   *t0 + data[idx+sY+sZ]   *t1) * s0
   437            + (data[idx+sX+sZ]*t0 + data[idx+sX+sY+sZ]*t1) * s1) * f1 ) * g0 
   439           ( ((data[idx+sT]      *t0 + data[idx+sT+sY]      *t1) * s0
   440            + (data[idx+sT+sX]   *t0 + data[idx+sT+sX+sY]   *t1) * s1) * f0
   441            +((data[idx+sT+sZ]   *t0 + data[idx+sT+sY+sZ]   *t1) * s0
   442            + (data[idx+sT+sX+sZ]*t0 + data[idx+sT+sX+sY+sZ]*t1) * s1) * f1 ) * g1 ;
 Definition: commonkernels.h:22
Vector4D(const double *v)
Copy-Constructor. 
Definition: vector4d.h:39
const Vector4D< S > & operator-=(const Vector4D< S > &v)
Assign and sub operator. 
Definition: vector4d.h:79
Vector4D()
Constructor. 
Definition: vector4d.h:30
Vector4D< S > operator-() const
Negation operator. 
Definition: vector4d.h:127
bool isValid() const
test if nans are present 
Vector4D(S vx, S vy, S vz, S vw)
Construct a vector from three Ss. 
Definition: vector4d.h:45
Vec4 toVec4(T v)
convert to Real Vector 
Definition: vector4d.h:367
const Vector4D< S > & operator=(const Vector4D< S > &v)
Assignment operator. 
Definition: vector4d.h:50
const Vector4D< S > & operator/=(const Vector4D< S > &v)
Assign and div operator. 
Definition: vector4d.h:111
std::string toString() const
debug output vector to a string 
Definition: vector4d.h:329
S & operator[](unsigned int i)
access operator 
Definition: vector4d.h:142
Basic inlined vector class. 
Definition: vector4d.h:26
const Vector4D< S > & operator*=(const Vector4D< S > &v)
Assign and mult operator. 
Definition: vector4d.h:95
Vector4D(const float *v)
Copy-Constructor. 
Definition: vector4d.h:36
bool empty()
Get smallest component. 
Definition: vector4d.h:137
Vector4D(const Vector4D< S > &v)
Copy-Constructor. 
Definition: vector4d.h:33
Vector4D(S v)
Construct a vector from one S. 
Definition: vector4d.h:42
const Vector4D< S > & operator+=(const Vector4D< S > &v)
Assign and add operator. 
Definition: vector4d.h:63