1 #ifndef PhysicsTools_Utilities_interface_FunctionsIO_h 2 #define PhysicsTools_Utilities_interface_FunctionsIO_h 13 std::ostream& operator<<(std::ostream& cout, const Numerical<n>&) {
17 template <
int n,
int m>
18 std::ostream& operator<<(std::ostream& cout, const funct::FractionStruct<n, m>&) {
19 return cout <<
n <<
"/" <<
m;
22 template <
int n,
int m>
23 std::ostream& operator<<(std::ostream& cout, const funct::MinusStruct<funct::FractionStruct<n, m> >&) {
24 return cout <<
"-" <<
n <<
"/" <<
m;
27 #define PRINT_FUNCTION(FUN, NAME) \ 28 template <typename T> \ 29 std::ostream& operator<<(std::ostream& cout, const funct::FUN<T>& f) { \ 30 return cout << NAME << "(" << f._ << ")"; \ 33 struct __useless_ignoreme 46 #define PRINT_BINARY_OPERATOR(TMPL, OP) \ 47 template <typename A, typename B> \ 48 std::ostream& operator<<(std::ostream& cout, const funct::TMPL<A, B>& f) { \ 49 return cout << f._1 << OP << f._2; \ 52 struct __useless_ignoreme 54 #define PRINT_UNARY_OPERATOR(TMPL, OP) \ 55 template <typename A> \ 56 std::ostream& operator<<(std::ostream& cout, const funct::TMPL<A>& f) { \ 57 return cout << OP << f._; \ 60 struct __useless_ignoreme 68 #undef PRINT_BINARY_OPERATOR 69 #undef PRINT_UNARY_OPERATOR 71 template <
typename A,
typename B>
72 std::ostream& operator<<(std::ostream& cout, const funct::SumStruct<A, funct::MinusStruct<B> >&
f) {
73 return cout <<
f._1 <<
" - " <<
f._2._;
76 template <
typename A,
typename B>
79 return cout <<
"- " <<
f._1._ <<
" - " <<
f._2._;
82 template <
typename A,
typename B>
83 std::ostream& operator<<(std::ostream& cout, const funct::SumStruct<funct::MinusStruct<A>,
B>&
f) {
84 return cout <<
"- " <<
f._1._ <<
" + " <<
f._2;
87 template <
typename A,
int n>
88 std::ostream& operator<<(std::ostream& cout, const funct::SumStruct<A, funct::Numerical<n> >&
f) {
89 return cout <<
f._1 << (
n >= 0 ?
" + " :
" - ") << ::
abs(
n);
92 template <
typename A,
int n>
93 std::ostream& operator<<(std::ostream& cout, const funct::SumStruct<funct::MinusStruct<A>,
funct::Numerical<n> >&
f) {
94 return cout <<
"- " <<
f._1._ << (
n >= 0 ?
" + " :
" - ") << ::
abs(
n);
97 #define PARENTHESES(TMPL1, TMPL2, OP) \ 98 template <typename A, typename B, typename C> \ 99 std::ostream& operator<<(std::ostream& cout, const funct::TMPL1<funct::TMPL2<A, B>, C>& f) { \ 100 return cout << "( " << f._1 << " )" << OP << f._2; \ 103 template <typename A, typename B, typename C> \ 104 std::ostream& operator<<(std::ostream& cout, const funct::TMPL1<C, funct::TMPL2<A, B> >& f) { \ 105 return cout << f._1 << OP << "( " << f._2 << " )"; \ 108 template <typename A, typename B, typename C, typename D> \ 109 std::ostream& operator<<(std::ostream& cout, const funct::TMPL1<funct::TMPL2<A, B>, funct::TMPL2<C, D> >& f) { \ 110 return cout << "( " << f._1 << " )" << OP << "( " << f._2 << " )"; \ 113 struct __useless_ignoreme 115 #define PARENTHESES_FRACT(TMPL, OP) \ 116 template <int n, int m, typename A> \ 117 std::ostream& operator<<(std::ostream& cout, const funct::TMPL<funct::FractionStruct<n, m>, A>& f) { \ 118 return cout << "( " << f._1 << " )" << OP << f._2; \ 121 template <int n, int m, typename A> \ 122 std::ostream& operator<<(std::ostream& cout, const funct::TMPL<A, funct::FractionStruct<n, m> >& f) { \ 123 return cout << f._1 << OP << "( " << f._2 << " )"; \ 126 template <int n, int m, int k, int l> \ 127 std::ostream& operator<<(std::ostream& cout, \ 128 const funct::TMPL<funct::FractionStruct<n, m>, funct::FractionStruct<k, l> >& f) { \ 129 return cout << "( " << f._1 << " )" << OP << "( " << f._2 << " )"; \ 132 template <int n, int m, typename A> \ 133 std::ostream& operator<<(std::ostream& cout, \ 134 const funct::TMPL<funct::MinusStruct<funct::FractionStruct<n, m> >, A>& f) { \ 135 return cout << "( " << f._1 << " )" << OP << f._2; \ 138 template <int n, int m, typename A> \ 139 std::ostream& operator<<(std::ostream& cout, \ 140 const funct::TMPL<A, funct::MinusStruct<funct::FractionStruct<n, m> > >& f) { \ 141 return cout << f._1 << OP << "( " << f._2 << " )"; \ 143 struct __useless_ignoreme 145 #define PARENTHESES_1(TMPL1, TMPL2, OP) \ 146 template <typename A, typename B> \ 147 std::ostream& operator<<(std::ostream& cout, const funct::TMPL1<funct::TMPL2<A, B> >& f) { \ 148 return cout << OP << "( " << f._ << " )"; \ 150 struct __useless_ignoreme 170 #undef PARENTHESES_FRACT
#define PARENTHESES(TMPL1, TMPL2, OP)
#define PRINT_BINARY_OPERATOR(TMPL, OP)
Abs< T >::type abs(const T &t)
#define PARENTHESES_1(TMPL1, TMPL2, OP)
#define PRINT_FUNCTION(FUN, NAME)
std::ostream & operator<<(std::ostream &cout, const Expression &e)
#define PRINT_UNARY_OPERATOR(TMPL, OP)
#define PARENTHESES_FRACT(TMPL, OP)