1 #ifndef Protium_Vector_h_
2 #define Protium_Vector_h_
12 namespace LinearAlgebra{
15 template<
typename T,
int n>
19 template<
typename T,
int n>
24 for(
int j=0; j<n;j++ ){
26 temp[index++] = T(other.
At(j) );
38 temp[0] = T(other.
At(1) );
40 temp[0] = T(other.
At(0) );
53 template <
typename T,
int n=3>
83 for(
int i=0; i<n; i++)
99 for(
int i=0; i<n; i++){
121 return sqrt( (*
this)*(*
this) );
129 T old_norm = this->
Norm();
130 if(old_norm == norm)
return norm;
131 if(old_norm ==0)
return 0;
132 for(
int i=0 ;i<n; i++ )
144 return helper.
Of( (*
this), i );
155 const T&
At(
const int& index)
const{
164 for(
int i=0; i<n;i++)
165 (*
this)[i] += rhs.At(i);
173 for(
int i=0; i<n;i++)
182 for(
int i=0; i<n;i++)
183 (*
this)[i] -=rhs.At(i);
206 for(
int i=0; i<n;i++){
207 ret+= (this->
At(i)) * (rhs.At(i) );
224 for(
int i=0; i<n;i++)
fComponents.at(i) = T(rhs.At(i) );
233 for(
int i=0; i<n;i++)
234 ret &= ( this->
At(i) == rhs.At(i) );
241 return !(*
this == rhs);
278 #endif //File Guardian
virtual T Normalize(const T &norm)
Vector< double, 10 > TenVector
Vector< double, 13 > ThirteenVector
Vector< double, 5 > FiveVector
Vector< double, 12 > TwelveVector
Vector< double, 6 > SixVector
const T operator*(const Vector< T, n > &rhs) const
Vector< T, 0 > Of(const Vector< T, 1 > &other, const int &i=0)
void Init()
Initialization of vector components to.
bool operator!=(const Vector< T, n > &rhs) const
bool operator==(const Vector< T, n > &rhs) const
#define PROTIUM_STATIC_ASSERT(expr, msg)
Use for performing static assertion.
T & operator[](const int &index)
Vector< double, 11 > ElevenVector
Vector< T, n > & operator-=(const Vector< T, n > &rhs)
const Vector< T, n > operator*(const T &rhs) const
const Vector< T, n > operator+(const Vector< T, n > &rhs) const
Vector< T, n > & operator+=(const Vector< T, n > &rhs)
Vector< double, 14 > FourteenVector
std::vector< T > fComponents
Holds the components of the vector.
Vector< double, 7 > SevenVector
Vector< double, 8 > EightVector
Vector< T, n > & operator*=(const T &rhs)
const Vector< T, n > operator-(const Vector< T, n > &rhs) const
Vector< double, 15 > FifteenVector
Vector< double, 9 > NineVector
static Vector< T, n > UnitVector(int dim=0)
Constructs a unit vector in the given dimension.
Vector< T, n > & operator=(const Vector< T, n > &rhs)
Inherit from this in order to benefit from small object allocation.
Implementation of vector to be used in Linear Algebra.
Vector< T, 1 > Of(const Vector< T, 2 > &other, const int &i=0)
const T & At(const int &index) const
Vector< double, 3 > ThreeVector
Convenience typedef of a double three vector.
Vector< T, n-1 > Of(const Vector< T, n > &other, const int &i=0)
Helper template for generating subvectors of vectors.
Vector< double, 4 > FourVector
Convenience typedef of a double four vector.
Vector< double, 2 > TwoVector
Convenience Typedef of a double twovector.
Vector< T, n-1 > GetSubVector(const int &i)