Reference documentation for deal.II version 9.0.0
Public Member Functions | Public Attributes | List of all members
BlockLinearOperator< Range, Domain, BlockPayload > Class Template Reference

#include <deal.II/lac/block_linear_operator.h>

Inheritance diagram for BlockLinearOperator< Range, Domain, BlockPayload >:
[legend]

Public Member Functions

 BlockLinearOperator (const BlockPayload &payload)
 
 BlockLinearOperator (const BlockLinearOperator< Range, Domain, BlockPayload > &)=default
 
template<typename Op >
 BlockLinearOperator (const Op &op)
 
template<size_t m, size_t n>
 BlockLinearOperator (const std::array< std::array< BlockType, n >, m > &ops)
 
template<size_t m>
 BlockLinearOperator (const std::array< BlockType, m > &ops)
 
BlockLinearOperator< Range, Domain, BlockPayload > & operator= (const BlockLinearOperator< Range, Domain, BlockPayload > &)=default
 
template<typename Op >
BlockLinearOperator< Range, Domain, BlockPayload > & operator= (const Op &op)
 
template<size_t m, size_t n>
BlockLinearOperator< Range, Domain, BlockPayload > & operator= (const std::array< std::array< BlockType, n >, m > &ops)
 
template<size_t m>
BlockLinearOperator< Range, Domain, BlockPayload > & operator= (const std::array< BlockType, m > &ops)
 
- Public Member Functions inherited from LinearOperator< Range, Domain, BlockPayload::BlockType >
 LinearOperator (const BlockPayload::BlockType &payload=BlockPayload::BlockType())
 
 LinearOperator (const LinearOperator< Range, Domain, BlockPayload::BlockType > &)=default
 
 LinearOperator (const Op &op)
 
LinearOperator< Range, Domain, BlockPayload::BlockType > & operator= (const LinearOperator< Range, Domain, BlockPayload::BlockType > &)=default
 
LinearOperator< Range, Domain, BlockPayload::BlockType > & operator= (const Op &op)
 
LinearOperator< Range, Domain, BlockPayload::BlockType > & operator+= (const LinearOperator< Range, Domain, BlockPayload::BlockType > &second_op)
 
LinearOperator< Range, Domain, BlockPayload::BlockType > & operator-= (const LinearOperator< Range, Domain, BlockPayload::BlockType > &second_op)
 
LinearOperator< Range, Domain, BlockPayload::BlockType > & operator*= (const LinearOperator< Domain, Domain, BlockPayload::BlockType > &second_op)
 
LinearOperator< Range, Domain, BlockPayload::BlockType > operator*= (typename Domain::value_type number)
 

Public Attributes

std::function< unsigned int()> n_block_rows
 
std::function< unsigned int()> n_block_cols
 
std::function< BlockType(unsigned int, unsigned int)> block
 
- Public Attributes inherited from LinearOperator< Range, Domain, BlockPayload::BlockType >
std::function< void(Range &v, const Domain &u)> vmult
 
std::function< void(Range &v, const Domain &u)> vmult_add
 
std::function< void(Domain &v, const Range &u)> Tvmult
 
std::function< void(Domain &v, const Range &u)> Tvmult_add
 
std::function< void(Range &v, bool omit_zeroing_entries)> reinit_range_vector
 
std::function< void(Domain &v, bool omit_zeroing_entries)> reinit_domain_vector
 
bool is_null_operator
 

Related Functions

(Note that these are not member functions.)

Creation of a BlockLinearOperator
template<typename Range , typename Domain , typename BlockPayload , typename BlockMatrixType >
BlockLinearOperator< Range, Domain, BlockPayload > block_operator (const BlockMatrixType &block_matrix)
 
template<size_t m, size_t n, typename Range , typename Domain , typename BlockPayload >
BlockLinearOperator< Range, Domain, BlockPayload > block_operator (const std::array< std::array< LinearOperator< typename Range::BlockType, typename Domain::BlockType, typename BlockPayload::BlockType >, n >, m > &ops)
 
template<typename Range , typename Domain , typename BlockPayload , typename BlockMatrixType >
BlockLinearOperator< Range, Domain, BlockPayload > block_diagonal_operator (const BlockMatrixType &block_matrix)
 
template<size_t m, typename Range , typename Domain , typename BlockPayload >
BlockLinearOperator< Range, Domain, BlockPayload > block_diagonal_operator (const std::array< LinearOperator< typename Range::BlockType, typename Domain::BlockType, typename BlockPayload::BlockType >, m > &ops)
 
