00001
00002
00003 #ifndef JMATH_UBLAS_COMPATIBILITY_HPP
00004 #define JMATH_UBLAS_COMPATIBILITY_HPP
00005
00006 #include "boost/version.hpp"
00007
00008 #if BOOST_VERSION < 103300
00009
00010 namespace boost { namespace numeric { namespace ublas {
00011
00012
00013 template<class E, class T, class MT, class MF1, class MF2, class MA>
00014
00015 std::basic_istream<E, T> &operator >> (std::basic_istream<E, T> &is,
00016 symmetric_matrix<MT, MF1, MF2, MA> &m) {
00017 typedef typename symmetric_matrix<MT, MF1, MF2, MA>::size_type size_type;
00018 E ch;
00019 size_type size1, size2;
00020 MT value;
00021 if (is >> ch && ch != '[') {
00022 is.putback (ch);
00023 is.setstate (std::ios_base::failbit);
00024 } else if (is >> size1 >> ch && ch != ',') {
00025 is.putback (ch);
00026 is.setstate (std::ios_base::failbit);
00027 } else if (is >> size2 >> ch && (size2 != size1 || ch != ']')) {
00028 is.putback (ch);
00029 is.setstate (std::ios_base::failbit);
00030 } else if (! is.fail ()) {
00031 symmetric_matrix<MT, MF1, MF2, MA> s (size1, size2);
00032 if (is >> ch && ch != '(') {
00033 is.putback (ch);
00034 is.setstate (std::ios_base::failbit);
00035 } else if (! is.fail ()) {
00036 for (size_type i = 0; i < size1; i ++) {
00037 if (is >> ch && ch != '(') {
00038 is.putback (ch);
00039 is.setstate (std::ios_base::failbit);
00040 break;
00041 }
00042 for (size_type j = 0; j < size2; j ++) {
00043 if (is >> value >> ch && ch != ',') {
00044 is.putback (ch);
00045 if (j < size2 - 1) {
00046 is.setstate (std::ios_base::failbit);
00047 break;
00048 }
00049 }
00050 if (i <= j) {
00051
00052 s(i,j) = value;
00053 }
00054 else if ( s(i,j) != value ) {
00055
00056 is.setstate (std::ios_base::failbit);
00057 break;
00058 }
00059 }
00060 if (is >> ch && ch != ')') {
00061 is.putback (ch);
00062 is.setstate (std::ios_base::failbit);
00063 break;
00064 }
00065 if (is >> ch && ch != ',') {
00066 is.putback (ch);
00067 if (i < size1 - 1) {
00068 is.setstate (std::ios_base::failbit);
00069 break;
00070 }
00071 }
00072 }
00073 if (is >> ch && ch != ')') {
00074 is.putback (ch);
00075 is.setstate (std::ios_base::failbit);
00076 }
00077 }
00078 if (! is.fail ())
00079 m.swap (s);
00080 }
00081 return is;
00082 }
00083
00084 }}}
00085
00086 #endif
00087
00088 #endif // JMATH_UBLAS_COMPATIBILITY_HPP