From 7ac7d99fd3e5f0635ca7db7e2bc656d576dbdf5d Mon Sep 17 00:00:00 2001 From: guido Date: Tue, 11 Mar 2003 13:48:57 +0000 Subject: [PATCH] BlockMatrixEZ operational git-svn-id: https://svn.dealii.org/trunk@7314 0785d39b-7218-0410-832d-ea1e28bc413d --- .../lac/include/lac/block_sparse_matrix_ez.h | 12 ++--- deal.II/lac/include/lac/sparse_matrix_ez.h | 54 ++++--------------- .../include/lac/sparse_matrix_ez.templates.h | 50 +++++++++++++++-- deal.II/lac/source/sparse_matrix_ez.double.cc | 9 +++- deal.II/lac/source/sparse_matrix_ez.float.cc | 9 ++-- 5 files changed, 74 insertions(+), 60 deletions(-) diff --git a/deal.II/lac/include/lac/block_sparse_matrix_ez.h b/deal.II/lac/include/lac/block_sparse_matrix_ez.h index 7c883083f9..1356c11d85 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix_ez.h +++ b/deal.II/lac/include/lac/block_sparse_matrix_ez.h @@ -328,10 +328,10 @@ template inline SparseMatrixEZ & BlockSparseMatrixEZ::block (const unsigned int row, - const unsigned int column) + const unsigned int column) { - Assert (row inline const SparseMatrixEZ & BlockSparseMatrixEZ::block (const unsigned int row, - const unsigned int column) const + const unsigned int column) const { - Assert (row does not exist."); + << "The entry with index (" << arg1 << ',' << arg2 + << ") does not exist."); + DeclException2(ExcEntryAllocationFailure, + int, int, + << "An entry with index (" << arg1 << ',' << arg2 + << ") cannot be allocated."); private: /** * Find an entry. Return a @@ -1222,6 +1226,9 @@ SparseMatrixEZ::allocate (const unsigned int row, { if (end >= row_info[row+1].start) { + // Failure if increment 0 + Assert(increment!=0,ExcEntryAllocationFailure(row,col)); + // Insert new entries data.insert(data.begin()+end, increment, Entry()); // Update starts of @@ -1441,48 +1448,5 @@ SparseMatrixEZ::conjugate_add (const MATRIXA& A, } -template -template -void -SparseMatrixEZ::print_statistics(STREAM& out, bool full) -{ - typename std::vector::const_iterator row = row_info.begin(); - const typename std::vector::const_iterator endrow = row_info.end(); - - // Add up entries actually used - unsigned int entries_used = 0; - unsigned int max_length = 0; - for (; row != endrow ; ++ row) - { - entries_used += row->length; - if (max_length < row->length) - max_length = row->length; - } - - // Number of entries allocated is - // position of last entry used - --row; - unsigned int entries_alloc = row->start + row->length; - - out << "SparseMatrixEZ:used entries:" << entries_used << std::endl - << "SparseMatrixEZ:alloc entries:" << entries_alloc << std::endl - << "SparseMatrixEZ:reserved entries:" << data.capacity() << std::endl; - - if (full) - { - std::vector length_used (max_length+1); - - for (row = row_info.begin() ; row != endrow; ++row) - { - ++length_used[row->length]; - } - for (unsigned int i=0; i< length_used.size();++i) - if (length_used[i] != 0) - out << "SparseMatrixEZ:entries\t" << i - << "\trows\t" << length_used[i] - << std::endl; - } -} - #endif /*---------------------------- sparse_matrix.h ---------------------------*/ 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 b492c30fad..40b6bc6a81 100644 --- a/deal.II/lac/include/lac/sparse_matrix_ez.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix_ez.templates.h @@ -55,9 +55,9 @@ SparseMatrixEZ::~SparseMatrixEZ() template SparseMatrixEZ& -SparseMatrixEZ::operator= (const SparseMatrixEZ&) +SparseMatrixEZ::operator= (const SparseMatrixEZ& m) { - Assert (false, ExcNotImplemented()); + Assert (m.empty(), ExcInvalidConstructorCall()); return *this; } @@ -74,8 +74,6 @@ SparseMatrixEZ::reinit(unsigned int n_rows, default_row_length = 5; if (default_increment == Entry::invalid) default_increment = 4; - if (default_increment == 0) - default_increment = 4; increment = default_increment; n_columns = n_cols; @@ -360,4 +358,48 @@ SparseMatrixEZ::memory_consumption() const } +template +template +void +SparseMatrixEZ::print_statistics(STREAM& out, bool full) +{ + typename std::vector::const_iterator row = row_info.begin(); + const typename std::vector::const_iterator endrow = row_info.end(); + + // Add up entries actually used + unsigned int entries_used = 0; + unsigned int max_length = 0; + for (; row != endrow ; ++ row) + { + entries_used += row->length; + if (max_length < row->length) + max_length = row->length; + } + + // Number of entries allocated is + // position of last entry used + --row; + unsigned int entries_alloc = row->start + row->length; + + out << "SparseMatrixEZ:used entries:" << entries_used << std::endl + << "SparseMatrixEZ:alloc entries:" << entries_alloc << std::endl + << "SparseMatrixEZ:reserved entries:" << data.capacity() << std::endl; + + if (full) + { + std::vector length_used (max_length+1); + + for (row = row_info.begin() ; row != endrow; ++row) + { + ++length_used[row->length]; + } + for (unsigned int i=0; i< length_used.size();++i) + if (length_used[i] != 0) + out << "SparseMatrixEZ:entries\t" << i + << "\trows\t" << length_used[i] + << std::endl; + } +} + + #endif // __deal2__sparse_matrix_ez_templates_h diff --git a/deal.II/lac/source/sparse_matrix_ez.double.cc b/deal.II/lac/source/sparse_matrix_ez.double.cc index e42957d5e9..92530119b4 100644 --- a/deal.II/lac/source/sparse_matrix_ez.double.cc +++ b/deal.II/lac/source/sparse_matrix_ez.double.cc @@ -1,4 +1,4 @@ -//---------------------------- sparse_matrix_ez.double.cc --------------------------- +//------------------------------------------------------------------------ // $Id$ // Version: $Name$ // @@ -9,14 +9,19 @@ // to the file deal.II/doc/license.html for the text and // further information on this license. // -//---------------------------- sparse_matrix_ez.double.cc --------------------------- +//------------------------------------------------------------------------ +#include #include +#include #define TYPEMAT double template class SparseMatrixEZ; +template void SparseMatrixEZ::print_statistics(ostream&, bool); +template void SparseMatrixEZ::print_statistics(LogStream&, bool); + #define TYPE2 float diff --git a/deal.II/lac/source/sparse_matrix_ez.float.cc b/deal.II/lac/source/sparse_matrix_ez.float.cc index e20c9c6834..ddb2ddde1c 100644 --- a/deal.II/lac/source/sparse_matrix_ez.float.cc +++ b/deal.II/lac/source/sparse_matrix_ez.float.cc @@ -1,4 +1,4 @@ -//---------------------------- sparse_matrix_ez.float.cc --------------------------- +//------------------------------------------------------------------------- // $Id$ // Version: $Name$ // @@ -9,14 +9,17 @@ // to the file deal.II/doc/license.html for the text and // further information on this license. // -//---------------------------- sparse_matrix_ez.float.cc --------------------------- - +//------------------------------------------------------------------------- +#include #include +#include #define TYPEMAT float template class SparseMatrixEZ; +template void SparseMatrixEZ::print_statistics(ostream&, bool); +template void SparseMatrixEZ::print_statistics(LogStream&, bool); #define TYPE2 float -- 2.39.5