[cig-commits] commit: Change back from priority queue to just sorting the vectors. The

Mercurial hg at geodynamics.org
Fri Mar 30 12:51:13 PDT 2012


changeset:   143:a12cb8d8c4a8
tag:         tip
user:        Walter Landry <wlandry at caltech.edu>
date:        Fri Mar 30 12:28:57 2012 -0700
files:       compute_coefficients/compute_v_on_interface/compute_dv_dtt.cxx
description:
Change back from priority queue to just sorting the vectors.  The
ordering of the priority queue never seemed to work.


diff -r 7d5b5ce74b59 -r a12cb8d8c4a8 compute_coefficients/compute_v_on_interface/compute_dv_dtt.cxx
--- a/compute_coefficients/compute_v_on_interface/compute_dv_dtt.cxx	Fri Mar 30 09:31:59 2012 -0700
+++ b/compute_coefficients/compute_v_on_interface/compute_dv_dtt.cxx	Fri Mar 30 12:28:57 2012 -0700
@@ -228,28 +228,23 @@ void compute_dv_dtt(const double zx[Nx+1
               }
           }
 
-      /* Put the valid vectors into a priority queue so that we can
-         take the sorted versions out as needed.  A bit messier than
-         just sorting the vector, but also significantly faster. */
+      sort(dd_valid(0,0).begin(), dd_valid(0,0).end());
+      sort(dd_valid(0,1).begin(), dd_valid(0,1).end());
+      sort(dd_valid(1,1).begin(), dd_valid(1,1).end());
+
+      sort(d_valid(0).begin(), d_valid(0).end());
+      sort(d_valid(1).begin(), d_valid(1).end());
+
+      sort(valid.begin(), valid.end());
 
       FTensor::Tensor3_christof<bool,2,2> is_set(false,false,false,false,
                                                  false,false);
-
-      typedef std::priority_queue<Valid, std::vector<Valid>, std::greater<Valid> > mpq;
-      mpq ddp_valid[]={{dd_valid(0,0).begin(),dd_valid(0,0).end()},
-                       {dd_valid(0,1).begin(),dd_valid(0,1).end()},
-                       {dd_valid(1,1).begin(),dd_valid(1,1).end()}};
-
-      mpq dp_valid[]={{d_valid(0).begin(),d_valid(0).end()},
-                      {d_valid(1).begin(),d_valid(1).end()}};
-      std::priority_queue<Valid, std::vector<Valid>, std::greater<Valid> >
-        p_valid(valid.begin(),valid.end());
 
       /* Compute everything */
       /* v */
 
       std::vector<Valid> values[2];
-      for(auto V=p_valid.top(); !p_valid.empty(); p_valid.pop(), V=p_valid.top())
+      for(auto &V: valid)
         {
           if(values[0].size()==6 && values[1].size()==6)
             break;
@@ -304,8 +299,7 @@ void compute_dv_dtt(const double zx[Nx+1
         {
           /* First derivative dv */
           std::vector<Valid> derivs[2];
-          for(auto V=dp_valid[d0].top(); !dp_valid[d0].empty();
-              dp_valid[d0].pop(), V=dp_valid[d0].top())
+          for(auto &V: d_valid(d0))
             {
               if(derivs[0].size()==3 && derivs[1].size()==3)
                 break;
@@ -344,8 +338,7 @@ void compute_dv_dtt(const double zx[Nx+1
           /* Second derivative ddv */
           for(int d1=d0;d1<2;++d1)
             {
-              for(auto V=ddp_valid[2*d0+d1].top(); !ddp_valid[2*d0+d1].empty();
-                  ddp_valid[2*d0+d1].pop(), V=ddp_valid[2*d0+d1].top())
+              for(auto &V: dd_valid(d0,d1))
                 {
                   if(is_set(0,d0,d1) && is_set(1,d0,d1))
                     break;



More information about the CIG-COMMITS mailing list