]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
add a function to copy from a transposed matrix
authorkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 23 Mar 2012 21:55:11 +0000 (21:55 +0000)
committerkanschat <kanschat@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 23 Mar 2012 21:55:11 +0000 (21:55 +0000)
git-svn-id: https://svn.dealii.org/trunk@25321 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/lac/full_matrix.h

index 4f69a546e4232dcf8d16bd55d58f39b7f7db33c7..a21c499a141ba94d2224bb1fc3589f816849cb11 100644 (file)
@@ -354,6 +354,17 @@ class FullMatrix : public Table<2,number>
     template <class MATRIX>
     void copy_from (const MATRIX&);
 
+                                     /**
+                                     * Transposing assignment from
+                                     * different matrix classes. This
+                                     * assignment operator uses
+                                     * iterators of the class
+                                     * MATRIX. Therefore, sparse
+                                     * matrices are possible sources.
+                                     */
+    template <class MATRIX>
+    void copy_transposed (const MATRIX&);
+
                                     /**
                                      * Fill rectangular block.
                                      *
@@ -1427,6 +1438,19 @@ FullMatrix<number>::copy_from (const MATRIX& M)
 }
 
 
+template <typename number>
+template <class MATRIX>
+void
+FullMatrix<number>::copy_transposed (const MATRIX& M)
+{
+  this->reinit (M.n(), M.m());
+  const typename MATRIX::const_iterator end = M.end();
+  for (typename MATRIX::const_iterator entry = M.begin();
+       entry != end; ++entry)
+    this->el(entry->column(), entry->row()) = entry->value();
+}
+
+
 template <typename number>
 template<typename number2>
 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.