From 55bc908d14315bc438c7877793c54e354a90b9c3 Mon Sep 17 00:00:00 2001 From: guido Date: Tue, 18 May 2004 11:33:11 +0000 Subject: [PATCH] changes applied to EZ-matrices, exception moved, documentation fixed git-svn-id: https://svn.dealii.org/trunk@9252 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/block_sparse_matrix.h | 4 ---- .../lac/include/lac/block_sparse_matrix_ez.h | 21 ++++++++++++++++++- .../lac/block_sparse_matrix_ez.templates.h | 17 ++++++++++++++- deal.II/lac/include/lac/full_matrix.h | 20 +++++------------- deal.II/lac/include/lac/petsc_matrix_base.h | 4 ---- deal.II/lac/include/lac/sparse_matrix.h | 4 ---- deal.II/lac/include/lac/sparse_matrix_ez.h | 18 ++++++++++++++++ .../include/lac/sparse_matrix_ez.templates.h | 21 ++++++++++++++++++- 8 files changed, 79 insertions(+), 30 deletions(-) diff --git a/deal.II/lac/include/lac/block_sparse_matrix.h b/deal.II/lac/include/lac/block_sparse_matrix.h index 92f2917c8e..7c2b4346a5 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix.h +++ b/deal.II/lac/include/lac/block_sparse_matrix.h @@ -896,10 +896,6 @@ class BlockSparseMatrix : public Subscriptor * Exception */ DeclException0 (ExcMatrixNotInitialized); - /** - * Exception - */ - DeclException0 (ExcScalarAssignmentOnlyForZeroValue); private: /** 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 0d8ea22f7b..ac7b949d1b 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix_ez.h +++ b/deal.II/lac/include/lac/block_sparse_matrix_ez.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2002, 2003 by the deal.II authors +// Copyright (C) 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -80,6 +80,25 @@ class BlockSparseMatrixEZ : public Subscriptor */ BlockSparseMatrixEZ & operator = (const BlockSparseMatrixEZ&); + /** + * This operator assigns a scalar to + * a matrix. Since this does usually + * not make much sense (should we set + * all matrix entries to this value? + * Only the nonzero entries of the + * sparsity pattern?), this operation + * is only allowed if the actual + * value to be assigned is zero. This + * operator only exists to allow for + * the obvious notation + * matrix=0, which sets all + * elements of the matrix to zero, + * but keep the sparsity pattern + * previously used. + */ + BlockSparseMatrixEZ & operator = (const double d); + + /** * Set matrix to zero dimensions * and release memory. diff --git a/deal.II/lac/include/lac/block_sparse_matrix_ez.templates.h b/deal.II/lac/include/lac/block_sparse_matrix_ez.templates.h index 31dacb2e6a..49d835bae1 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix_ez.templates.h +++ b/deal.II/lac/include/lac/block_sparse_matrix_ez.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2002, 2003 by the deal.II authors +// Copyright (C) 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -77,6 +77,21 @@ operator = (const BlockSparseMatrixEZ &m) +template +BlockSparseMatrixEZ & +BlockSparseMatrixEZ::operator = (const double d) +{ + Assert (d==0, ExcScalarAssignmentOnlyForZeroValue()); + + for (unsigned int r=0; r BlockSparseMatrixEZ::BlockSparseMatrixEZ ( const BlockSparseMatrixEZ &m) diff --git a/deal.II/lac/include/lac/full_matrix.h b/deal.II/lac/include/lac/full_matrix.h index 9d0de45e91..6bb359b3aa 100644 --- a/deal.II/lac/include/lac/full_matrix.h +++ b/deal.II/lac/include/lac/full_matrix.h @@ -251,17 +251,11 @@ class FullMatrix : public Table<2,number> operator = (const FullMatrix&); /** - * This operator assigns a scalar to a - * matrix. Since this does usually not - * make much sense (should we set all - * matrix entries to this value? Only the - * nonzero entries of the sparsity - * pattern?), this operation is only - * allowed if the actual value to be - * assigned is zero. This operator only - * exists to allow for the obvious - * notation matrix=0, which sets - * all elements of the matrix to zero. + * This operator assigns a scalar + * to a matrix. To avoid + * confusion with constructors, + * zero is the only value allowed + * for d */ FullMatrix & operator = (const double d); @@ -981,10 +975,6 @@ class FullMatrix : public Table<2,number> << "Target region not in matrix: size in this direction=" << arg1 << ", size of new matrix=" << arg2 << ", offset=" << arg3); - /** - * Exception - */ - DeclException0 (ExcScalarAssignmentOnlyForZeroValue); /** * Exception */ diff --git a/deal.II/lac/include/lac/petsc_matrix_base.h b/deal.II/lac/include/lac/petsc_matrix_base.h index a5ab43a3f3..f3d4ef3cd0 100644 --- a/deal.II/lac/include/lac/petsc_matrix_base.h +++ b/deal.II/lac/include/lac/petsc_matrix_base.h @@ -657,10 +657,6 @@ namespace PETScWrappers * Exception */ DeclException0 (ExcMatrixNotSquare); - /** - * Exception - */ - DeclException0 (ExcScalarAssignmentOnlyForZeroValue); protected: /** diff --git a/deal.II/lac/include/lac/sparse_matrix.h b/deal.II/lac/include/lac/sparse_matrix.h index cf7c480450..a4f1243ec8 100644 --- a/deal.II/lac/include/lac/sparse_matrix.h +++ b/deal.II/lac/include/lac/sparse_matrix.h @@ -1504,10 +1504,6 @@ class SparseMatrix : public virtual Subscriptor * Exception */ DeclException0 (ExcSourceEqualsDestination); - /** - * Exception - */ - DeclException0 (ExcScalarAssignmentOnlyForZeroValue); private: /** diff --git a/deal.II/lac/include/lac/sparse_matrix_ez.h b/deal.II/lac/include/lac/sparse_matrix_ez.h index 187430774d..b7b306ada8 100644 --- a/deal.II/lac/include/lac/sparse_matrix_ez.h +++ b/deal.II/lac/include/lac/sparse_matrix_ez.h @@ -385,6 +385,24 @@ class SparseMatrixEZ : public Subscriptor */ SparseMatrixEZ& operator = (const SparseMatrixEZ &); + /** + * This operator assigns a scalar to + * a matrix. Since this does usually + * not make much sense (should we set + * all matrix entries to this value? + * Only the nonzero entries of the + * sparsity pattern?), this operation + * is only allowed if the actual + * value to be assigned is zero. This + * operator only exists to allow for + * the obvious notation + * matrix=0, which sets all + * elements of the matrix to zero, + * but keep the sparsity pattern + * previously used. + */ + SparseMatrixEZ& operator = (const double d); + /** * Reinitialize the sparse matrix * to the dimensions provided. 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 cd1ea7b5fd..8fbedad977 100644 --- a/deal.II/lac/include/lac/sparse_matrix_ez.templates.h +++ b/deal.II/lac/include/lac/sparse_matrix_ez.templates.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2002, 2003 by the deal.II authors +// Copyright (C) 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -63,6 +63,25 @@ SparseMatrixEZ::operator= (const SparseMatrixEZ& m) } +template +SparseMatrixEZ & +SparseMatrixEZ::operator = (const double d) +{ + Assert (d==0, ExcScalarAssignmentOnlyForZeroValue()); + + typename std::vector::iterator e = data.begin(); + const typename std::vector::iterator end = data.end(); + + while (e != end) + { + (e++)->value = 0.; + } + + return *this; +} + + + template void SparseMatrixEZ::reinit(const unsigned int n_rows, -- 2.39.5