]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Let copy constructor from IdentityMatrix to FullMatrix not be explicit any more....
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 14 Aug 2012 06:58:05 +0000 (06:58 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 14 Aug 2012 06:58:05 +0000 (06:58 +0000)
git-svn-id: https://svn.dealii.org/trunk@25961 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.h
deal.II/include/deal.II/lac/full_matrix.h
tests/lac/identity_matrix_06.cc [new file with mode: 0644]
tests/lac/identity_matrix_06/cmp/generic [new file with mode: 0644]

index a4751585b27769131f57120cf0a0d632da250db0..1c45b5f3cd487b6ee20672fb9ffe83439efde58f 100644 (file)
@@ -276,6 +276,12 @@ enabled due to a missing include file in file
 <h3>Specific improvements</h3>
 
 <ol>
+<li> New: The copy constructor of FullMatrix from IdentityMatrix
+used to be explicit, but that didn't appear to be necessary in hindsight.
+Consequently, it is now a regular copy constructor.
+<br>
+(Wolfgang Bangerth, 2012/08/14)
+
 <li> New: The Patterns::Map pattern allows to describe maps from keys
 to values in input files.
 <br>
index 6e33ecc93a4854de2ba447be5d86c5c2302fc9bc..eab4bd0d8d0131355a388978b7f8fbe88d874e9a 100644 (file)
@@ -290,7 +290,7 @@ class FullMatrix : public Table<2,number>
                                       * FullMatrix<double> M(IdentityMatrix(n));
                                       * @endverbatim
                                       */
-    explicit FullMatrix (const IdentityMatrix &id);
+    FullMatrix (const IdentityMatrix &id);
     /**
      * @}
      */
@@ -921,10 +921,12 @@ class FullMatrix : public Table<2,number>
                const unsigned int src_offset_j = 0);
 
                                      /**
-                                      * Adda single element at the
+                                      * Add a single element at the
                                       * given position.
                                       */
-    void add(const unsigned int row, const unsigned int column, const number value);
+    void add (const unsigned int row,
+             const unsigned int column,
+             const number value);
 
                                        /**
                                         * Add an array of values given by
diff --git a/tests/lac/identity_matrix_06.cc b/tests/lac/identity_matrix_06.cc
new file mode 100644 (file)
index 0000000..4478492
--- /dev/null
@@ -0,0 +1,81 @@
+//---------------------------------------------------------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 2005, 2006, 2012 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+// check assignment from IdentityMatrix to FullMatrix using the syntax
+//     FullMatrix<number> M = IdentityMatrix(4);
+// this didn't work initially because the copy constructor in FullMatrix
+// was explicit; however, in hindsight, I can't see a good reason for
+// it to be explicit.
+
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/identity_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <fstream>
+#include <iomanip>
+#include <cmath>
+
+template<typename number>
+void
+check_vmult()
+{
+  FullMatrix<number> M = IdentityMatrix(4);
+  Vector<number> u(4);
+  Vector<number> v(4);
+
+  for (unsigned int i=0;i<4;++i)
+    u(i) = i+1;
+
+  M.vmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.vmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult(v,u);
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+
+  M.Tvmult_add(v,u);
+  v /= 2;
+  Assert (v == u, ExcInternalError());
+  for (unsigned int i=0;i<v.size();++i)
+    deallog << ' ' << v(i);
+  deallog << std::endl;
+}
+
+
+int main()
+{
+  std::ofstream logfile("identity_matrix_06/output");
+  logfile.setf(std::ios::fixed);
+  deallog << std::setprecision(0);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  check_vmult<double>();
+  check_vmult<float>();
+}
diff --git a/tests/lac/identity_matrix_06/cmp/generic b/tests/lac/identity_matrix_06/cmp/generic
new file mode 100644 (file)
index 0000000..29bcfce
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.
+DEAL:: 1. 2. 3. 4.

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.