7 #ifndef SRC_INCLUDE_SMASH_FOURVECTOR_H_
8 #define SRC_INCLUDE_SMASH_FOURVECTOR_H_
47 :
x_({y0, y1, y2, y3}) {}
56 :
x_({y0, vec.
x1(), vec.
x2(), vec.
x3()}) {}
70 double inline x0()
const;
72 void inline set_x0(
double t);
74 double inline x1()
const;
76 void inline set_x1(
double x);
78 double inline x2()
const;
80 void inline set_x2(
double y);
82 double inline x3()
const;
84 void inline set_x3(
double z);
114 double inline sqr()
const;
123 double inline abs()
const;
130 double inline sqr3()
const;
137 double inline abs3()
const;
143 double inline tau()
const;
149 double inline eta()
const;
308 std::array<double, 4>
x_;
337 return !(*
this == a);
341 return (
x_[0] < a.
x_[0]) && (
x_[1] < a.
x_[1]) && (
x_[2] < a.
x_[2]) &&
361 this->
x_[0] += a.
x_[0];
362 this->
x_[1] += a.
x_[1];
363 this->
x_[2] += a.
x_[2];
364 this->
x_[3] += a.
x_[3];
382 this->
x_[0] -= a.
x_[0];
383 this->
x_[1] -= a.
x_[1];
384 this->
x_[2] -= a.
x_[2];
385 this->
x_[3] -= a.
x_[3];
435 const double a_inv = 1.0 / a;
436 this->
x_[0] *= a_inv;
437 this->
x_[1] *= a_inv;
438 this->
x_[2] *= a_inv;
439 this->
x_[3] *= a_inv;
457 return x_[0] * a.
x_[0] -
x_[1] * a.
x_[1] -
x_[2] * a.
x_[2] -
x_[3] * a.
x_[3];
466 return std::sqrt(std::abs(this->
sqr()));
468 throw std::runtime_error(
469 "Absolute value of 4-vector could not be "
470 "determined, taking sqrt of negative value.");
479 return std::sqrt(this->
x0() * this->
x0() - this->
x3() * this->
x3());
483 return std::atanh(this->
x3() / this->
x0());
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
bool operator==(const FourVector &a) const
Check if all four vector components are almost equal (accuracy ).
double & operator[](std::size_t i)
access the component at offset i.
const_iterator end() const
const_iterator cbegin() const
bool operator<(const FourVector &a) const
checks if for all (all four vector components are below comparison vector)
double abs3() const
calculate the absolute value of the spatial three-vector
bool operator>=(const FourVector &a) const
logical complement to FourVector::operator<(const FourVector&) const
void reset()
Set all the 4-vector components to 0.
FourVector operator-=(const FourVector &a)
subtracts
std::array< double, 4 >::const_iterator const_iterator
iterates over the components
double abs() const
calculate the lorentz invariant absolute value
double sqr() const
calculate the square of the vector (which is a scalar)
FourVector lorentz_boost(const ThreeVector &v) const
Returns the FourVector boosted with velocity v.
double sqr3() const
calculate the square of the spatial three-vector
FourVector operator*=(const double &a)
multiplies by
bool operator>(const FourVector &a) const
checks if for all (all four vector components are above comparison vector)
bool operator<=(const FourVector &a) const
logical complement to FourVector::operator>(const FourVector&) const
ThreeVector threevec() const
const_iterator cend() const
FourVector operator/=(const double &a)
divides by
FourVector()
default constructor nulls the fourvector components
double Dot(const FourVector &a) const
calculate the scalar product with another four-vector
std::array< double, 4 > x_
internal storage of this vector's components
std::array< double, 4 >::iterator iterator
iterates over the components
ThreeVector velocity() const
Get the velocity (3-vector divided by zero component).
FourVector(double y0, double y1, double y2, double y3)
copy constructor
FourVector(double y0, ThreeVector vec)
construct from time-like component and a ThreeVector.
FourVector operator+=(const FourVector &a)
adds
bool operator!=(const FourVector &a) const
checks inequality (logical complement to FourVector::operator==(const FourVector&) const)
double eta() const
calculate the space-time rapidity from the given four vector
double operator[](std::size_t i) const
const overload of the [] operator
const_iterator begin() const
double tau() const
calculate the proper time from the given four vector
The ThreeVector class represents a physical three-vector with the components .
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
EnergyMomentumTensor operator-(EnergyMomentumTensor a, const EnergyMomentumTensor &b)
Direct subtraction operator.
EnergyMomentumTensor operator*(EnergyMomentumTensor a, const double b)
Direct multiplication operator.
constexpr double really_small
Numerical error tolerance.
EnergyMomentumTensor operator+(EnergyMomentumTensor a, const EnergyMomentumTensor &b)
Direct addition operator.
EnergyMomentumTensor operator/(EnergyMomentumTensor a, const double b)
Direct division operator.