rivet is hosted by Hepforge, IPPP Durham

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

#include <VectorN.hh>

Inheritance diagram for Vector< N >:

List of all members.

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)

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.


Constructor & Destructor Documentation

Vector ( ) [inline]

Definition at line 28 of file VectorN.hh.

{ _vec.loadZero(); }
Vector ( const Vector< N > &  other) [inline]

Definition at line 30 of file VectorN.hh.

      : _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().

                                                {
      if (index >= N) {
        throw std::runtime_error("Tried to access an invalid vector index.");
      } else {
        return _vec(index);
      }
    }
double& get ( const size_t  index) [inline, protected]

Definition at line 126 of file VectorN.hh.

                                    {
      if (index >= N) {
        throw std::runtime_error("Tried to access an invalid vector index.");
      } else {
        return _vec(index);
      }
    }
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().

                                             {
      for (size_t i=0; i < N; ++i) {
        if (! Rivet::isZero(_vec[i], tolerance) ) return false;
      }
      return true;
    }
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 ATLAS_2012_I1091481::getPionEnergy(), Vector< 4 >::mod(), Vector< 4 >::mod2(), Rivet::mod2(), Rivet::mod2Cmp(), and LorentzTransform::setBoost().

                        {
      double mod2 = 0.0;
      for (size_t i = 0; i < size(); ++i) {
        const double element = get(i);
        mod2 += element*element;
      }
      return mod2;
    }
bool operator!= ( const Vector< N > &  a) const [inline]

Definition at line 104 of file VectorN.hh.

                                              {
      return _vec != a._vec;
    }
Vector<N> operator- ( ) const [inline]

Invert the vector.

Reimplemented in FourMomentum, Vector3, and FourVector.

Definition at line 94 of file VectorN.hh.

                                {
      Vector<N> rtn;
      rtn._vec = -_vec;
      return rtn;
    }
bool operator< ( const Vector< N > &  a) const [inline]

Definition at line 108 of file VectorN.hh.

                                             {
      return _vec < a._vec;
    }
bool operator<= ( const Vector< N > &  a) const [inline]

Definition at line 112 of file VectorN.hh.

                                              {
      return _vec <= a._vec;
    }
bool operator== ( const Vector< N > &  a) const [inline]

Definition at line 100 of file VectorN.hh.

                                              {
      return _vec == a._vec;
    }
bool operator> ( const Vector< N > &  a) const [inline]

Definition at line 116 of file VectorN.hh.

                                             {
      return _vec > a._vec;
    }
bool operator>= ( const Vector< N > &  a) const [inline]

Definition at line 120 of file VectorN.hh.

                                              {
      return _vec >= a._vec;
    }
const double& operator[] ( const size_t  index) const [inline]

Direct access to vector elements by index.

Definition at line 42 of file VectorN.hh.

                                                       {
      return get(index);
    }
double& operator[] ( const size_t  index) [inline]

Direct access to vector elements by index.

Definition at line 47 of file VectorN.hh.

                                           {
      return get(index);
    }
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(), EigenSystem< N >::getDiagVector(), and Matrix< 4 >::getRow().

                                                           {
      if (index >= N) {
        throw std::runtime_error("Tried to access an invalid vector index.");
      } else {
        _vec[index] = value;
      }
      return *this;
    }
size_t size ( ) const [inline]

Vector dimensionality.

Definition at line 62 of file VectorN.hh.

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

                        {
      return N;
    }

Friends And Related Function Documentation

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

Member Data Documentation


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