]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
BlockMatrix now has function el()
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 21 Aug 2001 16:12:48 +0000 (16:12 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 21 Aug 2001 16:12:48 +0000 (16:12 +0000)
git-svn-id: https://svn.dealii.org/trunk@4902 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/2001/c-3-1.html
deal.II/lac/include/lac/block_sparse_matrix.h

index 99ee2b3e84f7be9527d03ddb50f3aa06ebd46c03..77bb3a4f4474473fe761dbd48633670ee7a71da2 100644 (file)
@@ -331,6 +331,13 @@ documentation, etc</a>.
 <h3>lac</h3>
 
 <ol>
+  <li> <p>
+       New: Function <code class="class">BlockSparseMatrix::el()</code>,
+       just like <code class="class">SparseMatrix::el()</code>.
+       <br>
+       (WB 2001/08/21)
+       </p>
+
   <li> <p>
        New: There is now a class <code class="class">MatrixOut</code>
        which can be used to convert a matrix into a graphical output,
index 6de57cdea9343ad885caa635278577c19cefa67b..786bf61fafce47b8763147c48f3a2c7546fe020e 100644 (file)
@@ -236,7 +236,6 @@ class BlockSparseMatrix : public Subscriptor
                                      * matrix is of dimension
                                      * $m \times n$.
                                      */
-
     unsigned int n () const;
 
                                     /**
@@ -251,10 +250,12 @@ class BlockSparseMatrix : public Subscriptor
     unsigned int n_nonzero_elements () const;
     
                                     /**
-                                     * Set the element @p{(i,j)} to @p{value}.
-                                     * Throws an error if the entry does
-                                     * not exist. Still, it is allowed to store
-                                     * zero values in non-existent fields.
+                                     * Set the element @p{(i,j)} to
+                                     * @p{value}.  Throws an error if
+                                     * the entry does not
+                                     * exist. Still, it is allowed to
+                                     * store zero values in
+                                     * non-existent fields.
                                      */
     void set (const unsigned int i,
              const unsigned int j,
@@ -312,27 +313,49 @@ class BlockSparseMatrix : public Subscriptor
                                      * since in this case the
                                      * operation is cheaper.
                                      *
-                                     * The source matrix may be a matrix
-                                     * of arbitrary type, as long as its
-                                     * data type is convertible to the
-                                     * data type of this matrix.
+                                     * The source matrix may be a
+                                     * matrix of arbitrary type, as
+                                     * long as its data type is
+                                     * convertible to the data type
+                                     * of this matrix.
                                      */
     template <typename somenumber>
     void add_scaled (const number factor,
                     const BlockSparseMatrix<somenumber> &matrix);
     
                                     /**
-                                     * Return the value of the entry (i,j).
-                                     * This may be an expensive operation
-                                     * and you should always take care
-                                     * where to call this function.
-                                     * In order to avoid abuse, this function
-                                     * throws an exception if the wanted
-                                     * element does not exist in the matrix.
+                                     * Return the value of the entry
+                                     * (i,j).  This may be an
+                                     * expensive operation and you
+                                     * should always take care where
+                                     * to call this function.  In
+                                     * order to avoid abuse, this
+                                     * function throws an exception
+                                     * if the wanted element does not
+                                     * exist in the matrix.
                                      */
     number operator () (const unsigned int i,
                        const unsigned int j) const;
 
+                                    /**
+                                     * This function is mostly like
+                                     * @p{operator()} in that it
+                                     * returns the value of the
+                                     * matrix entry @p{(i,j)}. The only
+                                     * difference is that if this
+                                     * entry does not exist in the
+                                     * sparsity pattern, then instead
+                                     * of raising an exception, zero
+                                     * is returned. While this may be
+                                     * convenient in some cases, note
+                                     * that it is simple to write
+                                     * algorithms that are slow
+                                     * compared to an optimal
+                                     * solution, since the sparsity
+                                     * of the matrix is not used.
+                                     */
+    number el (const unsigned int i,
+              const unsigned int j) const;
 
                                     /**
                                      * Matrix-vector multiplication:
@@ -619,6 +642,21 @@ BlockSparseMatrix<number>::operator () (const unsigned int i,
 
 
 
+template <typename number>
+inline
+number
+BlockSparseMatrix<number>::el (const unsigned int i,
+                              const unsigned int j) const
+{
+  const std::pair<unsigned int,unsigned int>
+    row_index = sparsity_pattern->row_indices.global_to_local (i),
+    col_index = sparsity_pattern->column_indices.global_to_local (j);
+  return block(row_index.first,col_index.first).el (row_index.second,
+                                                   col_index.second);
+};
+
+
+
 
 template <typename number>
 template <typename somenumber>

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.