[PPL-devel] [GIT] ppl/ppl(sparse_matrices): Unlimited_Sparse_Row_Over_CO_Tree: add a faster implementation for the get2() method.

Marco Poletti poletti.marco at gmail.com
Fri Apr 16 15:08:03 CEST 2010


Module: ppl/ppl
Branch: sparse_matrices
Commit: 24a28f39e4f816435b88a159a0d10e6e586de7a3
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=24a28f39e4f816435b88a159a0d10e6e586de7a3

Author: Marco Poletti <poletti.marco at gmail.com>
Date:   Fri Apr 16 13:41:46 2010 +0200

Unlimited_Sparse_Row_Over_CO_Tree: add a faster implementation for the get2() method.

---

 src/Unlimited_Sparse_Row_Over_CO_Tree.inlines.hh |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/Unlimited_Sparse_Row_Over_CO_Tree.inlines.hh b/src/Unlimited_Sparse_Row_Over_CO_Tree.inlines.hh
index 9c7385d..a2b8188 100644
--- a/src/Unlimited_Sparse_Row_Over_CO_Tree.inlines.hh
+++ b/src/Unlimited_Sparse_Row_Over_CO_Tree.inlines.hh
@@ -685,9 +685,20 @@ Unlimited_Sparse_Row_Over_CO_Tree::get2(const dimension_type c1,
                                         const dimension_type c2,
                                         const Coefficient*& p1,
                                         const Coefficient*& p2) const {
-  // TODO: consider a faster impementation.
-  p1 = &(get(c1));
-  p2 = &(get(c2));
+  const_iterator itr1;
+  const_iterator itr2;
+
+  find2(c1, c2, itr1, itr2);
+
+  if (itr1.itr.is_at_end())
+    p1 = &Coefficient_zero();
+  else
+    p1 = &(itr1->second);
+
+  if (itr2.itr.is_at_end())
+    p2 = &Coefficient_zero();
+  else
+    p2 = &(itr2->second);
 }
 
 




More information about the PPL-devel mailing list