Index: matrix.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/matrix.hpp,v
retrieving revision 1.72
diff -u -p -r1.72 matrix.hpp
--- matrix.hpp	6 Dec 2006 09:34:01 -0000	1.72
+++ matrix.hpp	30 Jan 2007 11:48:39 -0000
@@ -20,6 +20,8 @@
 #include <boost/numeric/ublas/vector.hpp>
 #include <boost/numeric/ublas/matrix_expression.hpp>
 #include <boost/numeric/ublas/detail/matrix_assign.hpp>
+#include <boost/serialization/collection_size_type.hpp>
+#include <boost/serialization/nvp.hpp>
 
 // Iterators based on ideas of Jeremy Siek
 
@@ -941,6 +943,27 @@ namespace boost { namespace numeric { na
             return reverse_iterator2 (begin2 ());
         }
 
+        // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+        
+            // we need to copy to a collection_size_type to get a portable
+            // and efficient serialization
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+          
+            // serialize the sizes
+            ar & serialization::make_nvp("size1",s1)
+               & serialization::make_nvp("size2",s2);
+
+            // copy the values back if loading
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+            }
+            ar & serialization::make_nvp("data",data_);
+        }
+
     private:
         size_type size1_;
         size_type size2_;
@@ -1960,6 +1984,27 @@ namespace boost { namespace numeric { na
             return reverse_iterator2 (begin2 ());
         }
 
+        // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+        
+            // we need to copy to a collection_size_type to get a portable
+            // and efficient serialization
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+          
+            // serialize the sizes
+            ar & serialization::make_nvp("size1",s1)
+               & serialization::make_nvp("size2",s2);
+
+            // copy the values back if loading
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+            }
+            ar & serialization::make_nvp("data",data_);
+        }
+
     private:
         size_type size1_;
         size_type size2_;
