4#ifndef ROOT_Math_Functions
5#define ROOT_Math_Functions
61template <
class T,
unsigned int D>
class SVector;
86inline const T
Maximum(
const T& lhs,
const T& rhs) {
87 return (lhs > rhs) ? lhs : rhs;
100inline const T
Minimum(
const T& lhs,
const T& rhs) {
101 return (lhs < rhs) ? lhs : rhs;
114 return (
x-
static_cast<int>(
x) < 0.5) ?
static_cast<int>(
x) :
static_cast<int>(
x+1);
128inline int Sign(
const T&
x) {
return (
x==0)? 0 : (
x<0)? -1 : 1; }
133template <
unsigned int I>
135 template <
class A,
class B,
class T>
136 static inline T
f(
const A& lhs,
const B& rhs,
const T&
x) {
147 template <
class A,
class B,
class T>
148 static inline T
f(
const A& lhs,
const B& rhs,
const T& ) {
149 return lhs.apply(0) * rhs.apply(0);
164template <
class T,
unsigned int D>
172template <
class A,
class T,
unsigned int D>
180template <
class A,
class T,
unsigned int D>
189template <
class A,
class B,
class T,
unsigned int D>
198template <
unsigned int I>
200 template <
class A,
class T>
201 static inline T
f(
const A& rhs,
const T&
x) {
212 template <
class A,
class T>
213 static inline T
f(
const A& rhs,
const T& ) {
214 return Square(rhs.apply(0));
229template <
class T,
unsigned int D>
237template <
class A,
class T,
unsigned int D>
252template <
class T,
unsigned int D>
254 return std::sqrt(
Mag2(rhs));
260template <
class A,
class T,
unsigned int D>
262 return std::sqrt(
Mag2(rhs));
283template <
class A,
class T>
301 return std::sqrt(
Lmag2(rhs));
307template <
class A,
class T>
309 return std::sqrt(
Lmag2(rhs));
335template <
class A,
class T>
348template <
class T,
class A>
361template <
class A,
class B,
class T>
381template <
class T,
unsigned int D>
389template <
class A,
class T,
unsigned int D>
398template <
class T,
unsigned int D>
399inline VecExpr<BinaryOp<DivOp<T>, SVector<T,D>, Constant<T>, T>, T, D>
400 unit(
const SVector<T,D>& lhs) {
401 typedef BinaryOp<DivOp<T>, SVector<T,D>, Constant<T>, T> DivOpBinOp;
402 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,Constant<T>(mag(lhs))));
408template <
class A,
class T,
unsigned int D>
409inline VecExpr<BinaryOp<DivOp<T>, VecExpr<A,T,D>, Constant<T>, T>, T, D>
410 unit(
const VecExpr<A,T,D>& lhs) {
411 typedef BinaryOp<DivOp<T>, VecExpr<A,T,D>, Constant<T>, T> DivOpBinOp;
412 return VecExpr<DivOpBinOp,T,D>(DivOpBinOp(DivOp<T>(),lhs,Constant<T>(mag(lhs))));
SVector: a generic fixed size Vector class.
SVector< T, D > & Unit()
transform vector into a vector of length 1
T apply(unsigned int i) const
access the parse tree. Index starts from zero
Expression wrapper class for Vector objects.
T apply(unsigned int i) const
const T Minimum(const T &lhs, const T &rhs)
minimum.
int Sign(const T &x)
sign.
int Round(const T &x)
round.
const T Maximum(const T &lhs, const T &rhs)
maximum.
SVector< T, D > Unit(const SVector< T, D > &rhs)
Unit.
SVector< T, 3 > Cross(const SVector< T, 3 > &lhs, const SVector< T, 3 > &rhs)
Vector Cross Product (only for 3-dim vectors) .
T Lmag2(const SVector< T, 4 > &rhs)
Lmag2: Square of Minkowski Lorentz-Vector norm (only for 4D Vectors) Template to compute .
T Mag2(const SVector< T, D > &rhs)
Vector magnitude square Template to compute .
T Mag(const SVector< T, D > &rhs)
Vector magnitude (Euclidean norm) Compute : .
T Lmag(const SVector< T, 4 > &rhs)
Lmag: Minkowski Lorentz-Vector norm (only for 4-dim vectors) Length of a vector Lorentz-Vector: .
Namespace for new Math classes and functions.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.