20 m_blockPrec.resize(nRows, nCols);
21 m_blockTargetPositions.setZero(nRows);
22 m_blockInputPositions.setZero(nCols);
24 for (
index_t i = 0; i < nRows; ++i)
25 for (
index_t j = 0; j < nCols; ++j)
26 m_blockPrec(i,j).reset();
32 GISMO_ASSERT( row >= 0 && row < m_blockPrec.rows(),
"The given row is not feasible." );
33 GISMO_ASSERT( col >= 0 && col < m_blockPrec.cols(),
"The given column is not feasible." );
34 GISMO_ASSERT( op->rows() == m_blockTargetPositions[row] || m_blockTargetPositions[row] == 0,
35 "The size of the given preconditioner does not fit to the other preconditioners in the same row." );
36 GISMO_ASSERT( op->cols() == m_blockInputPositions[col] || m_blockInputPositions[col] == 0,
37 "The size of the given preconditioner does not fit to the other preconditioners in the same column." );
39 m_blockPrec(row, col) = op;
40 m_blockTargetPositions[row] = op->rows();
41 m_blockInputPositions[col] = op->cols();
48 result.setZero(m_blockTargetPositions.sum(), input.cols());
50 singleCol << input.cols();
53 for (
index_t i = 0; i < m_blockPrec.rows() ; ++i)
56 for (
index_t j = 0; j < m_blockPrec.cols(); ++j)
58 if (!m_blockPrec(i,j))
60 inputIndex += m_blockInputPositions(j);
65 m_blockPrec(i,j)->apply(input.block(inputIndex,0,m_blockInputPositions(j),input.cols()),tmp_result);
66 resultBlocks(i) += tmp_result;
67 inputIndex += m_blockInputPositions(j);
gsBlockOp(index_t nRows, index_t nCols)
Constructor. Takes the number of blocks (nRows, nCols). Provide the contents of the blocks with addOp...
Definition: gsBlockOp.hpp:18
void apply(const gsMatrix< T > &input, gsMatrix< T > &result) const
Apply the correct segment of the input vector on the preconditioners in the block structure and store...
Definition: gsBlockOp.hpp:46
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
BlockView blockView(const gsVector< index_t > &rowSizes, const gsVector< index_t > &colSizes)
Return a block view of the matrix with rowSizes and colSizes.
Definition: gsMatrix.h:381
void addOperator(index_t row, index_t col, const BasePtr &op)
Add a preconditioner to the block structure.
Definition: gsBlockOp.hpp:30
memory::shared_ptr< gsLinearOperator< T > > BasePtr
Base class.
Definition: gsBlockOp.h:54