]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
optimized block_read and block_write
authorguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 16 Apr 2003 14:58:05 +0000 (14:58 +0000)
committerguido <guido@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 16 Apr 2003 14:58:05 +0000 (14:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@7400 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/sparse_matrix_ez.templates.h

index f20c0cd60ab1931da8fa694944a72d92c3a8b47e..89fff095417b003ee3f01ad7afb976814f240fac 100644 (file)
@@ -424,26 +424,34 @@ SparseMatrixEZ<number>::block_write (std::ostream &out) const
       << increment << "][";
                                    // then write out real data
   typename std::vector<RowInfo>::const_iterator r = row_info.begin();
-  const typename std::vector<RowInfo>::const_iterator re = row_info.end();
+  out.write(reinterpret_cast<const char*>(&*r),
+           sizeof(RowInfo) * row_info.size());
+
+//   Just in case that vector entries are not stored consecutively  
+//   const typename std::vector<RowInfo>::const_iterator re = row_info.end();
   
-  while (r != re)
-    {
-      out.write(reinterpret_cast<const char*>(&*r),
-               sizeof(RowInfo));
-      ++r;
-    }
+//   while (r != re)
+//     {
+//       out.write(reinterpret_cast<const char*>(&*r),
+//             sizeof(RowInfo));
+//       ++r;
+//     }
 
   out << "][";
   
   typename std::vector<Entry>::const_iterator d = data.begin();
-  const typename std::vector<Entry>::const_iterator de = data.end();
-
-  while (d != de)
-    {
-      out.write(reinterpret_cast<const char*>(&*d),
-               sizeof(Entry));
-      ++d;
-    }
+  out.write(reinterpret_cast<const char*>(&*d),
+           sizeof(Entry) * data.size());
+
+//   Just in case that vector entries are not stored consecutively  
+//   const typename std::vector<Entry>::const_iterator de = data.end();
+
+//   while (d != de)
+//     {
+//       out.write(reinterpret_cast<const char*>(&*d),
+//             sizeof(Entry));
+//       ++d;
+//     }
   
   out << ']';
   
@@ -483,16 +491,14 @@ SparseMatrixEZ<number>::block_read (std::istream &in)
   CHECKFOR(in,'[',c);
 
                                    // then read data
-  for (unsigned int i=0;i<row_info.size();++i)
-    in.read(reinterpret_cast<char*>(&row_info[i]),
-           sizeof(RowInfo));
+  in.read(reinterpret_cast<char*>(&row_info[i]),
+         sizeof(RowInfo) * row_info.size());
   
   CHECKFOR(in,']',c);
   CHECKFOR(in,'[',c);
            
-  for (unsigned int i=0;i<data.size();++i)
-    in.read(reinterpret_cast<char*>(&data[i]),
-           sizeof(Entry));
+  in.read(reinterpret_cast<char*>(&data[i]),
+         sizeof(Entry) * data.size());
   
   CHECKFOR(in,']',c);
 }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.