namespace Grid { template class BasisFieldVector { public: int _Nm; typedef typename Field::scalar_type Coeff_t; typedef typename Field::vector_type vCoeff_t; typedef typename Field::vector_object vobj; typedef typename vobj::scalar_object sobj; std::vector _v; // _Nfull vectors void report(int n,GridBase* value) { std::cout << GridLogMessage << "BasisFieldVector allocated:\n"; std::cout << GridLogMessage << " Delta N = " << n << "\n"; std::cout << GridLogMessage << " Size of full vectors (size) = " << ((double)n*sizeof(vobj)*value->oSites() / 1024./1024./1024.) << " GB\n"; std::cout << GridLogMessage << " Size = " << _v.size() << " Capacity = " << _v.capacity() << std::endl; value->Barrier(); if (value->IsBoss()) { system("cat /proc/meminfo"); } value->Barrier(); } BasisFieldVector(int Nm,GridBase* value) : _Nm(Nm), _v(Nm,value) { report(Nm,value); } ~BasisFieldVector() { } Field& operator[](int i) { return _v[i]; } void orthogonalize(Field& w, int k) { for(int j=0; j& Qt,int j0, int j1, int k0,int k1,int Nm) { GridBase* grid = _v[0]._grid; #pragma omp parallel { std::vector < vobj > B(Nm); #pragma omp for for(int ss=0;ss < grid->oSites();ss++){ for(int j=j0; j _Nm) _v.reserve(n); _v.resize(n,_v[0]._grid); if (n < _Nm) _v.shrink_to_fit(); report(n - _Nm,_v[0]._grid); _Nm = n; } std::vector getIndex(std::vector& sort_vals) { std::vector idx(sort_vals.size()); iota(idx.begin(), idx.end(), 0); // sort indexes based on comparing values in v sort(idx.begin(), idx.end(), [&sort_vals](int i1, int i2) {return ::fabs(sort_vals[i1]) < ::fabs(sort_vals[i2]);}); return idx; } void reorderInPlace(std::vector& sort_vals, std::vector& idx) { GridStopWatch gsw; gsw.Start(); int nswaps = 0; for (size_t i=0;i& sort_vals, bool reverse) { std::vector idx = getIndex(sort_vals); if (reverse) std::reverse(idx.begin(), idx.end()); reorderInPlace(sort_vals,idx); } void deflate(const std::vector& eval,const Field& src_orig,Field& result) { result = zero; int N = (int)_v.size(); for (int i=0;i