2
0
mirror of https://github.com/boostorg/ublas.git synced 2026-02-20 15:12:16 +00:00

use expression size_type

[SVN r25250]
This commit is contained in:
Michael Stevens
2004-09-20 07:33:48 +00:00
parent de008a0942
commit db42a65989

View File

@@ -29,7 +29,8 @@ namespace boost { namespace numeric { namespace ublas {
// BOOST_UBLAS_INLINE
std::basic_ostream<E, T> &operator << (std::basic_ostream<E, T> &os,
const vector_expression<VE> &v) {
std::size_t size = v ().size ();
typedef typename VE::size_type size_type;
size_type size = v ().size ();
std::basic_ostringstream<E, T, std::allocator<E> > s;
s.flags (os.flags ());
s.imbue (os.getloc ());
@@ -37,38 +38,20 @@ namespace boost { namespace numeric { namespace ublas {
s << '[' << size << "](";
if (size > 0)
s << v () (0);
for (std::size_t i = 1; i < size; ++ i)
for (size_type i = 1; i < size; ++ i)
s << ',' << v () (i);
s << ')';
return os << s.str ().c_str ();
}
template<class E, class T, class VT, class VA>
// This function seems to be big. So we do not let the compiler inline it.
// BOOST_UBLAS_INLINE
std::basic_ostream<E, T> &operator << (std::basic_ostream<E, T> &os,
const vector<VT, VA> &v) {
std::size_t size = v.size ();
std::basic_ostringstream<E, T, std::allocator<E> > s;
s.flags (os.flags ());
s.imbue (os.getloc ());
s.precision (os.precision ());
s << '[' << size << "](";
if (size > 0)
s << v (0);
for (std::size_t i = 1; i < size; ++ i)
s << ',' << v (i);
s << ')';
return os << s.str ().c_str ();
}
template<class E, class T, class VT, class VA>
// This function seems to be big. So we do not let the compiler inline it.
// BOOST_UBLAS_INLINE
std::basic_istream<E, T> &operator >> (std::basic_istream<E, T> &is,
vector<VT, VA> &v) {
typedef typename vector<VT, VA>::size_type size_type;
E ch;
std::size_t size;
size_type size;
if (is >> ch && ch != '[') {
is.putback (ch);
is.setstate (std::ios_base::failbit);
@@ -81,7 +64,7 @@ namespace boost { namespace numeric { namespace ublas {
is.putback (ch);
is.setstate (std::ios_base::failbit);
} else if (! is.fail ()) {
for (std::size_t i = 0; i < size; i ++) {
for (size_type i = 0; i < size; i ++) {
if (is >> s (i) >> ch && ch != ',') {
is.putback (ch);
if (i < size - 1)
@@ -105,8 +88,9 @@ namespace boost { namespace numeric { namespace ublas {
// BOOST_UBLAS_INLINE
std::basic_ostream<E, T> &operator << (std::basic_ostream<E, T> &os,
const matrix_expression<ME> &m) {
std::size_t size1 = m ().size1 ();
std::size_t size2 = m ().size2 ();
typedef typename ME::size_type size_type;
size_type size1 = m ().size1 ();
size_type size2 = m ().size2 ();
std::basic_ostringstream<E, T, std::allocator<E> > s;
s.flags (os.flags ());
s.imbue (os.getloc ());
@@ -116,15 +100,15 @@ namespace boost { namespace numeric { namespace ublas {
s << '(' ;
if (size2 > 0)
s << m () (0, 0);
for (std::size_t j = 1; j < size2; ++ j)
for (size_type j = 1; j < size2; ++ j)
s << ',' << m () (0, j);
s << ')';
}
for (std::size_t i = 1; i < size1; ++ i) {
for (size_type i = 1; i < size1; ++ i) {
s << ",(" ;
if (size2 > 0)
s << m () (i, 0);
for (std::size_t j = 1; j < size2; ++ j)
for (size_type j = 1; j < size2; ++ j)
s << ',' << m () (i, j);
s << ')';
}
@@ -132,45 +116,14 @@ namespace boost { namespace numeric { namespace ublas {
return os << s.str ().c_str ();
}
template<class E, class T, class MT, class MF, class MA>
// This function seems to be big. So we do not let the compiler inline it.
// BOOST_UBLAS_INLINE
std::basic_ostream<E, T> &operator << (std::basic_ostream<E, T> &os,
const matrix<MT, MF, MA> &m) {
std::size_t size1 = m.size1 ();
std::size_t size2 = m.size2 ();
std::basic_ostringstream<E, T, std::allocator<E> > s;
s.flags (os.flags ());
s.imbue (os.getloc ());
s.precision (os.precision ());
s << '[' << size1 << ',' << size2 << "](";
if (size1 > 0) {
s << '(' ;
if (size2 > 0)
s << m (0, 0);
for (std::size_t j = 1; j < size2; ++ j)
s << ',' << m (0, j);
s << ')';
}
for (std::size_t i = 1; i < size1; ++ i) {
s << ",(" ;
if (size2 > 0)
s << m (i, 0);
for (std::size_t j = 1; j < size2; ++ j)
s << ',' << m (i, j);
s << ')';
}
s << ')';
return os << s.str ().c_str ();
}
template<class E, class T, class MT, class MF, class MA>
// This function seems to be big. So we do not let the compiler inline it.
// BOOST_UBLAS_INLINE
std::basic_istream<E, T> &operator >> (std::basic_istream<E, T> &is,
matrix<MT, MF, MA> &m) {
typedef typename matrix<MT, MF, MA>::size_type size_type;
E ch;
std::size_t size1, size2;
size_type size1, size2;
if (is >> ch && ch != '[') {
is.putback (ch);
is.setstate (std::ios_base::failbit);
@@ -186,13 +139,13 @@ namespace boost { namespace numeric { namespace ublas {
is.putback (ch);
is.setstate (std::ios_base::failbit);
} else if (! is.fail ()) {
for (std::size_t i = 0; i < size1; i ++) {
for (size_type i = 0; i < size1; i ++) {
if (is >> ch && ch != '(') {
is.putback (ch);
is.setstate (std::ios_base::failbit);
break;
}
for (std::size_t j = 0; j < size2; j ++) {
for (size_type j = 0; j < size2; j ++) {
if (is >> s (i, j) >> ch && ch != ',') {
is.putback (ch);
if (j < size2 - 1) {
@@ -234,38 +187,25 @@ namespace boost { namespace numeric { namespace ublas {
// BOOST_UBLAS_INLINE
std::ostream &operator << (std::ostream &os,
const vector_expression<VE> &v) {
std::size_t size = v ().size ();
typedef typename VE::size_type size_type;
size_type size = v ().size ();
os << '[' << size << "](";
if (size > 0)
os << v () (0);
for (std::size_t i = 1; i < size; ++ i)
for (size_type i = 1; i < size; ++ i)
os << ',' << v () (i);
os << ')';
return os;
}
template<class VT, class VA>
// This function seems to be big. So we do not let the compiler inline it.
// BOOST_UBLAS_INLINE
std::ostream &operator << (std::ostream &os,
const vector<VT, VA> &v) {
std::size_t size = v.size ();
os << '[' << size << "](";
if (size > 0)
os << v (0);
for (std::size_t i = 1; i < size; ++ i)
os << ',' << v (i);
os << ')';
return os;
}
template<class VT, class VA>
// This function seems to be big. So we do not let the compiler inline it.
// BOOST_UBLAS_INLINE
std::istream &operator >> (std::istream &is,
vector<VT, VA> &v) {
typedef typename vector<VT, VA>::size_type size_type;
char ch;
std::size_t size;
size_type size;
if (is >> ch && ch != '[') {
is.putback (ch);
is.setstate (std::ios::failbit);
@@ -278,7 +218,7 @@ namespace boost { namespace numeric { namespace ublas {
is.putback (ch);
is.setstate (std::ios::failbit);
} else if (! is.fail ()) {
for (std::size_t i = 0; i < size; i ++) {
for (size_type i = 0; i < size; i ++) {
if (is >> s (i) >> ch && ch != ',') {
is.putback (ch);
if (i < size - 1)
@@ -302,22 +242,23 @@ namespace boost { namespace numeric { namespace ublas {
// BOOST_UBLAS_INLINE
std::ostream &operator << (std::ostream &os,
const matrix_expression<ME> &m) {
std::size_t size1 = m ().size1 ();
std::size_t size2 = m ().size2 ();
typedef typename ME::size_type size_type;
size_type size1 = m ().size1 ();
size_type size2 = m ().size2 ();
os << '[' << size1 << ',' << size2 << "](";
if (size1 > 0) {
os << '(' ;
if (size2 > 0)
os << m () (0, 0);
for (std::size_t j = 1; j < size2; ++ j)
for (size_type j = 1; j < size2; ++ j)
os << ',' << m () (0, j);
os << ')';
}
for (std::size_t i = 1; i < size1; ++ i) {
for (size_type i = 1; i < size1; ++ i) {
os << ",(" ;
if (size2 > 0)
os << m () (i, 0);
for (std::size_t j = 1; j < size2; ++ j)
for (size_type j = 1; j < size2; ++ j)
os << ',' << m () (i, j);
os << ')';
}
@@ -325,41 +266,14 @@ namespace boost { namespace numeric { namespace ublas {
return os;
}
template<class MT, class MF, class MA>
// This function seems to be big. So we do not let the compiler inline it.
// BOOST_UBLAS_INLINE
std::ostream &operator << (std::ostream &os,
const matrix<MT, MF, MA> &m) {
std::size_t size1 = m.size1 ();
std::size_t size2 = m.size2 ();
os << '[' << size1 << ',' << size2 << "](";
if (size1 > 0) {
os << '(' ;
if (size2 > 0)
os << m (0, 0);
for (std::size_t j = 1; j < size2; ++ j)
os << ',' << m (0, j);
os << ')';
}
for (std::size_t i = 1; i < size1; ++ i) {
os << ",(" ;
if (size2 > 0)
os << m (i, 0);
for (std::size_t j = 1; j < size2; ++ j)
os << ',' << m (i, j);
os << ')';
}
os << ')';
return os;
}
template<class MT, class MF, class MA>
// This function seems to be big. So we do not let the compiler inline it.
// BOOST_UBLAS_INLINE
std::istream &operator >> (std::istream &is,
matrix<MT, MF, MA> &m) {
typedef typename matrix<MT, MF, MA>::size_type size_type;
char ch;
std::size_t size1, size2;
size_type size1, size2;
if (is >> ch && ch != '[') {
is.putback (ch);
is.setstate (std::ios::failbit);
@@ -375,13 +289,13 @@ namespace boost { namespace numeric { namespace ublas {
is.putback (ch);
is.setstate (std::ios::failbit);
} else if (! is.fail ()) {
for (std::size_t i = 0; i < size1; i ++) {
for (size_type i = 0; i < size1; i ++) {
if (is >> ch && ch != '(') {
is.putback (ch);
is.setstate (std::ios::failbit);
break;
}
for (std::size_t j = 0; j < size2; j ++) {
for (size_type j = 0; j < size2; j ++) {
if (is >> s (i, j) >> ch && ch != ',') {
is.putback (ch);
if (j < size2 - 1) {