]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add operator*=(number) variant to LinearOperator
authorMatthias Maier <tamiko@43-1.org>
Sun, 26 Apr 2015 11:36:36 +0000 (13:36 +0200)
committerMatthias Maier <tamiko@43-1.org>
Sun, 26 Apr 2015 19:10:55 +0000 (21:10 +0200)
include/deal.II/lac/linear_operator.h
tests/lac/linear_operator_01.cc
tests/lac/linear_operator_01.with_cxx11=on.output
tests/lac/linear_operator_02.cc
tests/lac/linear_operator_02.with_cxx11=on.output

index d1479c2a2553e61f5b5da8d65eaf0402d7d44ba8..0366e3520562f23293ad86218ad61887b18d6f9f 100644 (file)
@@ -257,6 +257,18 @@ public:
     *this = *this * second_op;
     return *this;
   }
+
+  /**
+   * Scalar multiplication of the LinearOperator with @p number from the
+   * right.
+   */
+  LinearOperator<Range, Domain>
+  operator*=(typename Domain::value_type  number)
+  {
+    *this = *this * number;
+    return *this;
+  }
+
 };
 
 
index f227822c6634dd49b770ad0ca8f2b5a11d42964a..5b7fe75ece492791b5fd4b0f2e2c1c4771137d52 100644 (file)
@@ -194,6 +194,11 @@ int main()
   test.vmult(v, u);
   deallog << "(4 * 4) * " << u.value << " = " << v.value << std::endl;
 
+  test = multiply4;
+  test *= 4.;
+  test.vmult(v, u);
+  deallog << "(4 * 4) * " << u.value << " = " << v.value << std::endl;
+
   test = multiply4 * 4.;
   test.vmult(v, u);
   deallog << "(4 * 4) * " << u.value << " = " << v.value << std::endl;
@@ -205,6 +210,10 @@ int main()
   test2.vmult(w, u);
   deallog << "(2 * 4) * " << u.value << " = " << w.value << std::endl;
 
+  test2 *= identity_operator(test2.reinit_range_vector);
+  test2.vmult(w, u);
+  deallog << "(2 * 4) * 1 * " << u.value << " = " << w.value << std::endl;
+
   // identity
 
   auto test3 = identity_operator(test2.reinit_range_vector) + test2;
index 95b24c5f4c985519c2c182451f06914706dc5a01..2bceae3a833eba161ba14db96d938ff3081a0ee6 100644 (file)
@@ -13,5 +13,7 @@ DEAL::(2 - 4 + 2) * 24.0000 = 0.00000
 DEAL::(2 - 4 + 2 - 4) * 24.0000 = -96.0000
 DEAL::(4 * 4) * 24.0000 = 384.000
 DEAL::(4 * 4) * 24.0000 = 384.000
+DEAL::(4 * 4) * 24.0000 = 384.000
 DEAL::(2 * 4) * 24.0000 = 192.000
+DEAL::(2 * 4) * 1 * 24.0000 = 192.000
 DEAL::(1 + 2 * 4) * 24.0000 = 216.000
index 3fd049146352837fbdc26a29b572e655be81b1d9..be5d0cd494a430d521fef55d9357ab0699ca5329 100644 (file)
@@ -142,6 +142,10 @@ int main()
   op_x.vmult(x, u);
   deallog << "(A*=B)u: " << x << std::endl;
 
+  op_x *= 4.;
+  op_x.vmult(x, u);
+  deallog << "(A*=B*=4.)u: " << x << std::endl;
+
   // solver interface:
 
   SolverControl solver_control (1000, 1e-12);
index a1c91305e160a1581aa406691d06abf211de8d1d..923dc7ed25e5499f16fa92b71ce622fce4b3954c 100644 (file)
@@ -23,6 +23,8 @@ DEAL::(A*B)u: -0.1073495370 -0.1866319444 -0.2039930556 -0.02199074074 -0.289351
 DEAL::
 DEAL::(A*=B)u: -0.1073495370 -0.1866319444 -0.2039930556 -0.02199074074 -0.2893518519 -0.07465277778 -0.3703703704 0.03877314815 -0.2986111111 -0.1487268519 0.6250000000 -0.2201967593 -0.2123842593 0.4710648148 -0.4762731481 -0.1672453704 1.145833333 0.8049768519 -0.3211805556 -0.2199074074 -0.4939236111 1.570023148 -0.2034143519 -0.2300347222 -0.4094328704 
 DEAL::
+DEAL::(A*=B*=4.)u: -0.4293981481 -0.7465277778 -0.8159722222 -0.08796296296 -1.157407407 -0.2986111111 -1.481481481 0.1550925926 -1.194444444 -0.5949074074 2.500000000 -0.8807870370 -0.8495370370 1.884259259 -1.905092593 -0.6689814815 4.583333333 3.219907407 -1.284722222 -0.8796296296 -1.975694444 6.280092593 -0.8136574074 -0.9201388889 -1.637731481 
+DEAL::
 DEAL::solve(B, v, u): 80.16326531 28.24489796 86.53061224 25.79591837 259.4285714 57.14285714 328.0000000 88.00000000 184.0000000 226.6122449 40.48979592 1446.693878 315.7551020 160.0000000 760.0000000 387.7551020 81.63265306 190.8571429 2286.693878 470.0408163 1140.571429 108.0816327 569.9591837 539.1020408 3018.448980 
 DEAL::
 DEAL::inverse_operator(B)u: 80.16326531 28.24489796 86.53061224 25.79591837 259.4285714 57.14285714 328.0000000 88.00000000 184.0000000 226.6122449 40.48979592 1446.693878 315.7551020 160.0000000 760.0000000 387.7551020 81.63265306 190.8571429 2286.693878 470.0408163 1140.571429 108.0816327 569.9591837 539.1020408 3018.448980 

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.