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 CMS_2015_I1385107::analyze(), CMS_2011_S9120041::analyze(), PDG_TAUS::analyzeRadiativeDecay(), LorentzTransform::boost(), and Rivet::isZero().

                                             {
      for (size_t i=0; i < N; ++i) {
        if (! Rivet::isZero(_vec[i], tolerance) ) return false;
      }
      return true;
    }
double mod ( ) const [inline]

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

Definition at line 87 of file VectorN.hh.

Referenced by FParameter::_calcFParameter(), Sphericity::_calcSphericity(), Spherocity::_calcSpherocity(), Thrust::_calcThrust(), D0_1996_S3214044::_fourJetAnalysis(), D0_1996_S3214044::_threeJetAnalysis(), BABAR_2003_I593379::analyze(), CLEO_2004_S5809304::analyze(), BELLE_2001_S4598261::analyze(), ARGUS_1993_S2653028::analyze(), OPAL_1994_S2927284::analyze(), BELLE_2008_I786560::analyze(), SLD_2004_S5693039::analyze(), OPAL_1998_S3780481::analyze(), SLD_1999_S3743934::analyze(), OPAL_1995_S3198391::analyze(), OPAL_1997_S3608263::analyze(), ARGUS_1993_S2669951::analyze(), ALEPH_2002_S4823664::analyze(), ALICE_2012_I1181770::analyze(), OPAL_1996_S3257789::analyze(), OPAL_1998_S3702294::analyze(), DELPHI_1999_S3960137::analyze(), ATLAS_2014_I1282441::analyze(), BABAR_2007_S7266081::analyze(), DELPHI_1995_S3137023::analyze(), ATLAS_2010_CONF_2010_049::analyze(), OPAL_1998_S3749908::analyze(), OPAL_1997_S3396100::analyze(), ATLAS_2014_I1298811::analyze(), ATLAS_2014_I1298023::analyze(), ARGUS_1993_S2789213::analyze(), LHCB_2014_I1281685::analyze(), D0_2004_S5992206::analyze(), ATLAS_2012_I1183818::analyze(), MC_ZZINC::analyze(), MC_WWINC::analyze(), TASSO_1990_S2148048::analyze(), LHCB_2012_I1119400::analyze(), MC_TTBAR::analyze(), MC_SUSY::analyze(), ALEPH_1996_S3486095::analyze(), ALEPH_2004_S5765862::analyze(), DELPHI_1996_S3430090::analyze(), LorentzTransform::beta(), LorentzTransform::boost(), Hemispheres::calc(), Rivet::cmpMomByAscP(), Rivet::cmpMomByP(), MissingMomentum::missingEt(), FoxWolframMoments::project(), WFinder::project(), and LorentzTransform::setBoost().

                       {
      const double norm = mod2();
      assert(norm >= 0);
      return sqrt(norm);
    }
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::mod2Cmp(), LorentzTransform::setBoost(), and MissingMomentum::visibleMomentum().

                        {
      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, FourVector, and Vector3.

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: