Update of /cvsroot/boost/boost/boost/numeric/ublas
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16494
Modified Files:
hermitian.hpp triangular.hpp
Log Message:
- fixed bug in triangular_matrix::resize and hermitian_matrix::resize
by adding new matrix_resize_preserve specialization for those types
Index: hermitian.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/hermitian.hpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- hermitian.hpp 30 Nov 2006 18:14:07 -0000 1.57
+++ hermitian.hpp 1 May 2007 12:30:39 -0000 1.58
@@ -18,6 +18,7 @@
#define BOOST_UBLAS_HERMITIAN_H
#include <boost/numeric/ublas/matrix.hpp>
+#include <boost/numeric/ublas/triangular.hpp> // for resize_preserve
#include <boost/numeric/ublas/detail/temporary.hpp>
// Iterators based on ideas of Jeremy Siek
@@ -317,7 +318,7 @@
void resize (size_type size, bool preserve = true) {
if (preserve) {
self_type temporary (size, size);
- detail::matrix_resize_preserve<layout_type> (*this, temporary);
+ detail::matrix_resize_preserve<layout_type, triangular_type>
(*this, temporary);
}
else {
data ().resize (triangular_type::packed_size (layout_type (),
size, size));
Index: triangular.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/triangular.hpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- triangular.hpp 6 Nov 2005 14:57:14 -0000 1.59
+++ triangular.hpp 1 May 2007 12:30:39 -0000 1.60
@@ -25,6 +25,42 @@
namespace boost { namespace numeric { namespace ublas {
+ namespace detail {
+ using namespace boost::numeric::ublas;
+
+ // Matrix resizing algorithm
+ template <class L, class T, class M>
+ BOOST_UBLAS_INLINE
+ void matrix_resize_preserve (M& m, M& temporary) {
+ typedef L layout_type;
+ typedef T triangular_type;
+ typedef typename M::size_type size_type;
+ const size_type msize1 (m.size1 ()); // original size
+ const size_type msize2 (m.size2 ());
+ const size_type size1 (temporary.size1 ()); // new size is
specified by temporary
+ const size_type size2 (temporary.size2 ());
+ // Common elements to preserve
+ const size_type size1_min = (std::min) (size1, msize1);
+ const size_type size2_min = (std::min) (size2, msize2);
+ // Order for major and minor sizes
+ const size_type major_size = layout_type::size_M (size1_min,
size2_min);
+ const size_type minor_size = layout_type::size_m (size1_min,
size2_min);
+ // Indexing copy over major
+ for (size_type major = 0; major != major_size; ++major) {
+ for (size_type minor = 0; minor != minor_size; ++minor) {
+ // find indexes - use invertability of element_
functions
+ const size_type i1 = layout_type::index_M(major, minor);
+ const size_type i2 = layout_type::index_m(major, minor);
+ if ( triangular_type::other(i1,i2) ) {
+ temporary.data () [triangular_type::element
(layout_type (), i1, size1, i2, size2)] =
+ m.data() [triangular_type::element (layout_type
(), i1, msize1, i2, msize2)];
+ }
+ }
+ }
+ m.assign_temporary (temporary);
+ }
+ }
+
// Array based triangular matrix class
template<class T, class TRI, class L, class A>
class triangular_matrix:
@@ -104,7 +140,7 @@
void resize (size_type size1, size_type size2, bool preserve = true) {
if (preserve) {
self_type temporary (size1, size2);
- detail::matrix_resize_preserve<layout_type> (*this, temporary);
+ detail::matrix_resize_preserve<layout_type, triangular_type>
(*this, temporary);
}
else {
data ().resize (triangular_type::packed_size (layout_type (),
size1, size2));
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs