//----------------------------------------------------------------------------- void BlockMatrix::mult(const BlockVector& x, BlockVector& y, bool transposed) const { if (transposed) { dolfin_error("BlockMatrix.cpp", "compute transpose matrix-vector product", "Not implemented for block matrices"); } // Create temporary vector dolfin_assert(matrices[0][0]); // Loop over block rows for(std::size_t row = 0; row < matrices.shape()[0]; row++) { // RHS sub-vector GenericVector& _y = *(y.get_block(row)); const GenericMatrix& _matA = *matrices[row][0]; // Resize y and zero if (_y.empty()) _matA.init_vector(_y, 0); _y.zero(); // Loop over block columns std::shared_ptr<GenericVector> z_tmp = _matA.factory().create_vector(); for(std::size_t col = 0; col < matrices.shape()[1]; ++col) { const GenericVector& _x = *(x.get_block(col)); dolfin_assert(matrices[row][col]); matrices[row][col]->mult(_x, *z_tmp); _y += *z_tmp; } } }