]> https://gitweb.dealii.org/ - dealii.git/commitdiff
null operator 986/head
authorESeNonFossiIo <esenonfossiio@gmail.com>
Tue, 2 Jun 2015 10:39:38 +0000 (12:39 +0200)
committerESeNonFossiIo <esenonfossiio@gmail.com>
Tue, 2 Jun 2015 10:39:38 +0000 (12:39 +0200)
include/deal.II/lac/linear_operator.h
tests/lac/linear_operator_01.cc
tests/lac/linear_operator_01.with_cxx11=on.output

index e74aa2cf9ae0c7476e3ba26c560c49b7d1ca1766..5992a917651133af8b5e9a6677dd6a98a1ec002c 100644 (file)
@@ -682,6 +682,48 @@ identity_operator(const std::function<void(Range &, bool)> &reinit_vector)
 }
 
 
+/**
+ * @relates LinearOperator
+ *
+ * Returns a LinearOperator that is the null operator of the vector space
+ * @p Range.
+ *
+ * The function takes an <code>std::function</code> object @ref
+ * reinit_vector as an argument to initialize the
+ * <code>reinit_range_vector</code> and <code>reinit_domain_vector</code>
+ * objects of the LinearOperator object.
+ *
+ * @ingroup LAOperators
+ */
+template <typename Range>
+LinearOperator<Range, Range>
+null_operator(const std::function<void(Range &, bool)> &reinit_vector)
+{
+  LinearOperator<Range, Range> return_op;
+
+  return_op.reinit_range_vector = reinit_vector;
+  return_op.reinit_domain_vector = reinit_vector;
+
+  return_op.vmult = [](Range &v, const Range &u)
+  {
+    v = 0;
+  };
+
+  return_op.vmult_add = [](Range &v, const Range &u)
+  {};
+
+  return_op.Tvmult = [](Range &v, const Range &u)
+  {
+    v = 0;
+  };
+
+  return_op.Tvmult_add = [](Range &v, const Range &u)
+  {};
+
+  return return_op;
+}
+
+
 namespace internal
 {
   namespace LinearOperator
index 31eb357d3bca21a961958c390e6296dfbf841db1..2ed27d9611bd84173203324d032ef24173879df4 100644 (file)
@@ -229,4 +229,11 @@ int main()
   auto test3 = identity_operator(test2.reinit_range_vector) + test2;
   test3.vmult(w, u);
   deallog << "(1 + 2 * 4) * " << u.value << " = " << w.value << std::endl;
+
+  // null operator
+
+  auto test4 = null_operator(test2.reinit_range_vector);
+  test4.vmult(w, u);
+  deallog << " 0 * " << u.value << " = " << w.value << std::endl;
+
 }
index 2bceae3a833eba161ba14db96d938ff3081a0ee6..c910ee55b3311479feba4d35df63e60c2a1c237c 100644 (file)
@@ -17,3 +17,4 @@ 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
+DEAL:: 0 * 24.0000 = 0.00000

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.