]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add another BlockLinearOperator example.
authorDavid Wells <wellsd2@rpi.edu>
Sat, 28 Oct 2017 21:35:33 +0000 (17:35 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Sun, 29 Oct 2017 19:29:12 +0000 (15:29 -0400)
include/deal.II/lac/block_linear_operator.h

index ccb43b12a2f3ce4004230016d651404bc9d24f52..3afeb24ca36aa119c4e5beeca025dd2c98ea4eba 100644 (file)
@@ -122,6 +122,39 @@ block_back_substitution(const BlockLinearOperator<Range, Domain, BlockPayload> &
  * const auto block_op_a = block_operator(A);
  * @endcode
  *
+ * Alternatively, there are several helper functions available for creating
+ * instances from multiple independent matrices of possibly different types.
+ * Here is an example of a block diagonal matrix created from a FullMatrix and
+ * a SparseMatrixEZ:
+ *
+ * @code
+ * FullMatrix<double> top_left(2, 2);
+ * top_left(0, 0) = 2.0;
+ * top_left(0, 1) = -1.0;
+ * top_left(1, 0) = -1.0;
+ * top_left(1, 1) = 2.0;
+ *
+ * SparseMatrixEZ<double> bottom_right(4, 4, 4);
+ * for (std::size_t row_n = 0; row_n < 4; ++row_n)
+ *   {
+ *     bottom_right.add(row_n, row_n, 1.0);
+ *     if (row_n < 3)
+ *       bottom_right.add(row_n, row_n + 1, -1.0);
+ *   }
+ *
+ * auto top_left_op = linear_operator(top_left);
+ * auto bottom_right_op = linear_operator(bottom_right);
+ * std::array<decltype(top_left_op), 2> operators {{top_left_op, bottom_right_op}};
+ * auto block_op = block_diagonal_operator (operators);
+ *
+ * std::vector<BlockVector<double>::size_type> block_sizes {2, 4};
+ * BlockVector<double> src(block_sizes);
+ * src = 2.0;
+ * BlockVector<double> dst(block_sizes);
+ * block_op.vmult(dst, src); // now equal to 2, 2, 0, 0, 0, 2
+ * @endcode
+ *
+ *
  * A BlockLinearOperator can be sliced to a LinearOperator at any time. This
  * removes all information about the underlying block structure (because above
  * <code>std::function</code> objects are no longer available) - the linear

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.