From f74b6b4b38f90addd1ab6be379602bd9c1c1d6b7 Mon Sep 17 00:00:00 2001 From: guido Date: Wed, 16 Apr 2003 14:58:05 +0000 Subject: [PATCH] optimized block_read and block_write git-svn-id: https://svn.dealii.org/trunk@7400 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/lac/sparse_matrix_ez.templates.h | 48 +++++++++++-------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/deal.II/lac/include/lac/sparse_matrix_ez.templates.h b/deal.II/lac/include/lac/sparse_matrix_ez.templates.h index f20c0cd60a..89fff09541 100644 --- a/deal.II/lac/include/lac/sparse_matrix_ez.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix_ez.templates.h @@ -424,26 +424,34 @@ SparseMatrixEZ::block_write (std::ostream &out) const << increment << "]["; // then write out real data typename std::vector::const_iterator r = row_info.begin(); - const typename std::vector::const_iterator re = row_info.end(); + out.write(reinterpret_cast(&*r), + sizeof(RowInfo) * row_info.size()); + +// Just in case that vector entries are not stored consecutively +// const typename std::vector::const_iterator re = row_info.end(); - while (r != re) - { - out.write(reinterpret_cast(&*r), - sizeof(RowInfo)); - ++r; - } +// while (r != re) +// { +// out.write(reinterpret_cast(&*r), +// sizeof(RowInfo)); +// ++r; +// } out << "]["; typename std::vector::const_iterator d = data.begin(); - const typename std::vector::const_iterator de = data.end(); - - while (d != de) - { - out.write(reinterpret_cast(&*d), - sizeof(Entry)); - ++d; - } + out.write(reinterpret_cast(&*d), + sizeof(Entry) * data.size()); + +// Just in case that vector entries are not stored consecutively +// const typename std::vector::const_iterator de = data.end(); + +// while (d != de) +// { +// out.write(reinterpret_cast(&*d), +// sizeof(Entry)); +// ++d; +// } out << ']'; @@ -483,16 +491,14 @@ SparseMatrixEZ::block_read (std::istream &in) CHECKFOR(in,'[',c); // then read data - for (unsigned int i=0;i(&row_info[i]), - sizeof(RowInfo)); + in.read(reinterpret_cast(&row_info[i]), + sizeof(RowInfo) * row_info.size()); CHECKFOR(in,']',c); CHECKFOR(in,'[',c); - for (unsigned int i=0;i(&data[i]), - sizeof(Entry)); + in.read(reinterpret_cast(&data[i]), + sizeof(Entry) * data.size()); CHECKFOR(in,']',c); } -- 2.39.5