Dear All, I need to subtract two blocks of a BlockSparseMatrix<double> system_matrix. I am trying to achieve this by creating SpraseMatrix<double> tmp1, then tmp1.copy_from(system_matrix.block(0,0)); tmp1.add(-1.0, system_matrix.block(0,1));
However, I am getting the following error message: "When copying one sparse matrix into another, or when adding one sparse matrix to another, both matrices need to refer to the same sparsity pattern." Could you please help me to overcome this problem? system_matrix has BlockSparsityPattern sparsity_pattern; which was obtained in the following way: BlockDynamicSparsityPattern dsp (2, 2); dsp.block (0, 0).reinit (n_E_re, n_E_re); dsp.block (1, 0).reinit (n_E_im, n_E_re); dsp.block (0, 1).reinit (n_E_re, n_E_im); dsp.block (1, 1).reinit (n_E_im, n_E_im); dsp.collect_sizes (); DoFTools::make_sparsity_pattern (dof_handler, dsp, constraints, false); sparsity_pattern.copy_from (dsp); I have tried various ways of declaring tmp1. Such as SparseMatrix<double> tmp1(system_matrix.block(0,0).get_sparsity_pattern()) or creating tmp1 as BlockSparseMatrix<double> tmp1(sparsity_pattern) Thank you in advance for your help. -- The deal.II project is located at http://www.dealii.org/ For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en --- You received this message because you are subscribed to the Google Groups "deal.II User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to dealii+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.