From: wolf Date: Tue, 21 Aug 2001 16:12:48 +0000 (+0000) Subject: BlockMatrix now has function el() X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28c442e8b96fa864ddeb11742893668d09d5bbab;p=dealii-svn.git BlockMatrix now has function el() git-svn-id: https://svn.dealii.org/trunk@4902 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/2001/c-3-1.html b/deal.II/doc/news/2001/c-3-1.html index 99ee2b3e84..77bb3a4f44 100644 --- a/deal.II/doc/news/2001/c-3-1.html +++ b/deal.II/doc/news/2001/c-3-1.html @@ -331,6 +331,13 @@ documentation, etc.

lac

    +
  1. + New: Function BlockSparseMatrix::el(), + just like SparseMatrix::el(). +
    + (WB 2001/08/21) +

    +
  2. New: There is now a class MatrixOut which can be used to convert a matrix into a graphical output, diff --git a/deal.II/lac/include/lac/block_sparse_matrix.h b/deal.II/lac/include/lac/block_sparse_matrix.h index 6de57cdea9..786bf61faf 100644 --- a/deal.II/lac/include/lac/block_sparse_matrix.h +++ b/deal.II/lac/include/lac/block_sparse_matrix.h @@ -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 void add_scaled (const number factor, const BlockSparseMatrix &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::operator () (const unsigned int i, +template +inline +number +BlockSparseMatrix::el (const unsigned int i, + const unsigned int j) const +{ + const std::pair + 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 template