@@ -2317,6 +2362,26 @@ namespace boost { namespace numeric { na
             return const_reverse_iterator2 (begin2 ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+        
+            // we need to copy to a collection_size_type to get a portable
+            // and efficient serialization
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+          
+            // serialize the sizes
+            ar & serialization::make_nvp("size1",s1)
+               & serialization::make_nvp("size2",s2);
+
+            // copy the values back if loading
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+            }
+        }
+
     private:
         size_type size1_;
         size_type size2_;
@@ -2697,6 +2762,27 @@ namespace boost { namespace numeric { na
             return const_reverse_iterator2 (begin2 ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+        
+            // we need to copy to a collection_size_type to get a portable
+            // and efficient serialization
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+          
+            // serialize the sizes
+            ar & serialization::make_nvp("size1",s1)
+               & serialization::make_nvp("size2",s2);
+
+            // copy the values back if loading
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+                size_common_ = ((std::min)(size1_, size2_));
+            }
+        }
+
     private:
         size_type size1_;
         size_type size2_;
@@ -3136,6 +3222,28 @@ namespace boost { namespace numeric { na
             return const_reverse_iterator2 (begin2 ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+        
+            // we need to copy to a collection_size_type to get a portable
+            // and efficient serialization
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+          
+            // serialize the sizes
+            ar & serialization::make_nvp("size1",s1)
+               & serialization::make_nvp("size2",s2);
+
+            // copy the values back if loading
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+            }
+
+            ar & serialization::make_nvp("value", value_);
+        }
+
     private:
         size_type size1_;
         size_type size2_;
@@ -4039,6 +4147,28 @@ namespace boost { namespace numeric { na
             return reverse_iterator2 (begin2 ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+        
+            // we need to copy to a collection_size_type to get a portable
+            // and efficient serialization
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+          
+            // serialize the sizes
+            ar & serialization::make_nvp("size1",s1)
+               & serialization::make_nvp("size2",s2);
+
+            // copy the values back if loading
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+            }
+            // could probably use make_array( &(data[0][0]), N*M ) 
+            ar & serialization::make_array(data_, N);
+        }
+
     private:
         size_type size1_;
         size_type size2_;
Index: matrix_sparse.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/matrix_sparse.hpp,v
retrieving revision 1.83
diff -u -p -r1.83 matrix_sparse.hpp
--- matrix_sparse.hpp	6 Dec 2006 09:34:00 -0000	1.83
+++ matrix_sparse.hpp	30 Jan 2007 11:48:39 -0000
@@ -1295,6 +1295,20 @@ namespace boost { namespace numeric { na
             return reverse_iterator2 (begin2 ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+            ar & serialization::make_nvp("size1",s1);
+            ar & serialization::make_nvp("size2",s2);
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+            }
+            ar & serialization::make_nvp("data", data_);
+        }
+
     private:
         size_type size1_;
         size_type size2_;
@@ -2482,6 +2496,20 @@ namespace boost { namespace numeric { na
             return reverse_iterator2 (begin2 ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+            ar & serialization::make_nvp("size1",s1);
+            ar & serialization::make_nvp("size2",s2);
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+            }
+            ar & serialization::make_nvp("data", data_);
+        }
+
     private:
         size_type size1_;
         size_type size2_;
@@ -3815,6 +3843,26 @@ namespace boost { namespace numeric { na
             return reverse_iterator2 (begin2 ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+            ar & serialization::make_nvp("size1",s1);
+            ar & serialization::make_nvp("size2",s2);
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+            }
+            ar & serialization::make_nvp("capacity", capacity_);
+            ar & serialization::make_nvp("filled1", filled1_);
+            ar & serialization::make_nvp("filled2", filled2_);
+            ar & serialization::make_nvp("index1_data", index1_data_);
+            ar & serialization::make_nvp("index2_data", index2_data_);
+            ar & serialization::make_nvp("value_data", value_data_);
+            storage_invariants();
+        }
+
     private:
         void storage_invariants () const {
             BOOST_UBLAS_CHECK (layout_type::size_M (size1_, size2_) + 1 == index1_data_.size (), internal_logic ());
@@ -5159,6 +5207,27 @@ namespace boost { namespace numeric { na
             return reverse_iterator2 (begin2 ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+            ar & serialization::make_nvp("size1",s1);
+            ar & serialization::make_nvp("size2",s2);
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+            }
+            ar & serialization::make_nvp("capacity", capacity_);
+            ar & serialization::make_nvp("filled", filled_);
+            ar & serialization::make_nvp("sorted_filled", sorted_filled_);
+            ar & serialization::make_nvp("sorted", sorted_);
+            ar & serialization::make_nvp("index1_data", index1_data_);
+            ar & serialization::make_nvp("index2_data", index2_data_);
+            ar & serialization::make_nvp("value_data", value_data_);
+            storage_invariants();
+        }
+
     private:
         void storage_invariants () const
         {
Index: storage.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/storage.hpp,v
retrieving revision 1.75
diff -u -p -r1.75 storage.hpp
--- storage.hpp	21 Jun 2006 18:17:53 -0000	1.75
+++ storage.hpp	30 Jan 2007 11:48:40 -0000
@@ -22,6 +22,10 @@
 #include <boost/shared_array.hpp>
 #endif
 
+#include <boost/serialization/array.hpp>
+#include <boost/serialization/collection_size_type.hpp>
+#include <boost/serialization/nvp.hpp>
+
 #include <boost/numeric/ublas/exception.hpp>
 #include <boost/numeric/ublas/detail/iterator.hpp>
 
@@ -270,6 +275,21 @@ namespace boost { namespace numeric { na
         }
 
     private:
+        friend class boost::serialization::access;
+
+        // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int version)
+        { 
+            serialization::collection_size_type s(size_);
+            ar & serialization::make_nvp("size",s);
+            if ( Archive::is_loading::value ) {
+                resize(s);
+            }
+            ar & serialization::make_array(data_, s);
+        }
+
+    private:
         // Handle explict destroy on a (possibly indexed) iterator
         BOOST_UBLAS_INLINE
         static void iterator_destroy (iterator &i) {
@@ -433,6 +453,22 @@ namespace boost { namespace numeric { na
         }
 
     private:
+        // Serialization
+        friend class boost::serialization::access;
+
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int version)
+        {
+            serialization::collection_size_type s(size_);
+            ar & serialization::make_nvp("size", s);
+            if ( Archive::is_loading::value ) {
+                if (s > N) bad_size("too large size in bounded_array::load()\n").raise();
+                resize(s);
+            }
+            ar & serialization::make_array(data_, s);
+        }
+
+    private:
         size_type size_;
         BOOST_UBLAS_BOUNDED_ARRAY_ALIGN value_type data_ [N];
     };
Index: storage_sparse.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/storage_sparse.hpp,v
retrieving revision 1.42
diff -u -p -r1.42 storage_sparse.hpp
--- storage_sparse.hpp	6 Nov 2005 14:57:13 -0000	1.42
+++ storage_sparse.hpp	30 Jan 2007 11:48:40 -0000
@@ -18,6 +18,10 @@
 #define _BOOST_UBLAS_STORAGE_SPARSE_
 
 #include <map>
+#include <boost/serialization/collection_size_type.hpp>
+#include <boost/serialization/nvp.hpp>
+#include <boost/serialization/map.hpp>
+#include <boost/serialization/base_object.hpp>
 
 #include <boost/numeric/ublas/storage.hpp>
 
@@ -197,8 +201,16 @@ namespace boost { namespace numeric { na
     // FIXME should use ALLOC for map but std::allocator of std::pair<const I, T> and std::pair<I,T> fail to compile
     template<class I, class T, class ALLOC>
     class map_std : public std::map<I, T /*, ALLOC */> {
+    public:
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            ar & serialization::make_nvp("base", boost::serialization::base_object< std::map<I, T /*, ALLOC */> >(*this));
+        }
     };
 
+    
+
 
     // Map array
     //  Implementation requires pair<I, T> allocator definition (without const)
@@ -478,6 +490,17 @@ namespace boost { namespace numeric { na
             return alloc_;
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s (size_);
+            ar & serialization::make_nvp("size",s);
+            if (Archive::is_loading::value) {
+                resize(s);
+            }
+            ar & serialization::make_array(data_, s);
+        }
+
     private:
         // Provide destroy as a non member function
         BOOST_UBLAS_INLINE
Index: vector.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/vector.hpp,v
retrieving revision 1.74
diff -u -p -r1.74 vector.hpp
--- vector.hpp	6 Dec 2006 09:34:01 -0000	1.74
+++ vector.hpp	30 Jan 2007 11:48:40 -0000
@@ -20,6 +20,8 @@
 #include <boost/numeric/ublas/storage.hpp>
 #include <boost/numeric/ublas/vector_expression.hpp>
 #include <boost/numeric/ublas/detail/vector_assign.hpp>
+#include <boost/serialization/collection_size_type.hpp>
+#include <boost/serialization/nvp.hpp>
 
 // Iterators based on ideas of Jeremy Siek
 
@@ -505,6 +507,12 @@ namespace boost { namespace numeric { na
             return reverse_iterator (begin ());
         }
 
+        // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            ar & serialization::make_nvp("data",data_);
+        }
+
     private:
         array_type data_;
     };
@@ -748,6 +756,16 @@ namespace boost { namespace numeric { na
             return const_reverse_iterator (begin ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s (size_);
+            ar & serialization::make_nvp("size",s);
+            if (Archive::is_loading::value) {
+                size_ = s;
+            }
+        }
+
     private:
         size_type size_;
         typedef const value_type const_value_type;
@@ -958,6 +976,17 @@ namespace boost { namespace numeric { na
             return const_reverse_iterator (begin ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s (size_);
+            ar & serialization::make_nvp("size",s);
+            if (Archive::is_loading::value) {
+                size_ = s;
+            }
+            ar & serialization::make_nvp("index", index_);
+        }
+
     private:
         size_type size_;
         size_type index_;
@@ -1192,6 +1221,17 @@ namespace boost { namespace numeric { na
             return const_reverse_iterator (begin ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s (size_);
+            ar & serialization::make_nvp("size",s);
+            if (Archive::is_loading::value) {
+                size_ = s;
+            }
+            ar & serialization::make_nvp("value", value_);
+        }
+
     private:
         size_type size_;
         value_type value_;
@@ -1674,6 +1714,21 @@ namespace boost { namespace numeric { na
             return reverse_iterator (begin ());
         }
 
+        // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s (size_);
+            ar & serialization::make_nvp("size",s);
+            
+            // copy the value back if loading
+            if (Archive::is_loading::value) {
+              if (s > N) bad_size("too large size in bounded_vector::load()\n").raise();
+              size_ = s;
+            }
+            // ISSUE: this writes the full array
+            ar & serialization::make_nvp("data",data_);
+        }
+
     private:
         size_type size_;
         array_type data_;
Index: vector_of_vector.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/vector_of_vector.hpp,v
retrieving revision 1.28
diff -u -p -r1.28 vector_of_vector.hpp
--- vector_of_vector.hpp	16 Jul 2006 13:48:52 -0000	1.28
+++ vector_of_vector.hpp	30 Jan 2007 11:48:40 -0000
@@ -1217,6 +1217,30 @@ namespace boost { namespace numeric { na
             return reverse_iterator2 (begin2 ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+        
+            // we need to copy to a collection_size_type to get a portable
+            // and efficient serialization
+            serialization::collection_size_type s1 (size1_);
+            serialization::collection_size_type s2 (size2_);
+          
+            // serialize the sizes
+            ar & serialization::make_nvp("size1",s1)
+               & serialization::make_nvp("size2",s2);
+
+            // copy the values back if loading
+            if (Archive::is_loading::value) {
+                size1_ = s1;
+                size2_ = s2;
+            }
+
+            ar & serialization::make_nvp("data", data_);
+
+            storage_invariants();
+        }
+
     private:
         void storage_invariants () const
         {
Index: vector_sparse.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/numeric/ublas/vector_sparse.hpp,v
retrieving revision 1.77
diff -u -p -r1.77 vector_sparse.hpp
--- vector_sparse.hpp	16 Nov 2006 09:47:44 -0000	1.77
+++ vector_sparse.hpp	30 Jan 2007 11:48:40 -0000
@@ -738,6 +738,17 @@ namespace boost { namespace numeric { na
             return reverse_iterator (begin ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s (size_);
+            ar & serialization::make_nvp("size",s);
+            if (Archive::is_loading::value) {
+                size_ = s;
+            }
+            ar & serialization::make_nvp("data", data_);
+        }
+
     private:
         size_type size_;
         array_type data_;
@@ -1318,6 +1329,23 @@ namespace boost { namespace numeric { na
             return reverse_iterator (begin ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s (size_);
+            ar & serialization::make_nvp("size",s);
+            if (Archive::is_loading::value) {
+                size_ = s;
+            }
+            // ISSUE: filled may be much less than capacity
+            // ISSUE: index_data_ and value_data_ are undefined between filled and capacity (trouble with 'nan'-values)
+            ar & serialization::make_nvp("capacity", capacity_);
+            ar & serialization::make_nvp("filled", filled_);
+            ar & serialization::make_nvp("index_data", index_data_);
+            ar & serialization::make_nvp("value_data", value_data_);
+            storage_invariants();
+        }
+
     private:
         void storage_invariants () const
         {
@@ -1981,6 +2009,25 @@ namespace boost { namespace numeric { na
             return reverse_iterator (begin ());
         }
 
+         // Serialization
+        template<class Archive>
+        void serialize(Archive & ar, const unsigned int /* file_version */){
+            serialization::collection_size_type s (size_);
+            ar & serialization::make_nvp("size",s);
+            if (Archive::is_loading::value) {
+                size_ = s;
+            }
+            // ISSUE: filled may be much less than capacity
+            // ISSUE: index_data_ and value_data_ are undefined between filled and capacity (trouble with 'nan'-values)
+            ar & serialization::make_nvp("capacity", capacity_);
+            ar & serialization::make_nvp("filled", filled_);
+            ar & serialization::make_nvp("sorted_filled", sorted_filled_);
+            ar & serialization::make_nvp("sorted", sorted_);
+            ar & serialization::make_nvp("index_data", index_data_);
+            ar & serialization::make_nvp("value_data", value_data_);
+            storage_invariants();
+        }
+
     private:
         void storage_invariants () const
         {
