diff --git a/include/boost/numeric/ublas/banded.hpp b/include/boost/numeric/ublas/banded.hpp index 83c5b774..4c801e3b 100644 --- a/include/boost/numeric/ublas/banded.hpp +++ b/include/boost/numeric/ublas/banded.hpp @@ -1023,7 +1023,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename banded_matrix::value_type banded_matrix::zero_ = 0; + typename banded_matrix::value_type banded_matrix::zero_ = + banded_matrix::value_type (); // Diagonal matrix class template @@ -2063,7 +2064,8 @@ namespace boost { namespace numeric { namespace ublas { template typename banded_adaptor::matrix_type banded_adaptor::nil_; template - typename banded_adaptor::value_type banded_adaptor::zero_ = 0; + typename banded_adaptor::value_type banded_adaptor::zero_ = + banded_adaptor::value_type (); // Diagonal matrix adaptor class template diff --git a/include/boost/numeric/ublas/concepts.hpp b/include/boost/numeric/ublas/concepts.hpp index 725345c1..6d3d3edf 100644 --- a/include/boost/numeric/ublas/concepts.hpp +++ b/include/boost/numeric/ublas/concepts.hpp @@ -1038,7 +1038,7 @@ namespace boost { namespace numeric { namespace ublas { AdditiveAbelianGroupConcept::constraints (); bool r; value_type a = value_type (), b = value_type (), c = value_type (); - r = prod (prod (a, b), c) == prod (a, prod (b, c)) ; + r = prod (T (prod (a, b)), c) == prod (a, T (prod (b, c))); r = prod (a + b, c) == prod (a, c) + prod (b, c); r = prod (OneElement (value_type ()), a) == a; r = prod (a, OneElement (value_type ())) == a; diff --git a/include/boost/numeric/ublas/matrix.hpp b/include/boost/numeric/ublas/matrix.hpp index dd42a44c..95ae894a 100644 --- a/include/boost/numeric/ublas/matrix.hpp +++ b/include/boost/numeric/ublas/matrix.hpp @@ -2387,9 +2387,11 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename identity_matrix::value_type identity_matrix::zero_ = 0; + typename identity_matrix::value_type identity_matrix::zero_ = + identity_matrix::value_type (); template - typename identity_matrix::value_type identity_matrix::one_ = 1; + typename identity_matrix::value_type identity_matrix::one_ = + identity_matrix::value_type (1); // Zero matrix class template @@ -2841,7 +2843,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename zero_matrix::value_type zero_matrix::zero_ = 0; + typename zero_matrix::value_type zero_matrix::zero_ = + zero_matrix::value_type (); // Scalar matrix class template diff --git a/include/boost/numeric/ublas/matrix_assign.hpp b/include/boost/numeric/ublas/matrix_assign.hpp index 2401e510..92618892 100644 --- a/include/boost/numeric/ublas/matrix_assign.hpp +++ b/include/boost/numeric/ublas/matrix_assign.hpp @@ -516,7 +516,7 @@ namespace boost { namespace numeric { namespace ublas { typedef typename M::value_type value_type; #ifdef BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); -#ifndef BOOST_MSVC +#ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, m, row_major_tag ()); indexing_matrix_assign (functor1_type::template make_debug_functor::reference, value_type> (), cm, e, row_major_tag ()); #else @@ -651,7 +651,7 @@ namespace boost { namespace numeric { namespace ublas { typedef typename M::value_type value_type; #ifdef BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); -#ifndef BOOST_MSVC +#ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, m, column_major_tag ()); indexing_matrix_assign (functor1_type::template make_debug_functor::reference, value_type> (), cm, e, column_major_tag ()); #else @@ -784,7 +784,7 @@ namespace boost { namespace numeric { namespace ublas { typedef typename M::value_type value_type; #ifdef BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); -#ifndef BOOST_MSVC +#ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, m, row_major_tag ()); indexing_matrix_assign (functor_type::template make_debug_functor::reference, value_type> (), cm, e, row_major_tag ()); #else @@ -827,7 +827,7 @@ namespace boost { namespace numeric { namespace ublas { typedef typename M::value_type value_type; #ifdef BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); -#ifndef BOOST_MSVC +#ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, m, column_major_tag ()); indexing_matrix_assign (functor_type::template make_debug_functor::reference, value_type> (), cm, e, column_major_tag ()); #else @@ -872,7 +872,7 @@ namespace boost { namespace numeric { namespace ublas { typedef typename M::value_type value_type; #ifdef BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); -#ifndef BOOST_MSVC +#ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, m, row_major_tag ()); indexing_matrix_assign (functor1_type::template make_debug_functor::reference, value_type> (), cm, e, row_major_tag ()); #else @@ -1084,7 +1084,7 @@ namespace boost { namespace numeric { namespace ublas { typedef typename M::value_type value_type; #ifdef BOOST_UBLAS_TYPE_CHECK matrix cm (m.size1 (), m.size2 ()); -#ifndef BOOST_MSVC +#ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES indexing_matrix_assign (scalar_assign::reference, value_type> (), cm, m, column_major_tag ()); indexing_matrix_assign (functor1_type::template make_debug_functor::reference, value_type> (), cm, e, column_major_tag ()); #else diff --git a/include/boost/numeric/ublas/matrix_sparse.hpp b/include/boost/numeric/ublas/matrix_sparse.hpp index b8205143..dd8b78d7 100644 --- a/include/boost/numeric/ublas/matrix_sparse.hpp +++ b/include/boost/numeric/ublas/matrix_sparse.hpp @@ -53,9 +53,7 @@ namespace boost { namespace numeric { namespace ublas { sparse_matrix_element (matrix_type &m, size_type i, size_type j): container_reference (m), it_ (), i_ (i), j_ (j), d_ (), dirty_ (false) { pointer it = (*this) ().find_element (i_, j_); - if (! it) - (*this) ().insert (i_, j_, d_); - else + if (it) d_ = *it; } BOOST_UBLAS_INLINE @@ -64,10 +62,14 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE ~sparse_matrix_element () { if (dirty_) { - if (! it_) + if (! it_) { it_ = (*this) ().find_element (i_, j_); - BOOST_UBLAS_CHECK (it_, internal_logic ()); - *it_ = d_; + if (! it_) + (*this) ().insert (i_, j_, d_); + else + *it_ = d_; + } else + *it_ = d_; } } @@ -1394,7 +1396,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename sparse_matrix::value_type sparse_matrix::zero_ = 0; + typename sparse_matrix::value_type sparse_matrix::zero_ = + sparse_matrix::value_type (); // Array based sparse matrix class template @@ -2552,7 +2555,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename sparse_vector_of_sparse_vector::value_type sparse_vector_of_sparse_vector::zero_ = 0; + typename sparse_vector_of_sparse_vector::value_type sparse_vector_of_sparse_vector::zero_ = + sparse_vector_of_sparse_vector::value_type (); // Array based sparse matrix class // Thanks to Kresimir Fresl for extending this to cover different index bases. @@ -3861,7 +3865,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename compressed_matrix::value_type compressed_matrix::zero_ = 0; + typename compressed_matrix::value_type compressed_matrix::zero_ = + compressed_matrix::value_type (); // Array based sparse matrix class // Thanks to Kresimir Fresl for extending this to cover different index bases. @@ -5168,7 +5173,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename coordinate_matrix::value_type coordinate_matrix::zero_ = 0; + typename coordinate_matrix::value_type coordinate_matrix::zero_ = + coordinate_matrix::value_type (); }}} diff --git a/include/boost/numeric/ublas/triangular.hpp b/include/boost/numeric/ublas/triangular.hpp index a92920ed..c75b4b92 100644 --- a/include/boost/numeric/ublas/triangular.hpp +++ b/include/boost/numeric/ublas/triangular.hpp @@ -952,9 +952,11 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename triangular_matrix::value_type triangular_matrix::zero_ = 0; + typename triangular_matrix::value_type triangular_matrix::zero_ = + triangular_matrix::value_type (); template - typename triangular_matrix::value_type triangular_matrix::one_ = 1; + typename triangular_matrix::value_type triangular_matrix::one_ = + triangular_matrix::value_type (1); // Triangular matrix adaptor class template @@ -1879,9 +1881,11 @@ namespace boost { namespace numeric { namespace ublas { template typename triangular_adaptor::matrix_type triangular_adaptor::nil_; template - typename triangular_adaptor::value_type triangular_adaptor::zero_ = 0; + typename triangular_adaptor::value_type triangular_adaptor::zero_ = + triangular_adaptor::value_type (); template - typename triangular_adaptor::value_type triangular_adaptor::one_ = 1; + typename triangular_adaptor::value_type triangular_adaptor::one_ = + triangular_adaptor::value_type (1); template struct matrix_vector_solve_traits { diff --git a/include/boost/numeric/ublas/vector.hpp b/include/boost/numeric/ublas/vector.hpp index 8d9d0548..3111a951 100644 --- a/include/boost/numeric/ublas/vector.hpp +++ b/include/boost/numeric/ublas/vector.hpp @@ -794,9 +794,11 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename unit_vector::value_type unit_vector::zero_ = 0; + typename unit_vector::value_type unit_vector::zero_ = + unit_vector::value_type (); template - typename unit_vector::value_type unit_vector::one_ = 1; + typename unit_vector::value_type unit_vector::one_ = + unit_vector::value_type (1); // Zero vector class template @@ -1002,7 +1004,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename zero_vector::value_type zero_vector::zero_ = 0; + typename zero_vector::value_type zero_vector::zero_ = + zero_vector::value_type (); // Scalar vector class template diff --git a/include/boost/numeric/ublas/vector_assign.hpp b/include/boost/numeric/ublas/vector_assign.hpp index 2a913163..70db95a3 100644 --- a/include/boost/numeric/ublas/vector_assign.hpp +++ b/include/boost/numeric/ublas/vector_assign.hpp @@ -284,7 +284,7 @@ namespace boost { namespace numeric { namespace ublas { typedef typename V::value_type value_type; #ifdef BOOST_UBLAS_TYPE_CHECK vector cv (v.size ()); -#ifndef BOOST_MSVC +#ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES indexing_vector_assign (scalar_assign::reference, value_type> (), cv, v); indexing_vector_assign (functor_type::template make_debug_functor::reference, value_type> (), cv, e); #else @@ -344,7 +344,7 @@ namespace boost { namespace numeric { namespace ublas { typedef typename V::value_type value_type; #ifdef BOOST_UBLAS_TYPE_CHECK vector cv (v.size ()); -#ifndef BOOST_MSVC +#ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES indexing_vector_assign (scalar_assign::reference, value_type> (), cv, v); indexing_vector_assign (functor_type::template make_debug_functor::reference, value_type> (), cv, e); #else @@ -378,7 +378,7 @@ namespace boost { namespace numeric { namespace ublas { typedef typename V::reference reference; #ifdef BOOST_UBLAS_TYPE_CHECK vector cv (v.size ()); -#ifndef BOOST_MSVC +#ifndef BOOST_UBLAS_NO_ELEMENT_PROXIES indexing_vector_assign (scalar_assign::reference, value_type> (), cv, v); indexing_vector_assign (functor_type::template make_debug_functor::reference, value_type> (), cv, e); #else diff --git a/include/boost/numeric/ublas/vector_of_vector.hpp b/include/boost/numeric/ublas/vector_of_vector.hpp index a073a74d..4bf8245b 100644 --- a/include/boost/numeric/ublas/vector_of_vector.hpp +++ b/include/boost/numeric/ublas/vector_of_vector.hpp @@ -1198,7 +1198,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename generalized_vector_of_vector::value_type generalized_vector_of_vector::zero_ = 0; + typename generalized_vector_of_vector::value_type generalized_vector_of_vector::zero_ = + generalized_vector_of_vector::value_type (); }}} diff --git a/include/boost/numeric/ublas/vector_sparse.hpp b/include/boost/numeric/ublas/vector_sparse.hpp index 038a6386..c4424260 100644 --- a/include/boost/numeric/ublas/vector_sparse.hpp +++ b/include/boost/numeric/ublas/vector_sparse.hpp @@ -52,9 +52,7 @@ namespace boost { namespace numeric { namespace ublas { sparse_vector_element (vector_type &v, size_type i): container_reference (v), it_ (), i_ (i), d_ (), dirty_ (false) { pointer it = (*this) ().find_element (i_); - if (! it) - (*this) ().insert (i_, d_); - else + if (it) d_ = *it; } BOOST_UBLAS_INLINE @@ -63,10 +61,14 @@ namespace boost { namespace numeric { namespace ublas { BOOST_UBLAS_INLINE ~sparse_vector_element () { if (dirty_) { - if (! it_) + if (! it_) { it_ = (*this) ().find_element (i_); - BOOST_UBLAS_CHECK (it_, internal_logic ()); - *it_ = d_; + if (! it_) + (*this) ().insert (i_, d_); + else + *it_ = d_; + } else + *it_ = d_; } } @@ -772,7 +774,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename sparse_vector::value_type sparse_vector::zero_ = 0; + typename sparse_vector::value_type sparse_vector::zero_ = + sparse_vector::value_type (); // Array based sparse vector class // Thanks to Kresimir Fresl for extending this to cover different index bases. @@ -1336,7 +1339,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename compressed_vector::value_type compressed_vector::zero_ = 0; + typename compressed_vector::value_type compressed_vector::zero_ = + compressed_vector::value_type (); // Array based sparse vector class // Thanks to Kresimir Fresl for extending this to cover different index bases. @@ -1931,7 +1935,8 @@ namespace boost { namespace numeric { namespace ublas { }; template - typename coordinate_vector::value_type coordinate_vector::zero_ = 0; + typename coordinate_vector::value_type coordinate_vector::zero_ = + coordinate_vector::value_type (); }}}