1#ifndef RIVET_MATH_VECTORN
2#define RIVET_MATH_VECTORN
4#include "Rivet/Math/MathConstants.hh"
5#include "Rivet/Math/MathUtils.hh"
7#include "Rivet/Math/eigen3/Dense"
26 friend Vector<M> multiply(
const Matrix<M>& a,
const Vector<M>& b);
32 : _vec(EVector::Zero()) { }
34 const double& get(
const size_t index)
const {
36 throw std::runtime_error(
"Tried to access an invalid vector index.");
43 double& get(
const size_t index) {
45 throw std::runtime_error(
"Tried to access an invalid vector index.");
63 Vector<N>&
set(
const size_t index,
const double value) {
65 throw std::runtime_error(
"Tried to access an invalid vector index.");
74 constexpr size_t size()
const {
79 bool isZero(
double tolerance = 1
E-5)
const {
80 for (
size_t i = 0; i < N; ++i) {
90 for (
size_t i = 0; i <
size(); ++i) {
91 const double element = get(i);
92 mod2 += element * element;
100 const double norm =
mod2();
113 return _vec == a._vec;
116 bool operator!=(
const Vector<N>& a)
const {
117 return _vec != a._vec;
137 using EVector = RivetEigen::Matrix<double, N, 1>;
151 std::ostringstream out;
153 for (
size_t i = 0; i < v.
size(); ++i) {
154 out << (fabs(v[i]) < 1
E-30 ? 0.0 : v[i]);
155 if (i < v.
size() - 1) out <<
", ";
177 for (
size_t i = 0; i < N; ++i) {
178 const double a = va.get(i);
179 const double b = vb.get(i);
189 return v.
isZero(tolerance);
General -dimensional mathematical matrix object.
Definition MatrixN.hh:30
A minimal base class for -dimensional vectors.
Definition VectorN.hh:23
double mod() const
Calculate the modulus of a vector. .
Definition VectorN.hh:99
double mod2() const
Calculate the modulus-squared of a vector. .
Definition VectorN.hh:88
RivetEigen::Matrix< double, N, 1 > EVector
Vector.
Definition VectorN.hh:137
constexpr size_t size() const
Vector dimensionality.
Definition VectorN.hh:74
Vector< N > & set(const size_t index, const double value)
Set indexed value.
Definition VectorN.hh:63
bool isZero(double tolerance=1E-5) const
Check for nullness, allowing for numerical precision.
Definition VectorN.hh:79
const double & operator[](const size_t index) const
Direct access to vector elements by index.
Definition VectorN.hh:53
double & operator[](const size_t index)
Direct access to vector elements by index.
Definition VectorN.hh:58
Vector< N > operator-() const
Invert the vector.
Definition VectorN.hh:106
double E(const ParticleBase &p)
Unbound function access to E.
Definition ParticleBaseUtils.hh:829
Definition LHCbCommon.hh:9
bool operator==(const Cut &a, const Cut &b)
Compare two cuts for equality, forwards to the cut-specific implementation.
Definition Cuts.hh:45
std::ostream & operator<<(std::ostream &os, const AnalysisInfo &ai)
Stream an AnalysisInfo as a text description.
Definition AnalysisInfo.hh:463
std::enable_if_t< std::is_floating_point_v< NUM >, bool > isZero(NUM val, double tolerance=1e-8)
Compare a number to zero.
Definition MathUtils.hh:23
std::string toString(const AnalysisInfo &ai)
String representation.
std::enable_if_t< std::is_arithmetic_v< N1 > &&std::is_arithmetic_v< N2 > &&(std::is_floating_point_v< N1 >||std::is_floating_point_v< N2 >), bool > fuzzyEquals(N1 a, N2 b, double tolerance=1e-5)
Compare two numbers for equality with a degree of fuzziness.
Definition MathUtils.hh:66