]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add function diag_element.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 26 Jul 2004 18:05:59 +0000 (18:05 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 26 Jul 2004 18:05:59 +0000 (18:05 +0000)
git-svn-id: https://svn.dealii.org/trunk@9520 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/block_matrix_base.h

index 919bbd51799212eb8a6ac8dfde3a2ca4624a7026..995131ccb74fd6f2c86d216fee08694e4acdbf24 100644 (file)
@@ -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 <i>i</i>th 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<MatrixType>::el (const unsigned int i,
 
 
 
+template <class MatrixType>
+inline
+typename BlockMatrixBase<MatrixType>::value_type
+BlockMatrixBase<MatrixType>::diag_element (const unsigned int i) const
+{
+  Assert (n_block_rows() == n_block_cols(),
+          ExcMatrixNotBlockSquare());
+
+  const std::pair<unsigned int,unsigned int>
+    index = row_block_indices.global_to_local (i);
+  return block(index.first,index.first).diag_element(index.second);
+}
+
+
+
 template <class MatrixType>
 inline
 void

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.