27 #ifndef SYMMETRY_NU1_TEMPLATE_H
28 #define SYMMETRY_NU1_TEMPLATE_H
34 #include <boost/lexical_cast.hpp>
35 #include <boost/functional/hash.hpp>
37 #include <boost/serialization/serialization.hpp>
38 #include <boost/serialization/array.hpp>
41 template<
int N,
class S =
int>
49 for (S i = 0; i < N; ++i) (*
this)[i] = init;
54 std::copy(rhs.begin(), rhs.end(), this->
begin());
57 S *
begin() {
return &data_[0]; }
58 S *
end() {
return &data_[N]; }
60 S
const *
begin()
const {
return &data_[0]; }
61 S
const *
end()
const {
return &data_[N]; }
64 S
const &
operator[](std::size_t p)
const {
return data_[p]; }
66 template<
class Archive>
67 void save(Archive & ar)
const
69 for (
int i = 0; i < N; ++i)
70 ar[boost::lexical_cast<std::string>(i)] << (*this)[i];
73 template<
class Archive>
76 for (
int i = 0; i < N; ++i)
77 ar[boost::lexical_cast<std::string>(i)] >> (*this)[i];
80 template <
class Archive>
81 void serialize(Archive & ar,
const unsigned int version)
91 template <
int N,
class S>
95 return boost::hash_range(&Charge[0],&Charge[N]);
99 template <
int N,
class S>
100 class hash<std::pair<NU1Charge<N, S>, NU1Charge<N, S> > >{
103 std::size_t seed = 0;
104 for(
int i(0); i<N; i++){
105 boost::hash_combine(seed, (Pair_of_charge.first)[i]);
106 boost::hash_combine(seed, (Pair_of_charge.second)[i]);
113 class hash<std::pair<int, int> >{
115 size_t operator()(std::pair<int, int>
const &Pair_of_charge )
const {
116 return boost::hash_value(Pair_of_charge);
122 template<
int N,
class S>
123 std::ostream& operator<<(std::ostream& os, NU1Charge<N, S>
const & c)
126 for (
int i = 0; i < N; ++i) {
135 template<
int N,
int I>
143 else if (a[I] > b[I])
154 else if (a[I] < b[I])
213 template<
int N,
class S>
219 template<
int N,
class S>
225 template<
int N,
class S>
231 template<
int N,
class S>
237 template<
int N,
class S>
246 template<
int N,
class S>
254 template<
int N,
class S>
261 template<
int N,
class S>
265 template<
int N,
class S =
int>
281 template<
int R>
static charge fuse(boost::array<charge, R>
const & v)
284 for (
int i = 1; i < R; ++i)
285 ret =
fuse(ret, v[i]);
void save(Archive &ar) const
bool operator_lt(T const *, T const *) const
void operator_plus(T const *, T const *, T *) const
bool operator_eq(T const *, T const *) const
size_t operator()(std::pair< int, int > const &Pair_of_charge) const
static charge fuse(charge a, charge b)
bool operator_lt(T const *a, T const *b) const
void operator_div(T const *, T *, int) const
bool operator>(NU1Charge< N, S > const &a, NU1Charge< N, S > const &b)
void operator_plus(T const *a, T const *b, T *c) const
static charge fuse(boost::array< charge, R > const &v)
NU1Charge(boost::array< S, N > const &rhs)
S const & operator[](std::size_t p) const
std::vector< charge > charge_v
NU1Charge< N, S > operator-(NU1Charge< N, S > const &rhs)
bool operator_gt(T const *, T const *) const
static const int static_size
void operator_uminus(T const *a, T *b) const
NU1Charge< N, S > operator+(NU1Charge< N, S > const &a, NU1Charge< N, S > const &b)
bool operator!=(NU1Charge< N, S > const &a, NU1Charge< N, S > const &b)
bool operator_eq(T const *a, T const *b) const
bool operator_gt(T const *a, T const *b) const
size_t operator()(std::pair< NU1Charge< N, S >, NU1Charge< N, S > > const &Pair_of_charge) const
S & operator[](std::size_t p)
static const charge IdentityCharge
void operator_uminus(T const *, T *) const
void operator_div(T const *a, T *b, int n) const
bool operator==(NU1Charge< N, S > const &a, NU1Charge< N, S > const &b)
size_t operator()(NU1Charge< N, S > const &Charge) const
void serialize(Archive &ar, const unsigned int version)
NU1Charge< N, S > operator/(NU1Charge< N, S > const &a, int n)