template<size_t m, typename Range , typename Domain , typename BlockPayload >
BlockLinearOperator< Range, Domain, BlockPayload > block_diagonal_operator (const LinearOperator< typename Range::BlockType, typename Domain::BlockType, typename BlockPayload::BlockType > &op)
 
Manipulation of a BlockLinearOperator
template<typename Range , typename Domain , typename BlockPayload >
LinearOperator< Domain, Range, typename BlockPayload::BlockType > block_forward_substitution (const BlockLinearOperator< Range, Domain, BlockPayload > &block_operator, const BlockLinearOperator< Domain, Range, BlockPayload > &diagonal_inverse)
 
template<typename Range , typename Domain , typename BlockPayload >
LinearOperator< Domain, Range, typename BlockPayload::BlockType > block_back_substitution (const BlockLinearOperator< Range, Domain, BlockPayload > &block_operator, const BlockLinearOperator< Domain, Range, BlockPayload > &diagonal_inverse)
 
Creation of a BlockLinearOperator
template<typename Range , typename Domain = Range>
BlockLinearOperator< Range, Domain, TrilinosWrappers::internal::BlockLinearOperatorImplementation::TrilinosBlockPayload< TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload > > block_operator (const TrilinosWrappers::BlockSparseMatrix &block_matrix)
 
template<size_t m, size_t n, typename Range , typename Domain = Range>
BlockLinearOperator< Range, Domain, TrilinosWrappers::internal::BlockLinearOperatorImplementation::TrilinosBlockPayload< TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload > > block_operator (const std::array< std::array< LinearOperator< typename Range::BlockType, typename Domain::BlockType, TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload >, n >, m > &ops)
 
template<typename Range , typename Domain = Range>
BlockLinearOperator< Range, Domain, TrilinosWrappers::internal::BlockLinearOperatorImplementation::TrilinosBlockPayload< TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload > > block_diagonal_operator (const TrilinosWrappers::BlockSparseMatrix &block_matrix)
 
template<size_t m, typename Range , typename Domain = Range>
BlockLinearOperator< Range, Domain, TrilinosWrappers::internal::BlockLinearOperatorImplementation::TrilinosBlockPayload< TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload > > block_diagonal_operator (const std::array< LinearOperator< typename Range::BlockType, typename Domain::BlockType, TrilinosWrappers::internal::LinearOperatorImplementation::TrilinosPayload >, m > &ops)
 

Detailed Description

template<typename Range, typename Domain, typename BlockPayload>
class BlockLinearOperator< Range, Domain, BlockPayload >

A class to store the concept of a block linear operator.

This class increases the interface of LinearOperator (which encapsulates the Matrix interface) by three additional functions:

std::function<unsigned int()> n_block_rows;
std::function<unsigned int()> n_block_cols;
std::function<BlockType(unsigned int, unsigned int)> block;

that describe the underlying block structure (of an otherwise opaque) linear operator.

Objects of type BlockLinearOperator can be created similarly to LinearOperator with a wrapper function:

const auto block_op_a = block_operator(A);

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:

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

A BlockLinearOperator can be sliced to a LinearOperator at any time. This removes all information about the underlying block structure (because above std::function objects are no longer available) - the linear operator interface, however, remains intact.

Note
This class makes heavy use of std::function objects and lambda functions. This flexibility comes with a run-time penalty. Only use this object to encapsulate object with medium to large individual block sizes, and small block structure (as a rule of thumb, matrix blocks greater than \(1000\times1000\)).
Author
Matthias Maier, 2015

Definition at line 43 of file block_linear_operator.h.

Constructor & Destructor Documentation

◆ BlockLinearOperator() [1/5]

template<typename Range, typename Domain, typename BlockPayload>
BlockLinearOperator< Range, Domain, BlockPayload >::BlockLinearOperator ( const BlockPayload &  payload)
inline

Create an empty BlockLinearOperator object.

Allstd::function member objects of this class and its base class LinearOperator are initialized with default variants that throw an exception upon invocation.

Definition at line 187 of file block_linear_operator.h.

◆ BlockLinearOperator() [2/5]

template<typename Range, typename Domain, typename BlockPayload>
BlockLinearOperator< Range, Domain, BlockPayload >::BlockLinearOperator ( const BlockLinearOperator< Range, Domain, BlockPayload > &  )
default

