From: Wolfgang Bangerth Date: Tue, 16 Apr 2013 02:59:11 +0000 (+0000) Subject: Optimize function. Modify testcase so that there is a row with more than one entry. X-Git-Tag: v8.0.0~695 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7b0e5f703109c168aea5c71730a1daeca4d9e29;p=dealii.git Optimize function. Modify testcase so that there is a row with more than one entry. git-svn-id: https://svn.dealii.org/trunk@29292 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/lac/sparse_matrix.templates.h b/deal.II/include/deal.II/lac/sparse_matrix.templates.h index 2dbf6e0ee9..ce97bbcaee 100644 --- a/deal.II/include/deal.II/lac/sparse_matrix.templates.h +++ b/deal.II/include/deal.II/lac/sparse_matrix.templates.h @@ -385,10 +385,10 @@ SparseMatrix::copy_from (const TrilinosWrappers::SparseMatrix &matrix) value_cache.resize(ncols); colnum_cache.resize(ncols); - // then copy everything - for (int i = 0; i < ncols; ++i) - this->set(row, colnum_cache[i], - value_cache[i]); + // then copy everything in one swoop + this->set(row, + colnum_cache, + value_cache); } return *this; diff --git a/tests/trilinos/sparse_matrix_copy_from_01.cc b/tests/trilinos/sparse_matrix_copy_from_01.cc index 7e305b72cf..5cd5950654 100644 --- a/tests/trilinos/sparse_matrix_copy_from_01.cc +++ b/tests/trilinos/sparse_matrix_copy_from_01.cc @@ -35,6 +35,8 @@ int main (int argc,char **argv) SparsityPattern sparsity (5,5,5); sparsity.add (1,2); sparsity.add (2,3); + sparsity.add (3,2); + sparsity.add (3,3); sparsity.add (3,4); sparsity.add (4,3); sparsity.compress(); diff --git a/tests/trilinos/sparse_matrix_copy_from_01/cmp/generic b/tests/trilinos/sparse_matrix_copy_from_01/cmp/generic index 6a95ff5cf1..638836310a 100644 --- a/tests/trilinos/sparse_matrix_copy_from_01/cmp/generic +++ b/tests/trilinos/sparse_matrix_copy_from_01/cmp/generic @@ -3,8 +3,8 @@ DEAL::Original: 1.000e+00 2.000e+00 3.000e+00 4.000e+00 5.000e+00 - 6.000e+00 7.000e+00 - 9.000e+00 8.000e+00 + 7.000e+00 6.000e+00 8.000e+00 + 1.000e+01 9.000e+00 DEAL::Copy with all values: (0,0) 1.00000 (1,1) 2.00000 @@ -12,6 +12,7 @@ DEAL::Copy with all values: (2,2) 4.00000 (2,3) 5.00000 (3,3) 6.00000 -(3,4) 7.00000 -(4,4) 8.00000 -(4,3) 9.00000 +(3,2) 7.00000 +(3,4) 8.00000 +(4,4) 9.00000 +(4,3) 10.0000