]> https://gitweb.dealii.org/ - dealii.git/commitdiff
SparseMatrix::reinit(): accept other sparse matrix 12863/head
authorPeter Munch <peterrmuench@gmail.com>
Fri, 22 Oct 2021 16:54:46 +0000 (18:54 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Sun, 24 Oct 2021 19:47:15 +0000 (21:47 +0200)
include/deal.II/lac/sparse_matrix.h

index d707f1f38ef5e7af95d969661914794a0216891c..2cd998e33cffb7ed4230bb44456e27c5e0d74200 100644 (file)
@@ -696,6 +696,16 @@ public:
   virtual void
   reinit(const SparsityPattern &sparsity);
 
+  /**
+   * Reinitialize the sparse matrix with the sparsity pattern of the given
+   * @p sparse_matrix. See also comments of the function above.
+   *
+   * @note The elements of the matrix are set to zero by this function.
+   */
+  template <typename number2>
+  void
+  reinit(const SparseMatrix<number2> &sparse_matrix);
+
   /**
    * Release all memory and return to a state just like after having called
    * the default constructor. It also forgets the sparsity pattern it was
@@ -1787,6 +1797,16 @@ private:
 
 
 
+template <typename number>
+template <typename number2>
+void
+SparseMatrix<number>::reinit(const SparseMatrix<number2> &sparse_matrix)
+{
+  this->reinit(sparse_matrix.get_sparsity_pattern());
+}
+
+
+
 template <typename number>
 inline typename SparseMatrix<number>::size_type
 SparseMatrix<number>::m() const

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.