00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __OUTPUT_H
00032 #define __OUTPUT_H
00033
00034 #include "OFELI_Config.h"
00035 #include <iostream>
00036 using std::ostream;
00037 using std::setw;
00038
00039 #include <iomanip>
00040
00041 #include <complex>
00042 #include <string>
00043
00044 #include <valarray>
00045 using std::valarray;
00046
00047 #include <vector>
00048 using std::vector;
00049
00050 namespace OFELI {
00051
00057
00058
00059
00060 inline ostream& operator<<(ostream &s, const std::complex<double> &x)
00061 {
00062 if (x.imag()<0)
00063 s << x.real() << " - " << -x.imag() << " I";
00064 else
00065 s << x.real() << " + " << x.imag() << " I";
00066 return s;
00067 }
00068
00069
00073 inline ostream& operator<<(ostream &s, const std::string &c)
00074 {
00075 for (size_t i=0; i<c.length(); i++)
00076 s << c[i];
00077 return s;
00078 }
00079
00080
00084 template<class T_>
00085 inline ostream& operator<<(ostream& s, const vector<T_> &v)
00086 {
00087 for (typename std::vector<T_>::const_iterator i=v.begin(); i!=v.end(); i++)
00088 s << *i << endl;
00089 return s;
00090 }
00091
00092
00096 template<class T_>
00097 inline ostream&operator<<(ostream& s, const valarray<T_> &v)
00098 {
00099 for (size_t i=0; i<v.size(); i++)
00100 s << v[i] << endl;
00101 return s;
00102 }
00103
00104
00108 template<class T_>
00109 inline ostream& operator<<(ostream& s, const std::pair<T_,T_> &a)
00110 {
00111 s << "(" << a.first << "," << a.second << ") ";
00112 return s;
00113 }
00114
00115
00116 }
00117
00118 #endif