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>
25 return cout <<
"-" <<
n <<
"/" <<
m;
28 #define PRINT_FUNCTION(FUN, NAME) \
29 template<typename T> \
30 std::ostream& operator<<(std::ostream& cout, const funct::FUN<T> & f) { \
31 return cout << NAME << "(" << f._ << ")"; \
34 struct __useless_ignoreme
47 #define PRINT_BINARY_OPERATOR(TMPL, OP) \
48 template<typename A, typename B> \
49 std::ostream& operator<<(std::ostream& cout, const funct::TMPL <A, B> & f) \
50 { 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._; } \
59 struct __useless_ignoreme
67 #undef PRINT_BINARY_OPERATOR
68 #undef PRINT_UNARY_OPERATOR
70 template<
typename A,
typename B>
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>
85 return cout <<
"- " <<
f._1._ <<
" + " <<
f._2;
88 template<
typename A,
int n>
91 return cout <<
f._1 << (
n >= 0 ?
" + " :
" - ") << ::
abs(
n);
94 template<
typename A,
int n>
97 return cout <<
"- " <<
f._1._ << (
n >= 0 ?
" + " :
" - ") << ::
abs(
n);
100 #define PARENTHESES(TMPL1, TMPL2, OP) \
101 template<typename A, typename B, typename C> \
102 std::ostream& operator<<(std::ostream& cout, \
103 const funct::TMPL1<funct::TMPL2<A, B>, C> & f) { \
104 return cout << "( " << f._1 << " )" << OP << f._2; \
107 template<typename A, typename B, typename C> \
108 std::ostream& operator<<(std::ostream& cout, \
109 const funct::TMPL1<C, funct::TMPL2<A, B> > & f) { \
110 return cout << f._1 << OP << "( " << f._2 << " )"; \
113 template<typename A, typename B, typename C, typename D> \
114 std::ostream& operator<<(std::ostream& cout, \
115 const funct::TMPL1<funct::TMPL2<A, B>, \
116 funct::TMPL2<C, D> > & f) { \
117 return cout << "( " << f._1 << " )" << OP << "( " << f._2 << " )"; \
120 struct __useless_ignoreme
122 #define PARENTHESES_FRACT(TMPL, OP) \
123 template<int n, int m, typename A> \
124 std::ostream& operator<<(std::ostream& cout, \
125 const funct::TMPL<funct::FractionStruct<n, m>, A> & f ) { \
126 return cout << "( " << f._1 << " )" << OP << f._2; \
129 template<int n, int m, typename A> \
130 std::ostream& operator<<(std::ostream& cout, \
131 const funct::TMPL<A, funct::FractionStruct<n, m> > & f) { \
132 return cout << f._1 << OP << "( " << f._2 << " )"; } \
134 template<int n, int m, int k, int l> \
135 std::ostream& operator<<(std::ostream& cout, \
136 const funct::TMPL<funct::FractionStruct<n, m>, \
137 funct::FractionStruct<k, l> > & f) { \
138 return cout << "( " << f._1 << " )" << OP << "( " << f._2 << " )"; \
141 template<int n, int m, typename A> \
142 std::ostream& operator<<(std::ostream& cout, \
143 const funct::TMPL<funct::MinusStruct<funct::FractionStruct<n, m> >, A> & f) { \
144 return cout << "( " << f._1 << " )" << OP << f._2; \
147 template<int n, int m, typename A> \
148 std::ostream& operator<<(std::ostream& cout, \
149 const funct::TMPL<A, funct::MinusStruct<funct::FractionStruct<n, m> > > & f) { \
150 return cout << f._1 << OP << "( " << f._2 << " )"; \
152 struct __useless_ignoreme
154 #define PARENTHESES_1(TMPL1, TMPL2, OP) \
155 template<typename A, typename B> \
156 std::ostream& operator<<(std::ostream& cout, \
157 const funct::TMPL1<funct::TMPL2<A, B> > & f) { \
158 return cout << OP << "( " << f._ << " )"; \
160 struct __useless_ignoreme
180 #undef PARENTHESES_FRACT
PARENTHESES(ProductStruct, SumStruct," ")
PRINT_BINARY_OPERATOR(SumStruct," + ")
PRINT_UNARY_OPERATOR(MinusStruct,"-")
Abs< T >::type abs(const T &t)
PARENTHESES_1(MinusStruct, SumStruct,"-")
PARENTHESES_FRACT(RatioStruct,"/")
PRINT_FUNCTION(SqrtStruct,"sqrt")
std::ostream & operator<<(std::ostream &cout, const Expression &e)