/** @file data_type.cpp
 *
 *  @author Cory Alexander Balaton (coryab)
 *  @author Janita Ovidie Sandtrøen Willumsen (janitaws)
 *
 *  @version 1.0
 *
 *  @brief Implementation for the data_t type.
 *
 *  @bug No known bugs
 * */
#include "data_type.hpp"

template <class T>
data_t operator/(const data_t &data, T num)
{
    data_t res = data;
    res.E /= num;
    res.E2 /= num;
    res.M /= num;
    res.M2 /= num;
    res.M_abs /= num;

    return res;
}

// Explicit instantiation
template data_t operator/(const data_t &, uint);
template data_t operator/(const data_t &, ulong);
template data_t operator/(const data_t &,int);
template data_t operator/(const data_t &,double);

template <class T>
data_t& operator/=(data_t &data, T num)
{
    data.E /= num;
    data.E2 /= num;
    data.M /= num;
    data.M2 /= num;
    data.M_abs /= num;

    return data;
}

// Explicit instantiation
template data_t& operator/=(data_t &, uint);
template data_t& operator/=(data_t &, ulong);
template data_t& operator/=(data_t &,int);
template data_t& operator/=(data_t &,double);

data_t operator+(const data_t &a, const data_t &b)
{
    data_t res = a;
    res.E += b.E;
    res.E2 += b.E2;
    res.M += b.M;
    res.M2 += b.M2;
    res.M_abs += b.M_abs;

    return res;
}

data_t& operator+=(data_t &a, const data_t &b)
{
    a.E += b.E;
    a.E2 += b.E2;
    a.M += b.M;
    a.M2 += b.M2;
    a.M_abs += b.M_abs;

    return a;
}
