From 0f13413c2a5d4e47302a047569ff1be9c4fc45f6 Mon Sep 17 00:00:00 2001 From: wolf Date: Mon, 26 Jul 2004 18:05:59 +0000 Subject: [PATCH] Add function diag_element. git-svn-id: https://svn.dealii.org/trunk@9520 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/block_matrix_base.h | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/deal.II/lac/include/lac/block_matrix_base.h b/deal.II/lac/include/lac/block_matrix_base.h index 919bbd5179..995131ccb7 100644 --- a/deal.II/lac/include/lac/block_matrix_base.h +++ b/deal.II/lac/include/lac/block_matrix_base.h @@ -450,6 +450,25 @@ class BlockMatrixBase : public Subscriptor value_type el (const unsigned int i, const unsigned int j) const; + /** + * Return the main diagonal element in + * the ith row. This function + * throws an error if the matrix is not + * quadratic and also if the diagonal + * blocks of the matrix are not + * quadratic. + * + * This function is considerably + * faster than the operator()(), + * since for quadratic matrices, the + * diagonal entry may be the + * first to be stored in each row + * and access therefore does not + * involve searching for the + * right column number. + */ + value_type diag_element (const unsigned int i) const; + /** * Call the compress() function on all * the subblocks of the matrix. @@ -1377,6 +1396,21 @@ BlockMatrixBase::el (const unsigned int i, +template +inline +typename BlockMatrixBase::value_type +BlockMatrixBase::diag_element (const unsigned int i) const +{ + Assert (n_block_rows() == n_block_cols(), + ExcMatrixNotBlockSquare()); + + const std::pair + index = row_block_indices.global_to_local (i); + return block(index.first,index.first).diag_element(index.second); +} + + + template inline void -- 2.39.5