Home
Install
Use
Develop
Support
News
Credits
hosted by
|
21template < unsigned N, typename T>
26 { for ( unsigned i=0; i<N; i++) v.x[i] = T(0.0); }
29 template< unsigned M, typename U>
37 Vector () { zero (* this); }
43 { x[0] = x0; x[1] = x1; }
46 { x[0] = x0; x[1] = x1; x[2] = x2; }
48 Vector (T x0, T x1, T x2, T x3)
49 { x[0] = x0; x[1] = x1; x[2] = x2; x[3] = x3; }
57 { for ( unsigned i=0; i<N; i++) x[i] = T(s.x[i]); return * this; }
61 { x[0] = scalar; for ( unsigned i=1; i<N; i++) x[i] = 0.0; return * this; }
65 { for ( unsigned i=0; i<N; i++) x[i] += s.x[i]; return * this; }
69 { for ( unsigned i=0; i<N; i++) x[i] -= s.x[i]; return * this; }
79 { for ( unsigned i=0; i<N; i++) x[i] *= a; return * this; }
84 { for ( unsigned i=0; i<N; i++) x[i] /= a; return * this; }
88 { for( unsigned i=0; i<N; i++) if(x[i]!=b.x[i]) return false; return true; }
114 { T r=0; for ( unsigned i=0; i<N; i++) r += a[i]*b[i]; return r; }
122 { for ( unsigned i=0; i<N; i++) s.x[i] = -s.x[i]; return s; }
133 unsigned size () const { return N; }
137 { Vector v; v[i] = 1.0; return v; }
147 for ( unsigned i=0; i<3; i++) {
148 j = (i+1)%3; k = (i+2)%3;
149 result[i] = a[j]*b[k] - a[k]*b[j];
162T normsq ( const std::complex<T>& v)
167template < typename T, typename U=T>
174template < unsigned N, typename T>
177 T sum = normsq(v[0]);
178 for ( unsigned i=1; i < N; i++)
184template < unsigned N, template< typename T> class V, typename U >
185U normsq ( const Vector< N, V<U> >& v)
187 U sum = normsq(v[0]);
188 for ( unsigned i=1; i < N; i++)
194template < unsigned N, typename T>
197 return sqrt(normsq(v));
201template< unsigned N, typename T>
205 for ( unsigned i=0; i < N; i++)
206 result[i] = input[i].real();
210template< unsigned N, typename T>
214 for ( unsigned i=0; i < N; i++)
215 result[i] = input[i].imag();
219template< unsigned N, typename T>
223 for ( unsigned i=0; i < N; i++)
224 result[i] = std::conj(input[i]);
230 template< unsigned N, typename T>
231 bool finite ( const Vector< N, T>& input)
233 for ( unsigned i=0; i < N; i++)
234 if (!true_math::finite( input[i] ))
245 static inline unsigned ndim () { return N; }
246 static inline T& element (Vector<N,T>& t, unsigned i)
248 static inline const T element ( const Vector<N,T>& t, unsigned i)
253template< unsigned N, typename T>
254std::ostream& operator<< (std::ostream& ostr, const Vector<N,T>& v)
257 for ( unsigned i=1; i<N; i++)
262template< unsigned N, typename T>
263std::istream& operator >> (std::istream& is, Vector<N,T>& v)
269 is.setstate(std::istream::failbit);
275 for ( unsigned i=1; i<N; i++)
279 is.setstate(std::istream::failbit);
287 is.setstate(std::istream::failbit);
bool operator!=(const Vector &b) const
Vector & operator+=(const Vector &s)
friend const friend Vector operator+(Vector a, const Vector< N, U > &b)
Vector & operator-=(const Vector &s)
T & operator[](unsigned n)
friend const friend Vector operator*(Vector a, T c)
static const Vector basis(unsigned i)
friend const friend Vector operator-(Vector a, const Vector< N, U > &b)
Vector & operator/=(const U &a)
bool operator==(const Vector &b) const
friend const friend Vector operator/(Vector a, T c)
Vector & operator*=(const U &a)
Vector & operator=(const Vector< N, U > &s)
Generated using doxygen 1.14.0
|