Default copy constructor.

◆ BlockLinearOperator() [3/5]

template<typename Range, typename Domain, typename BlockPayload>
template<typename Op >
BlockLinearOperator< Range, Domain, BlockPayload >::BlockLinearOperator ( const Op &  op)
inline

Templated copy constructor that creates a BlockLinearOperator object from an object op for which the conversion function block_operator is defined.

Definition at line 221 of file block_linear_operator.h.

◆ BlockLinearOperator() [4/5]

template<typename Range, typename Domain, typename BlockPayload>
template<size_t m, size_t n>
BlockLinearOperator< Range, Domain, BlockPayload >::BlockLinearOperator ( const std::array< std::array< BlockType, n >, m > &  ops)
inline

Create a BlockLinearOperator from a two-dimensional array ops of LinearOperator. This constructor calls the corresponding block_operator() specialization.

Definition at line 232 of file block_linear_operator.h.

◆ BlockLinearOperator() [5/5]

template<typename Range, typename Domain, typename BlockPayload>
template<size_t m>
BlockLinearOperator< Range, Domain, BlockPayload >::BlockLinearOperator ( const std::array< BlockType, m > &  ops)
inline

Create a block-diagonal BlockLinearOperator from a one-dimensional array ops of LinearOperator. This constructor calls the corresponding block_operator() specialization.

Definition at line 243 of file block_linear_operator.h.

Member Function Documentation

◆ operator=() [1/4]

template<typename Range, typename Domain, typename BlockPayload>
BlockLinearOperator<Range, Domain, BlockPayload>& BlockLinearOperator< Range, Domain, BlockPayload >::operator= ( const BlockLinearOperator< Range, Domain, BlockPayload > &  )
default

Default copy assignment operator.

◆ operator=() [2/4]

template<typename Range, typename Domain, typename BlockPayload>
template<typename Op >
BlockLinearOperator<Range, Domain, BlockPayload>& BlockLinearOperator< Range, Domain, BlockPayload >::operator= ( const Op &  op)
inline

Templated copy assignment operator for an object op for which the conversion function block_operator is defined.

Definition at line 259 of file block_linear_operator.h.

◆ operator=() [3/4]

template<typename Range, typename Domain, typename BlockPayload>
template<size_t m, size_t n>
BlockLinearOperator<Range, Domain, BlockPayload>& BlockLinearOperator< Range, Domain, BlockPayload >::operator= ( const std::array< std::array< BlockType, n >, m > &  ops)
inline

Copy assignment from a two-dimensional array ops of LinearOperator. This assignment operator calls the corresponding block_operator() specialization.

Definition at line 272 of file block_linear_operator.h.

◆ operator=() [4/4]

template<typename Range, typename Domain, typename BlockPayload>
template<size_t m>
BlockLinearOperator<Range, Domain, BlockPayload>& BlockLinearOperator< Range, Domain, BlockPayload >::operator= ( const std::array< BlockType, m > &  ops)
inline

Copy assignment from a one-dimensional array ops of LinearOperator that creates a block-diagonal BlockLinearOperator. This assignment operator calls the corresponding block_operator() specialization.

Definition at line 285 of file block_linear_operator.h.

Member Data Documentation

◆ n_block_rows

template<typename Range, typename Domain, typename BlockPayload>
std::function<unsigned int()> BlockLinearOperator< Range, Domain, BlockPayload >::n_block_rows

Return the number of blocks in a column (i.e, the number of "block rows", or the number \(m\), if interpreted as a \(m\times n\) block system).

Definition at line 295 of file block_linear_operator.h.

◆ n_block_cols

template<typename Range, typename Domain, typename BlockPayload>
std::function<unsigned int()> BlockLinearOperator< Range, Domain, BlockPayload >::n_block_cols

Return the number of blocks in a row (i.e, the number of "block columns", or the number \(n\), if interpreted as a \(m\times n\) block system).

Definition at line 301 of file block_linear_operator.h.

◆ block

template<typename Range, typename Domain, typename BlockPayload>
std::function<BlockType(unsigned int, unsigned int)> BlockLinearOperator< Range, Domain, BlockPayload >::block

Access the block with the given coordinates. This std::function object returns a LinearOperator representing the \((i,j)\)-th block of the BlockLinearOperator.

Definition at line 308 of file block_linear_operator.h.


The documentation for this class was generated from the following files: