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

Fixed a regression reported by Gunter Winkler.

svn path=/trunk/boost/boost/numeric/ublas/; revision=18602
This commit is contained in:
Jörg Walter
2003-05-30 05:20:48 +00:00
parent 817330e820
commit eafe5ef169
4 changed files with 36 additions and 48 deletions

View File

@@ -123,8 +123,8 @@
// One of these workarounds is needed for MSVC 7.1 AFAIK
// (thanks to John Maddock and Martin Lauer).
// The second workaround looks like BOOST_UBLAS_QUALIFIED_TYPENAME.
// #define BOOST_UBLAS_NO_NESTED_CLASS_RELATION
#define BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
#define BOOST_UBLAS_NO_NESTED_CLASS_RELATION
// #define BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION
#endif

View File

@@ -52,7 +52,8 @@ namespace boost { namespace numeric { namespace ublas {
size_type size = pm.size ();
for (size_type i = 0; i < size; ++ i) {
std::swap (mv (i), mv (pm (i)));
if (i != pm (i))
std::swap (mv (i), mv (pm (i)));
}
}
template<class PM, class MV>
@@ -63,7 +64,8 @@ namespace boost { namespace numeric { namespace ublas {
size_type size = pm.size ();
for (size_type i = 0; i < size; ++ i) {
row (mv, i).swap (row (mv, pm (i)));
if (i != pm (i))
row (mv, i).swap (row (mv, pm (i)));
}
}
// Dispatcher
@@ -95,6 +97,8 @@ namespace boost { namespace numeric { namespace ublas {
if (i_norm_inf != i) {
pm (i) = i_norm_inf;
row (m, i_norm_inf).swap (mri);
} else {
BOOST_UBLAS_CHECK (pm (i) == i_norm_inf, external_logic ());
}
project (mci, range (i + 1, size1)) *= value_type (1) / m (i, i);
} else if (singular == 0) {
@@ -145,6 +149,8 @@ namespace boost { namespace numeric { namespace ublas {
pm (i) = i_norm_inf;
std::swap (v (i_norm_inf), v (i));
project (row (m, i_norm_inf), range (i + 1, size2)).swap (project (row (m, i), range (i + 1, size2)));
} else {
BOOST_UBLAS_CHECK (pm (i) == i_norm_inf, external_logic ());
}
project (column (mr, i), range (i + 1, size1)).assign (
project (v, range (i + 1, size1)) / v (i));
@@ -178,6 +184,8 @@ namespace boost { namespace numeric { namespace ublas {
pm (i) = i_norm_inf;
std::swap (v (i_norm_inf), v (i));
project (row (m, i_norm_inf), range (i + 1, size2)).swap (project (row (m, i), range (i + 1, size2)));
} else {
BOOST_UBLAS_CHECK (pm (i) == i_norm_inf, external_logic ());
}
project (column (lr, i), range (i + 1, size1)).assign (
project (v, range (i + 1, size1)) / v (i));
@@ -204,7 +212,9 @@ namespace boost { namespace numeric { namespace ublas {
template<class M, class PMT, class PMA, class MV>
void lu_substitute (const M &m, const permutation_matrix<PMT, PMA> &pm, MV &mv) {
typedef const M const_matrix_type;
typedef MV matrix_vector_type;
typedef typename boost::mpl::if_c<boost::is_same<typename MV::type_category, vector_tag>::value,
vector<typename MV::value_type>,
matrix<typename MV::value_type> >::type matrix_vector_type;
swap_rows (pm, mv);
#ifdef BOOST_UBLAS_TYPE_CHECK
@@ -223,7 +233,9 @@ namespace boost { namespace numeric { namespace ublas {
template<class MV, class M, class PMT, class PMA>
void lu_substitute (MV &mv, const M &m, const permutation_matrix<PMT, PMA> &pm) {
typedef const M const_matrix_type;
typedef MV matrix_vector_type;
typedef typename boost::mpl::if_c<boost::is_same<typename MV::type_category, vector_tag>::value,
vector<typename MV::value_type>,
matrix<typename MV::value_type> >::type matrix_vector_type;
swap_rows (pm, mv);
#ifdef BOOST_UBLAS_TYPE_CHECK

View File

@@ -53,31 +53,19 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_INLINE
sparse_matrix_element (matrix_type &m, size_type i, size_type j):
container_reference<matrix_type> (m), it_ (), i_ (i), j_ (j), d_ (), dirty_ (false) {
// FIX: reduce fill in.
// pointer it = (*this) ().find_element (i_, j_);
// if (! it)
// (*this) ().insert (i_, j_, d_);
// else
// d_ = *it;
it_ = (*this) ().find_element (i_, j_);
if (it_)
d_ = *it_;
pointer it = (*this) ().find_element (i_, j_);
if (! it)
(*this) ().insert (i_, j_, d_);
else
d_ = *it;
}
BOOST_UBLAS_INLINE
~sparse_matrix_element () {
// FIX: reduce fill in.
// if (dirty_) {
// if (! it_)
// it_ = (*this) ().find_element (i_, j_);
// BOOST_UBLAS_CHECK (it_, internal_logic ());
// *it_ = d_;
// }
if (dirty_) {
if (! it_) {
if (d_ != value_type ())
(*this) ().insert (i_, j_, d_);
} else
*it_ = d_;
if (! it_)
it_ = (*this) ().find_element (i_, j_);
BOOST_UBLAS_CHECK (it_, internal_logic ());
*it_ = d_;
}
}

View File

@@ -52,31 +52,19 @@ namespace boost { namespace numeric { namespace ublas {
BOOST_UBLAS_INLINE
sparse_vector_element (vector_type &v, size_type i):
container_reference<vector_type> (v), it_ (), i_ (i), d_ (), dirty_ (false) {
// FIX: reduce fill in.
// pointer it = (*this) ().find_element (i_);
// if (! it)
// (*this) ().insert (i_, d_);
// else
// d_ = *it;
it_ = (*this) ().find_element (i_);
if (it_)
d_ = *it_;
pointer it = (*this) ().find_element (i_);
if (! it)
(*this) ().insert (i_, d_);
else
d_ = *it;
}
BOOST_UBLAS_INLINE
~sparse_vector_element () {
// FIX: reduce fill in.
// if (dirty_) {
// if (! it_)
// it_ = (*this) ().find_element (i_);
// BOOST_UBLAS_CHECK (it_, internal_logic ());
// *it_ = d_;
// }
if (dirty_) {
if (! it_) {
if (d_ != value_type ())
(*this) ().insert (i_, d_);
} else
*it_ = d_;
if (! it_)
it_ = (*this) ().find_element (i_);
BOOST_UBLAS_CHECK (it_, internal_logic ());
*it_ = d_;
}
}