00001 00033 #ifndef ITCONFIG_H 00034 #define ITCONFIG_H 00035 00036 #include <complex> 00037 00038 #ifdef _MSC_VER 00039 #define __WIN32__ 00040 #endif 00041 00042 namespace itpp { 00043 00087 } // namespace itpp 00088 00089 00090 namespace std { 00091 00093 template <class T> 00094 std::ostream& operator<<(std::ostream &os, const std::complex<T> &x) 00095 { 00096 os << x.real(); 00097 ios::fmtflags saved_format = os.setf(ios::showpos); 00098 os << x.imag(); 00099 os.setf(saved_format, ios::showpos); 00100 return os << 'i'; 00101 } 00102 00104 template <class T> 00105 std::istream& operator>>(std::istream &is, std::complex<T> &x) 00106 { 00107 T re, im; 00108 char c; 00109 is >> c; 00110 if (c == '(') { 00111 is >> re >> c; 00112 if (c == ',') { 00113 is >> im >> c; 00114 if (c == ')') { 00115 x = complex<T>(re, im); 00116 } else { 00117 is.setstate(ios_base::failbit); 00118 } 00119 } else if (c == ')') { 00120 x = complex<T>(re, T(0)); 00121 } else { 00122 is.setstate(ios_base::failbit); 00123 } 00124 } else { 00125 is.putback(c); 00126 is >> re; 00127 if (!is.eof() && ((c = is.peek()) == '+' || c == '-')) { 00128 is >> im >> c; 00129 if (c == 'i') { 00130 x = complex<T>(re, im); 00131 } else { 00132 is.setstate(ios_base::failbit); 00133 } 00134 } else { 00135 x = complex<T>(re, T(0)); 00136 } 00137 } 00138 return is; 00139 } 00140 00141 } // namespace std 00142 00143 #endif // #ifndef ITCONFIG_H
Generated on Thu Apr 19 14:14:58 2007 for IT++ by Doxygen 1.5.1