13 enum STANDARD_BASIS
{ei
}; //Allows instantiation of particular vectors of Rn
15 //Constructors and destructors
17 Vector (const unsigned int dimension
);
18 Vector (std::vector
<double> components
);
19 /*Can throw logic_error exceptions
20 /!\ Be aware that the index 'i' is understood as a mathematical index, not a general C++ index /!\*/
21 Vector (const unsigned int dimension
, STANDARD_BASIS aVector
, const unsigned int i
);
22 Vector (const Vector
&otherVector
);
24 //Accessors and modifiers
25 const std::vector
<double>& components () const {return m_components
;}
26 void setComponents (const std::vector
<double> &newVector
) {m_components
= newVector
;}
27 unsigned int dimension () const;
31 void operator = (const Vector
&otherVector
);
33 //All operators can throw logic_error exceptions
35 Vector
operator + (const Vector
&otherVector
) const;
36 Vector
& operator += (const Vector
&otherVector
);
38 Vector
operator - (const Vector
&otherVector
) const;
39 Vector
& operator -= (const Vector
&otherVector
);
41 Vector
operator * (const double scalar
) const;
42 Vector
& operator *= (const double scalar
);
43 double operator * (const Vector
&otherVector
) const; //Dot product of two vectors
45 //Can throw domain_error exceptions
46 Vector
operator / (const double scalar
) const;
47 Vector
& operator /= (const double scalar
);
49 Vector
operator ^ (const Vector
&otherVector
) const;
51 Vector
operator == (const Vector
&otherVector
) const;
52 Vector
operator != (const Vector
&otherVector
) const;
54 /*Can throw out_of_range exceptions
55 /!\ index is understood as a mathematical index, not as a general C++ index /!\
56 See method 'at()' for the C++ like getter*/
57 double operator [] (const double index
) const;
58 double& operator [] (const double index
);
60 /*Can throw out_of_range exception
62 double at (const unsigned int index
) const;
63 double& at (const unsigned int index
);
65 double dotProduct (const Vector
&otherVector
) const; //Calculate Euclidea standard product
68 void addComponent (double value
);
69 double magnitude () const;
70 double magnitude2 () const;
75 std::vector
<double> m_components
;