From d143dabb404468bb4d4157499c70c1f0b5fad63a Mon Sep 17 00:00:00 2001
From: bangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Date: Tue, 16 Apr 2013 02:59:11 +0000
Subject: [PATCH] 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
---
 deal.II/include/deal.II/lac/sparse_matrix.templates.h |  8 ++++----
 tests/trilinos/sparse_matrix_copy_from_01.cc          |  2 ++
 tests/trilinos/sparse_matrix_copy_from_01/cmp/generic | 11 ++++++-----
 3 files changed, 12 insertions(+), 9 deletions(-)

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<number>::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
-- 
2.39.5