7 #ifndef SRC_INCLUDE_FOURVECTOR_H_ 8 #define SRC_INCLUDE_FOURVECTOR_H_ 46 :
x_({y0, y1, y2, y3}) {}
55 :
x_({y0, vec.
x1(), vec.
x2(), vec.
x3()}) {}
69 double inline x0()
const;
71 void inline set_x0(
double t);
73 double inline x1()
const;
75 void inline set_x1(
double x);
77 double inline x2()
const;
79 void inline set_x2(
double y);
81 double inline x3()
const;
83 void inline set_x3(
double z);
108 double inline sqr()
const;
117 double inline abs()
const;
124 double inline sqr3()
const;
131 double inline abs3()
const;
285 std::array<double, 4>
x_;
314 return !(*
this == a);
318 return (
x_[0] < a.
x_[0]) && (
x_[1] < a.
x_[1]) && (
x_[2] < a.
x_[2]) &&
338 this->
x_[0] += a.
x_[0];
339 this->
x_[1] += a.
x_[1];
340 this->
x_[2] += a.
x_[2];
341 this->
x_[3] += a.
x_[3];
359 this->
x_[0] -= a.
x_[0];
360 this->
x_[1] -= a.
x_[1];
361 this->
x_[2] -= a.
x_[2];
362 this->
x_[3] -= a.
x_[3];
412 const double a_inv = 1.0 / a;
413 this->
x_[0] *= a_inv;
414 this->
x_[1] *= a_inv;
415 this->
x_[2] *= a_inv;
416 this->
x_[3] *= a_inv;
434 return x_[0] * a.
x_[0] -
x_[1] * a.
x_[1] -
x_[2] * a.
x_[2] -
x_[3] * a.
x_[3];
443 return std::sqrt(std::abs(this->
sqr()));
445 throw std::runtime_error(
446 "Absolute value of 4-vector could not be " 447 "determined, taking sqrt of negative value.");
465 #endif // SRC_INCLUDE_FOURVECTOR_H_ bool operator>(const FourVector &a) const
checks if for all (all four vector components are above comparison vector)
FourVector operator*=(const double &a)
multiplies by
The ThreeVector class represents a physical three-vector with the components .
constexpr double really_small
Numerical error tolerance.
double & operator[](std::size_t i)
access the component at offset i.
EnergyMomentumTensor operator/(EnergyMomentumTensor a, const double b)
Direct division operator.
std::array< double, 4 > x_
internal storage of this vector's components
double abs3() const
calculate the absolute value of the spatial three-vector
EnergyMomentumTensor operator+(EnergyMomentumTensor a, const EnergyMomentumTensor &b)
Direct addition operator.
bool operator<=(const FourVector &a) const
logical complement to FourVector::operator>(const FourVector&) const
double abs() const
calculate the lorentz invariant absolute value
const_iterator begin() const
bool operator>=(const FourVector &a) const
logical complement to FourVector::operator<(const FourVector&) const
ThreeVector threevec() const
double operator[](std::size_t i) const
const overload of the [] operator
EnergyMomentumTensor operator-(EnergyMomentumTensor a, const EnergyMomentumTensor &b)
Direct subtraction operator.
bool operator<(const FourVector &a) const
checks if for all (all four vector components are below comparison vector)
const_iterator cbegin() const
ThreeVector velocity() const
Get the velocity (3-vector divided by zero component).
const_iterator cend() const
std::array< double, 4 >::const_iterator const_iterator
iterates over the components
FourVector operator/=(const double &a)
divides by
EnergyMomentumTensor operator*(EnergyMomentumTensor a, const double b)
Direct multiplication operator.
FourVector(double y0, ThreeVector vec)
construct from time-like component and a ThreeVector.
FourVector LorentzBoost(const ThreeVector &v) const
Returns the FourVector boosted with velocity v.
FourVector operator-=(const FourVector &a)
subtracts
FourVector operator+=(const FourVector &a)
adds
double sqr() const
calculate the square of the vector (which is a scalar)
FourVector(double y0, double y1, double y2, double y3)
copy constructor
std::array< double, 4 >::iterator iterator
iterates over the components
double Dot(const FourVector &a) const
calculate the scalar product with another four-vector
double sqr3() const
calculate the square of the spatial three-vector
bool operator==(const FourVector &a) const
Check if all four vector components are almost equal (accuracy ).
std::ostream & operator<<(std::ostream &out, const ActionPtr &action)
Convenience: dereferences the ActionPtr to Action.
The FourVector class holds relevant values in Minkowski spacetime with (+, −, −, −) metric signature.
FourVector()
default constructor nulls the fourvector components
bool operator!=(const FourVector &a) const
checks inequality (logical complement to FourVector::operator==(const FourVector&) const) ...
const_iterator end() const