From b515999e9506328b51fed289b10eb55fe57ed8b9 Mon Sep 17 00:00:00 2001 From: wolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d> Date: Wed, 9 May 2001 13:25:14 +0000 Subject: [PATCH] Slightly simplify code and make it a little faster by that. git-svn-id: https://svn.dealii.org/trunk@4581 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/dofs/dof_constraints.templates.h | 144 +++++++++--------- 1 file changed, 70 insertions(+), 74 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_constraints.templates.h b/deal.II/deal.II/include/dofs/dof_constraints.templates.h index d0d56968b0..1c04921780 100644 --- a/deal.II/deal.II/include/dofs/dof_constraints.templates.h +++ b/deal.II/deal.II/include/dofs/dof_constraints.templates.h @@ -174,89 +174,85 @@ ConstraintMatrix::condense (SparseMatrix<number> &uncondensed) const // regular line. loop over cols for (unsigned int j=sparsity.get_rowstart_indices()[row]; j<sparsity.get_rowstart_indices()[row+1]; ++j) - // end of row reached? - if (sparsity.get_column_numbers()[j] == SparsityPattern::invalid_entry) - { - // this should not happen, since - // we only operate on compressed - // matrices! - Assert (false, ExcMatrixNotClosed()); - break; - } - else - { - if (distribute[sparsity.get_column_numbers()[j]] != -1) - // distribute entry at regular - // row @p{row} and irregular column - // sparsity.get_column_numbers()[j]; set old - // entry to zero - { + { + // end of row reached? + // this should not + // happen, since we only + // operate on compressed + // matrices! + Assert (sparsity.get_column_numbers()[j] != SparsityPattern::invalid_entry, + ExcMatrixNotClosed()); + + if (distribute[sparsity.get_column_numbers()[j]] != -1) + // distribute entry at regular + // row @p{row} and irregular column + // sparsity.get_column_numbers()[j]; set old + // entry to zero + { + for (unsigned int q=0; + q!=lines[distribute[sparsity.get_column_numbers()[j]]] + .entries.size(); ++q) + uncondensed.add (row, + lines[distribute[sparsity.get_column_numbers()[j]]] + .entries[q].first, + uncondensed.global_entry(j) * + lines[distribute[sparsity.get_column_numbers()[j]]] + .entries[q].second); + + uncondensed.global_entry(j) = 0.; + }; + } + else + // row must be distributed + for (unsigned int j=sparsity.get_rowstart_indices()[row]; + j<sparsity.get_rowstart_indices()[row+1]; ++j) + { + // end of row reached? + // this should not + // happen, since we only + // operate on compressed + // matrices! + Assert (sparsity.get_column_numbers()[j] != SparsityPattern::invalid_entry, + ExcMatrixNotClosed()); + + if (distribute[sparsity.get_column_numbers()[j]] == -1) + // distribute entry at irregular + // row @p{row} and regular column + // sparsity.get_column_numbers()[j]. set old + // entry to zero + { + for (unsigned int q=0; + q!=lines[distribute[row]].entries.size(); ++q) + uncondensed.add (lines[distribute[row]].entries[q].first, + sparsity.get_column_numbers()[j], + uncondensed.global_entry(j) * + lines[distribute[row]].entries[q].second); + + uncondensed.global_entry(j) = 0.; + } + else + // distribute entry at irregular + // row @p{row} and irregular column + // sparsity.get_column_numbers()[j] + // set old entry to one if on main + // diagonal, zero otherwise + { + for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p) for (unsigned int q=0; q!=lines[distribute[sparsity.get_column_numbers()[j]]] .entries.size(); ++q) - uncondensed.add (row, + uncondensed.add (lines[distribute[row]].entries[p].first, lines[distribute[sparsity.get_column_numbers()[j]]] .entries[q].first, uncondensed.global_entry(j) * + lines[distribute[row]].entries[p].second * lines[distribute[sparsity.get_column_numbers()[j]]] .entries[q].second); - uncondensed.global_entry(j) = 0.; - }; - } - else - // row must be distributed - for (unsigned int j=sparsity.get_rowstart_indices()[row]; - j<sparsity.get_rowstart_indices()[row+1]; ++j) - // end of row reached? - if (sparsity.get_column_numbers()[j] == SparsityPattern::invalid_entry) - { - // this should not happen, since - // we only operate on compressed - // matrices! - Assert (false, ExcMatrixNotClosed()); - break; - } - else - { - if (distribute[sparsity.get_column_numbers()[j]] == -1) - // distribute entry at irregular - // row @p{row} and regular column - // sparsity.get_column_numbers()[j]. set old - // entry to zero - { - for (unsigned int q=0; - q!=lines[distribute[row]].entries.size(); ++q) - uncondensed.add (lines[distribute[row]].entries[q].first, - sparsity.get_column_numbers()[j], - uncondensed.global_entry(j) * - lines[distribute[row]].entries[q].second); - - uncondensed.global_entry(j) = 0.; - } - else - // distribute entry at irregular - // row @p{row} and irregular column - // sparsity.get_column_numbers()[j] - // set old entry to one if on main - // diagonal, zero otherwise - { - for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p) - for (unsigned int q=0; - q!=lines[distribute[sparsity.get_column_numbers()[j]]] - .entries.size(); ++q) - uncondensed.add (lines[distribute[row]].entries[p].first, - lines[distribute[sparsity.get_column_numbers()[j]]] - .entries[q].first, - uncondensed.global_entry(j) * - lines[distribute[row]].entries[p].second * - lines[distribute[sparsity.get_column_numbers()[j]]] - .entries[q].second); - - uncondensed.global_entry(j) = (row == sparsity.get_column_numbers()[j] ? - 1. : 0. ); - }; - }; + uncondensed.global_entry(j) = (row == sparsity.get_column_numbers()[j] ? + 1. : 0. ); + }; + }; }; }; -- 2.39.5