/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./lib/algorithms/iterative/ImplicitlyRestartedLanczos.h Copyright (C) 2015 Author: Peter Boyle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ #ifndef GRID_DEFLATION_H #define GRID_DEFLATION_H namespace Grid { template class Guesser { public: Guesser(void) = default; virtual ~Guesser(void) = default; virtual void operator()(const Field &src, Field &guess) = 0; }; template class ZeroGuesser: public Guesser { public: virtual void operator()(const Field &src, Field &guess) { guess = zero; }; }; template class SourceGuesser: public Guesser { public: virtual void operator()(const Field &src, Field &guess) { guess = src; }; }; //////////////////////////////// // Fine grid deflation //////////////////////////////// template class DeflatedGuesser: public Guesser { private: const std::vector &evec; const std::vector &eval; public: DeflatedGuesser(const std::vector & _evec,const std::vector & _eval) : evec(_evec), eval(_eval) {}; virtual void operator()(const Field &src,Field &guess) { guess = zero; assert(evec.size()==eval.size()); auto N = evec.size(); for (int i=0;i class LocalCoherenceDeflatedGuesser: public Guesser { private: const std::vector &subspace; const std::vector &evec_coarse; const std::vector &eval_coarse; public: LocalCoherenceDeflatedGuesser(const std::vector &_subspace, const std::vector &_evec_coarse, const std::vector &_eval_coarse) : subspace(_subspace), evec_coarse(_evec_coarse), eval_coarse(_eval_coarse) { } void operator()(const FineField &src,FineField &guess) { int N = (int)evec_coarse.size(); CoarseField src_coarse(evec_coarse[0]._grid); CoarseField guess_coarse(evec_coarse[0]._grid); guess_coarse = zero; blockProject(src_coarse,src,subspace); for (int i=0;i