Vector Class Template Reference

#include <VectorN.hh>

Inheritance diagram for Vector:

Inheritance graph
[legend]

List of all members.


Detailed Description

template<size_t N>
class Rivet::Vector< N >

A minimal base class for $ N $-dimensional vectors.

Definition at line 23 of file VectorN.hh.


Public Member Functions

 Vector ()
 Vector (const Vector< N > &other)
const double & get (const size_t index) const
const double & operator[] (const size_t index) const
 Direct access to vector elements by index.
double & operator[] (const size_t index)
 Direct access to vector elements by index.
Vector< N > & set (const size_t index, const double value)
 Set indexed value.
size_t size () const
 Vector dimensionality.
bool isZero (double tolerance=1E-5) const
 Check for nullness, allowing for numerical precision.
double mod2 () const
 Calculate the modulus-squared of a vector. $ \sum_{i=1}^N x_i^2 $.
double mod () const
 Calculate the modulus of a vector. $ \sqrt{\sum_{i=1}^N x_i^2} $.
Vector< N > operator- () const
 Invert the vector.
bool operator== (const Vector< N > &a) const
bool operator!= (const Vector< N > &a) const
bool operator< (const Vector< N > &a) const
bool operator<= (const Vector< N > &a) const
bool operator> (const Vector< N > &a) const
bool operator>= (const Vector< N > &a) const

Protected Member Functions

double & get (const size_t index)

Protected Attributes

Eigen::Vector< double, N > _vec
 Vector.

Friends

template<size_t M>
Vector< M > multiply (const Matrix< M > &a, const Vector< M > &b)

Constructor & Destructor Documentation

Vector (  )  [inline]

Definition at line 28 of file VectorN.hh.

00028 { _vec.loadZero(); }

Vector ( const Vector< N > &  other  )  [inline]

Definition at line 30 of file VectorN.hh.

00031       : _vec(other._vec) { }


Member Function Documentation

const double& get ( const size_t  index  )  const [inline]

Definition at line 33 of file VectorN.hh.

Referenced by Rivet::fuzzyEquals(), Matrix< 4 >::setColumn(), Matrix< 4 >::setRow(), and Vector3::Vector3().

00033                                                 {
00034       if (index >= N) {
00035         throw std::runtime_error("Tried to access an invalid vector index.");
00036       } else {
00037         return _vec(index);
00038       }
00039     }

const double& operator[] ( const size_t  index  )  const [inline]

Direct access to vector elements by index.

Definition at line 42 of file VectorN.hh.

00042                                                        {
00043       return get(index);
00044     }

double& operator[] ( const size_t  index  )  [inline]

Direct access to vector elements by index.

Definition at line 47 of file VectorN.hh.

00047                                            {
00048       return get(index);
00049     }

Vector<N>& set ( const size_t  index,
const double  value 
) [inline]

Set indexed value.

Definition at line 52 of file VectorN.hh.

Referenced by Rivet::diagonalize(), Matrix< 4 >::getColumn(), and Matrix< 4 >::getRow().

00052                                                            {
00053       if (index >= N) {
00054         throw std::runtime_error("Tried to access an invalid vector index.");
00055       } else {
00056         _vec[index] = value;
00057       }
00058       return *this;
00059     }

size_t size (  )  const [inline]

Vector dimensionality.

Definition at line 62 of file VectorN.hh.

Referenced by Vector< 4 >::mod2(), and Rivet::toString().

00062                         {
00063       return N;
00064     }

bool isZero ( double  tolerance = 1E-5  )  const [inline]

Check for nullness, allowing for numerical precision.

Definition at line 67 of file VectorN.hh.

Referenced by LorentzTransform::boost(), and Rivet::isZero().

00067                                              {
00068       for (size_t i=0; i < N; ++i) {
00069         if (! Rivet::isZero(_vec[i], tolerance) ) return false;
00070       }
00071       return true;
00072     }

double mod2 (  )  const [inline]

Calculate the modulus-squared of a vector. $ \sum_{i=1}^N x_i^2 $.

Definition at line 76 of file VectorN.hh.

Referenced by Vector< 4 >::mod(), Rivet::mod2(), Vector< 4 >::mod2(), Rivet::mod2Cmp(), and LorentzTransform::setBoost().

00076                         {
00077       double mod2 = 0.0;
00078       for (size_t i = 0; i < size(); ++i) {
00079         const double element = get(i);
00080         mod2 += element*element;
00081       }
00082       return mod2;
00083     }

double mod (  )  const [inline]

Vector<N> operator- (  )  const [inline]

Invert the vector.

Reimplemented in Vector3, and FourVector.

Definition at line 94 of file VectorN.hh.

00094                                 {
00095       Vector<N> rtn;
00096       rtn._vec = -_vec;
00097       return rtn;
00098     }

bool operator== ( const Vector< N > &  a  )  const [inline]

Definition at line 100 of file VectorN.hh.

00100                                               {
00101       return _vec == a._vec;
00102     }

bool operator!= ( const Vector< N > &  a  )  const [inline]

Definition at line 104 of file VectorN.hh.

00104                                               {
00105       return _vec != a._vec;
00106     }

bool operator< ( const Vector< N > &  a  )  const [inline]

Definition at line 108 of file VectorN.hh.

00108                                              {
00109       return _vec < a._vec;
00110     }

bool operator<= ( const Vector< N > &  a  )  const [inline]

Definition at line 112 of file VectorN.hh.

00112                                               {
00113       return _vec <= a._vec;
00114     }

bool operator> ( const Vector< N > &  a  )  const [inline]

Definition at line 116 of file VectorN.hh.

00116                                              {
00117       return _vec > a._vec;
00118     }

bool operator>= ( const Vector< N > &  a  )  const [inline]

Definition at line 120 of file VectorN.hh.

00120                                               {
00121       return _vec >= a._vec;
00122     }

double& get ( const size_t  index  )  [inline, protected]

Definition at line 126 of file VectorN.hh.

00126                                     {
00127       if (index >= N) {
00128         throw std::runtime_error("Tried to access an invalid vector index.");
00129       } else {
00130         return _vec(index);
00131       }
00132     }


Friends And Related Function Documentation

Vector<M> multiply ( const Matrix< M > &  a,
const Vector< M > &  b 
) [friend]


Member Data Documentation

Eigen::Vector<double,N> _vec [protected]


The documentation for this class was generated from the following file: