#include <fourvector.h>
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
The overloaded operators are built according to Andrew Koenig recommendations where the compound assignment operators is used as a base for their non-compound counterparts. This means that the operator + is implemented in terms of +=. The operator+ returns a copy of its result. + and friends are non-members, while the compound assignment counterparts, changing the left argument, are a member of the FourVector class.
Definition at line 32 of file fourvector.h.
| Public Types | |
| using | iterator = std::array< double, 4 >::iterator | 
| iterates over the components  More... | |
| using | const_iterator = std::array< double, 4 >::const_iterator | 
| iterates over the components  More... | |
| Public Member Functions | |
| FourVector () | |
| default constructor nulls the fourvector components  More... | |
| FourVector (double y0, double y1, double y2, double y3) | |
| copy constructor  More... | |
| FourVector (double y0, ThreeVector vec) | |
| construct from time-like component and a ThreeVector.  More... | |
| double & | operator[] (std::size_t i) | 
| access the component at offset i.  More... | |
| double | operator[] (std::size_t i) const | 
| const overload of the [] operator  More... | |
| double | x0 () const | 
| void | set_x0 (double t) | 
| double | x1 () const | 
| void | set_x1 (double x) | 
| double | x2 () const | 
| void | set_x2 (double y) | 
| double | x3 () const | 
| void | set_x3 (double z) | 
| ThreeVector | threevec () const | 
| ThreeVector | velocity () const | 
| Get the velocity (3-vector divided by zero component).  More... | |
| double | Dot (const FourVector &a) const | 
| calculate the scalar product with another four-vector  More... | |
| double | sqr () const | 
| calculate the square of the vector (which is a scalar)  More... | |
| double | abs () const | 
| calculate the lorentz invariant absolute value  More... | |
| double | sqr3 () const | 
| calculate the square of the spatial three-vector  More... | |
| double | abs3 () const | 
| calculate the absolute value of the spatial three-vector  More... | |
| FourVector | LorentzBoost (const ThreeVector &v) const | 
| Returns the FourVector boosted with velocity v.  More... | |
| bool | operator== (const FourVector &a) const | 
| Check if all four vector components are almost equal (accuracy \(10^{-4}\)).  More... | |
| bool | operator!= (const FourVector &a) const | 
| checks inequality (logical complement to FourVector::operator==(const FourVector&) const)  More... | |
| bool | operator< (const FourVector &a) const | 
| checks if \(x^\mu < a^\mu\) for all \(\mu\) (all four vector components are below comparison vector)  More... | |
| bool | operator> (const FourVector &a) const | 
| checks if \(x^\mu > a^\mu\) for all \(\mu\) (all four vector components are above comparison vector)  More... | |
| bool | operator<= (const FourVector &a) const | 
| logical complement to FourVector::operator>(const FourVector&) const  More... | |
| bool | operator>= (const FourVector &a) const | 
| logical complement to FourVector::operator<(const FourVector&) const  More... | |
| FourVector | operator+= (const FourVector &a) | 
| adds \(a_\mu: x_\mu^\prime = x_\mu + a_\mu\)  More... | |
| FourVector | operator-= (const FourVector &a) | 
| subtracts \(a_\mu: x_\mu^\prime = x_\mu - a_\mu\)  More... | |
| FourVector | operator*= (const double &a) | 
| multiplies by \(a: x_\mu^\prime = a \cdot x_\mu\)  More... | |
| FourVector | operator/= (const double &a) | 
| divides by \(a: x_\mu^\prime = \frac{1}{a} \cdot x_\mu\)  More... | |
| iterator | begin () | 
| iterator | end () | 
| const_iterator | begin () const | 
| const_iterator | end () const | 
| const_iterator | cbegin () const | 
| const_iterator | cend () const | 
| Private Attributes | |
| std::array< double, 4 > | x_ | 
| internal storage of this vector's components  More... | |
| using smash::FourVector::iterator = std::array<double, 4>::iterator | 
iterates over the components
Definition at line 258 of file fourvector.h.
| using smash::FourVector::const_iterator = std::array<double, 4>::const_iterator | 
iterates over the components
Definition at line 260 of file fourvector.h.
| 
 | inline | 
default constructor nulls the fourvector components
Definition at line 35 of file fourvector.h.
| 
 | inline | 
copy constructor
| [in] | y0 | The time component to be copied | 
| [in] | y1 | The x component to be copied | 
| [in] | y2 | The y component to be copied | 
| [in] | y3 | the z component to be copied | 
Definition at line 45 of file fourvector.h.
| 
 | inline | 
construct from time-like component and a ThreeVector.
| [in] | y0 | The time component to be used | 
| [in] | vec | A ThreeVector (x,y,z) to be used | 
Definition at line 54 of file fourvector.h.
| 
 | inline | 
access the component at offset i. 
This operator results in the same as using the x0()...x3() functions
| [in] | i | the index of the component to access (has to be 0,1,2 or 3) | 
Definition at line 64 of file fourvector.h.
| 
 | inline | 
const overload of the [] operator
Definition at line 66 of file fourvector.h.
| 
 | inline | 
Definition at line 290 of file fourvector.h.
| 
 | inline | 
| [in] | t | set time-like component | 
Definition at line 292 of file fourvector.h.
| 
 | inline | 
Definition at line 294 of file fourvector.h.
| 
 | inline | 
| [in] | x | set first space-like component | 
Definition at line 296 of file fourvector.h.
| 
 | inline | 
Definition at line 298 of file fourvector.h.
| 
 | inline | 
| [in] | y | set second space-like component | 
Definition at line 300 of file fourvector.h.
| 
 | inline | 
Definition at line 302 of file fourvector.h.
| 
 | inline | 
| [in] | z | set third space-like component | 
Definition at line 304 of file fourvector.h.
| 
 | inline | 
Definition at line 306 of file fourvector.h.
| 
 | inline | 
Get the velocity (3-vector divided by zero component).
Should only be used with momentum 4-vectors (not with space-time ones).
Definition at line 310 of file fourvector.h.
| 
 | inline | 
calculate the scalar product with another four-vector
| [in] | a | the FourVector to dot product with *this | 
Definition at line 433 of file fourvector.h.
| 
 | inline | 
calculate the square of the vector (which is a scalar)
Definition at line 437 of file fourvector.h.
| 
 | inline | 
calculate the lorentz invariant absolute value
Note that this will fail for space-like vectors.
Definition at line 441 of file fourvector.h.
| 
 | inline | 
calculate the square of the spatial three-vector
Definition at line 451 of file fourvector.h.
| 
 | inline | 
calculate the absolute value of the spatial three-vector
Definition at line 453 of file fourvector.h.
| FourVector smash::FourVector::LorentzBoost | ( | const ThreeVector & | v | ) | const | 
Returns the FourVector boosted with velocity v.
The current FourVector is not changed.
| v | ( \(\vec{v}\)) is a ThreeVector representing the boost velocity | 
(Notation: \(\vec{a}\) is a Three-Vector, \(a^\mu\) is a Four-Vector.)
The gamma factor is \(\gamma = 1/\sqrt{1-\vec{v}^2}\).
The time-like component of a Lorentz-boosted FourVector \(x^\mu = (x_0, x_1, x_2, x_3) = (x_0, \vec{r})\) with velocity \(\vec v\) is
\begin{eqnarray*}x^\prime_0 = \gamma \cdot (x_0 - \vec{r}\cdot\vec{v}),\end{eqnarray*}
and the space-like components i = 1, 2, 3 are:
\begin{eqnarray*} x^\prime_i &=& x_i + v_i \cdot (\frac{\gamma - 1}{\vec{v}^2} \cdot \vec{r}\cdot\vec{v} - \gamma \cdot x_0)\\ &=& x_i + v_i \cdot (\frac{\gamma^2}{\gamma + 1} \cdot \vec{r}\cdot\vec{v} - \gamma \cdot x_0)\\ &=& x_i - v_i \cdot \frac{\gamma}{\gamma + 1} \cdot (\gamma(x_0 - \vec{r}\cdot\vec{v}) + x_0 )\\ &=& x_i - v_i \cdot \frac{\gamma}{\gamma + 1} \cdot (x^\prime_0 + x_0) \end{eqnarray*}
Note: This function is equivalent to -velocity Boost from ROOT
Definition at line 16 of file fourvector.cc.
| bool smash::FourVector::operator== | ( | const FourVector & | a | ) | const | 
Check if all four vector components are almost equal (accuracy \(10^{-4}\)).
| [in] | a | The FourVector to compare to | 
Definition at line 29 of file fourvector.cc.
| 
 | inline | 
checks inequality (logical complement to FourVector::operator==(const FourVector&) const)
| [in] | a | The FourVector to compare to | 
Definition at line 313 of file fourvector.h.
| 
 | inline | 
checks if \(x^\mu < a^\mu\) for all \(\mu\) (all four vector components are below comparison vector)
| [in] | a | The FourVector to compare to | 
Definition at line 317 of file fourvector.h.
| 
 | inline | 
checks if \(x^\mu > a^\mu\) for all \(\mu\) (all four vector components are above comparison vector)
| [in] | a | The FourVector to compare to | 
Definition at line 323 of file fourvector.h.
| 
 | inline | 
logical complement to FourVector::operator>(const FourVector&) const
| [in] | a | The FourVector to compare to | 
Definition at line 328 of file fourvector.h.
| 
 | inline | 
logical complement to FourVector::operator<(const FourVector&) const
| [in] | a | The FourVector to compare to | 
Definition at line 333 of file fourvector.h.
| 
 | inline | 
adds \(a_\mu: x_\mu^\prime = x_\mu + a_\mu\)
| [in] | a | The FourVector to add | 
Definition at line 337 of file fourvector.h.
| 
 | inline | 
subtracts \(a_\mu: x_\mu^\prime = x_\mu - a_\mu\)
| [in] | a | The FourVector to subtract | 
Definition at line 358 of file fourvector.h.
| 
 | inline | 
multiplies by \(a: x_\mu^\prime = a \cdot x_\mu\)
| [in] | a | The value with which to multiply | 
Definition at line 379 of file fourvector.h.
| 
 | inline | 
divides by \(a: x_\mu^\prime = \frac{1}{a} \cdot x_\mu\)
| [in] | a | The value by which to divide | 
Definition at line 411 of file fourvector.h.
| 
 | inline | 
The iterator implements the randomIterator concept. Thus, you can simply write begin() + 1 to get an iterator that points to the 1st component. 
Definition at line 268 of file fourvector.h.
| 
 | inline | 
Definition at line 271 of file fourvector.h.
| 
 | inline | 
Definition at line 274 of file fourvector.h.
| 
 | inline | 
Definition at line 276 of file fourvector.h.
| 
 | inline | 
Definition at line 279 of file fourvector.h.
| 
 | inline | 
Definition at line 281 of file fourvector.h.
| 
 | private | 
internal storage of this vector's components
Definition at line 285 of file fourvector.h.