From: wolf Date: Mon, 22 May 2000 09:09:31 +0000 (+0000) Subject: Fix a bug with non-square/square block matrices. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e83510520aedb2c66c2c106bcaea12afb59f70be;p=dealii-svn.git Fix a bug with non-square/square block matrices. git-svn-id: https://svn.dealii.org/trunk@2917 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/numerics/matrices.cc b/deal.II/deal.II/source/numerics/matrices.cc index 0c1017352f..be9eeb19a0 100644 --- a/deal.II/deal.II/source/numerics/matrices.cc +++ b/deal.II/deal.II/source/numerics/matrices.cc @@ -922,10 +922,32 @@ MatrixTools::apply_boundary_values (const map &boundar // (row,dof_number) // in this block // (not in the - // transpose one) - const unsigned int * + // transpose + // one). note that + // we have to take + // care of special + // cases with + // square + // sub-matrices + const unsigned int *p = 0; + if (this_sparsity.n_rows() == this_sparsity.n_cols()) + { + if (this_sparsity.get_column_numbers() + [this_sparsity.get_rowstart_indices()[row]] + == + block_index.second) + p = &this_sparsity.get_column_numbers() + [this_sparsity.get_rowstart_indices()[row]]; + else + p = lower_bound(&this_sparsity.get_column_numbers() + [this_sparsity.get_rowstart_indices()[row]+1], + &this_sparsity.get_column_numbers() + [this_sparsity.get_rowstart_indices()[row+1]], + block_index.second); + } + else p = lower_bound(&this_sparsity.get_column_numbers() - [this_sparsity.get_rowstart_indices()[row]+1], + [this_sparsity.get_rowstart_indices()[row]], &this_sparsity.get_column_numbers() [this_sparsity.get_rowstart_indices()[row+1]], block_index.second); @@ -938,7 +960,15 @@ MatrixTools::apply_boundary_values (const map &boundar // past-the-end pointer but points // to dof_number anyway...) // - // there should be such an entry! + // there should be + // such an entry! + // note, however, + // that this + // assertion will + // fail sometimes + // if the sparsity + // pattern is not + // symmetric! Assert ((*p == block_index.second) && (p != &this_sparsity.get_column_numbers() [this_sparsity.get_rowstart_indices()[row+1]]),