Commit c6b28459 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

remove another over-optimization

parent 632fa522
...@@ -1290,12 +1290,12 @@ template<typename Serv> void wminmax(const GridderConfig &gconf, ...@@ -1290,12 +1290,12 @@ template<typename Serv> void wminmax(const GridderConfig &gconf,
} }
} }
template<typename T> void update_idx(vector<T> &v, vector<T> &vold, template<typename T> void update_idx(vector<T> &v, const vector<T> &add,
const vector<T> &add, const vector<T> &del) const vector<T> &del)
{ {
myassert(v.size()>=del.size(), "must not happen"); myassert(v.size()>=del.size(), "must not happen");
vold.resize(0); vector<T> res;
vold.reserve((v.size()+add.size())-del.size()); res.reserve((v.size()+add.size())-del.size());
auto iin=v.begin(), ein=v.end(); auto iin=v.begin(), ein=v.end();
auto iadd=add.begin(), eadd=add.end(); auto iadd=add.begin(), eadd=add.end();
auto irem=del.begin(), erem=del.end(); auto irem=del.begin(), erem=del.end();
...@@ -1305,15 +1305,15 @@ template<typename T> void update_idx(vector<T> &v, vector<T> &vold, ...@@ -1305,15 +1305,15 @@ template<typename T> void update_idx(vector<T> &v, vector<T> &vold,
if ((irem!=erem) && (*iin==*irem)) if ((irem!=erem) && (*iin==*irem))
{ ++irem; ++iin; } // skip removed entry { ++irem; ++iin; } // skip removed entry
else if ((iadd!=eadd) && (*iadd<*iin)) else if ((iadd!=eadd) && (*iadd<*iin))
vold.push_back(*(iadd++)); // add new entry res.push_back(*(iadd++)); // add new entry
else else
vold.push_back(*(iin++)); res.push_back(*(iin++));
} }
myassert(irem==erem, "must not happen"); myassert(irem==erem, "must not happen");
while(iadd!=eadd) while(iadd!=eadd)
vold.push_back(*(iadd++)); res.push_back(*(iadd++));
myassert(vold.size()==(v.size()+add.size())-del.size(), "must not happen"); myassert(res.size()==(v.size()+add.size())-del.size(), "must not happen");
v.swap(vold); v.swap(res);
} }
template<typename Serv> void wstack_common( template<typename Serv> void wstack_common(
...@@ -1403,14 +1403,14 @@ template<typename T, typename Serv> void x2dirty( ...@@ -1403,14 +1403,14 @@ template<typename T, typename Serv> void x2dirty(
if (verbosity>0) cout << "Gridding using improved w-stacking" << endl; if (verbosity>0) cout << "Gridding using improved w-stacking" << endl;
wstack_common(gconf, srv, wmin, dw, nplanes, minplane, verbosity); wstack_common(gconf, srv, wmin, dw, nplanes, minplane, verbosity);
dirty.fill(0); dirty.fill(0);
vector<idx_t> subidx, subidx_old; vector<idx_t> subidx;
tmpStorage<complex<T>,2> grid_({gconf.Nu(),gconf.Nv()}); tmpStorage<complex<T>,2> grid_({gconf.Nu(),gconf.Nv()});
auto grid=grid_.getMav(); auto grid=grid_.getMav();
tmpStorage<complex<T>,2> tdirty_(dirty.shape()); tmpStorage<complex<T>,2> tdirty_(dirty.shape());
auto tdirty=tdirty_.getMav(); auto tdirty=tdirty_.getMav();
for (size_t iw=0; iw<nplanes; ++iw) for (size_t iw=0; iw<nplanes; ++iw)
{ {
update_idx(subidx, subidx_old, minplane[iw], iw>=supp ? minplane[iw-supp] : vector<idx_t>()); update_idx(subidx, minplane[iw], iw>=supp ? minplane[iw-supp] : vector<idx_t>());
if (subidx.size()==0) continue; if (subidx.size()==0) continue;
if (verbosity>1) if (verbosity>1)
cout << "Working on plane " << iw << " containing " << subidx.size() cout << "Working on plane " << iw << " containing " << subidx.size()
...@@ -1482,14 +1482,14 @@ template<typename T, typename Serv> void dirty2x( ...@@ -1482,14 +1482,14 @@ template<typename T, typename Serv> void dirty2x(
// correct for w gridding // correct for w gridding
apply_wcorr(gconf, tdirty, ES_Kernel(supp, nthreads), dw); apply_wcorr(gconf, tdirty, ES_Kernel(supp, nthreads), dw);
vector<idx_t> subidx, subidx_old; vector<idx_t> subidx;
tmpStorage<complex<T>,2> grid_({gconf.Nu(),gconf.Nv()}); tmpStorage<complex<T>,2> grid_({gconf.Nu(),gconf.Nv()});
auto grid=grid_.getMav(); auto grid=grid_.getMav();
tmpStorage<complex<T>,2> tdirty2_({nx_dirty,ny_dirty}); tmpStorage<complex<T>,2> tdirty2_({nx_dirty,ny_dirty});
auto tdirty2=tdirty2_.getMav(); auto tdirty2=tdirty2_.getMav();
for (size_t iw=0; iw<nplanes; ++iw) for (size_t iw=0; iw<nplanes; ++iw)
{ {
update_idx(subidx, subidx_old, minplane[iw], iw>=supp ? minplane[iw-supp] : vector<idx_t>()); update_idx(subidx, minplane[iw], iw>=supp ? minplane[iw-supp] : vector<idx_t>());
if (subidx.size()==0) continue; if (subidx.size()==0) continue;
if (verbosity>1) if (verbosity>1)
cout << "Working on plane " << iw << " containing " << subidx.size() cout << "Working on plane " << iw << " containing " << subidx.size()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment