]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix bug pointed out by Alexander Grayver.
authorkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 4 May 2012 18:01:21 +0000 (18:01 +0000)
committerkronbichler <kronbichler@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 4 May 2012 18:01:21 +0000 (18:01 +0000)
git-svn-id: https://svn.dealii.org/trunk@25489 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/include/deal.II/base/tensor_base.h
tests/base/tensor_06.cc [new file with mode: 0644]
tests/base/tensor_06/cmp/generic [new file with mode: 0644]

index 08bc4dbe3f87fef395fc7a8a463b10d2b70865cd..252fe3546abdd3ca0a470086a446869645b36619 100644 (file)
@@ -1125,7 +1125,7 @@ Tensor<1,dim,Number>::operator * (const Tensor<1,dim,Number> &p) const
               values[2] * p.values[2]);
       break;
     default:
-      Number q = values[0] * values[0];
+      Number q = values[0] * p.values[0];
       for (unsigned int i=1; i<dim; ++i)
         q += values[i] * p.values[i];
       return q;
diff --git a/tests/base/tensor_06.cc b/tests/base/tensor_06.cc
new file mode 100644 (file)
index 0000000..b964836
--- /dev/null
@@ -0,0 +1,49 @@
+//----------------------------  tensor_06.cc  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 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.
+//
+//----------------------------  tensor_06.cc  ---------------------------
+
+// check Tensor<1,dim>::operator*(Tensor<1,dim>)
+
+#include "../tests.h"
+#include <deal.II/base/tensor.h>
+#include <deal.II/base/logstream.h>
+#include <fstream>
+#include <iomanip>
+
+template <int dim>
+void test_tensor ()
+{
+  Tensor<1,dim> t1, t2;
+  for (unsigned int i=0; i<dim; ++i)
+    {
+      t1[i] = i+1;
+      t2[i] = 4.*i-10.;
+    }
+  double res = t1 * t2;
+  deallog << "dim = " << dim << ": " << res << std::endl;
+}
+
+int main ()
+{
+  std::ofstream logfile("tensor_06/output");
+  deallog << std::setprecision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  test_tensor<1>();
+  test_tensor<2>();
+  test_tensor<3>();
+  test_tensor<4>();
+  test_tensor<7>();
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/base/tensor_06/cmp/generic b/tests/base/tensor_06/cmp/generic
new file mode 100644 (file)
index 0000000..097a080
--- /dev/null
@@ -0,0 +1,7 @@
+
+DEAL::dim = 1: -10.0
+DEAL::dim = 2: -22.0
+DEAL::dim = 3: -28.0
+DEAL::dim = 4: -20.0
+DEAL::dim = 7: 168.
+DEAL::OK

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.