Loading...
Searching...
No Matches
data_type.hpp
Go to the documentation of this file.
#ifndef __DATA_TYPE__
#define __DATA_TYPE__
#include <sys/types.h>
#include <type_traits>
class data_t {
public:
double E, M, E2, M2, M_abs;
data_t()
{
this->E = 0.;
this->E2 = 0.;
this->M = 0.;
this->M2 = 0.;
this->M_abs = 0.;
}
data_t(double E, double E2, double M, double M2, double M_abs)
{
this->E = E;
this->E2 = E2;
this->M = M;
this->M2 = M2;
this->M_abs = M_abs;
}
template <class T> data_t operator/(T num)
{
data_t res;
res.E = this->E / (double)num;
res.E2 = this->E2 / (double)num;
res.M = this->M / (double)num;
res.M2 = this->M2 / (double)num;
res.M_abs = this->M_abs / (double)num;
return res;
}
template <class T> data_t& operator/=(T num)
{
this->E /= (double)num;
this->E2 /= (double)num;
this->M /= (double)num;
this->M2 /= (double)num;
this->M_abs /= (double)num;
return *this;
}
template <class T> data_t operator*(T num)
{
data_t res;
res.E = this->E * (double)num;
res.E2 = this->E2 * (double)num;
res.M = this->M * (double)num;
res.M2 = this->M2 * (double)num;
res.M_abs = this->M_abs * (double)num;
return res;
}
template <class T> data_t& operator*=(T num)
{
this->E *= (double)num;
this->E2 *= (double)num;
this->M *= (double)num;
this->M2 *= (double)num;
this->M_abs *= (double)num;
return *this;
}
data_t operator+(const data_t &b)
{
data_t res;
res.E = this->E + b.E;
res.E2 = this->E2 + b.E2;
res.M = this->M + b.M;
res.M2 = this->M2 + b.M2;
res.M_abs = this->M_abs + b.M_abs;
return res;
}
data_t& operator+=(const data_t &b)
{
this->E += b.E;
this->E2 += b.E2;
this->M += b.M;
this->M2 += b.M2;
this->M_abs += b.M_abs;
return *this;
}
template <class T> void operator=(T num)
{
this->E = (double)num;
this->E2 = (double)num;
this->M = (double)num;
this->M2 = (double)num;
this->M_abs = (double)num;
}
};
#endif
data_t
Definition: data_type.hpp:18