/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./tests/debug/Test_mrhs_promotion.cc Copyright (C) 2026 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 */ // // MrhsPromotedOperator: a D dimensional operator presented as D+1 with Nrhs. // // Each output slice must equal the D dimensional operator applied to the // corresponding input slice, bit for bit -- the promotion moves data, it does // not change arithmetic. Slices are independent random fields so a mistake in // the slice indexing cannot pass. // #include using namespace Grid; int main (int argc, char ** argv) { Grid_init(&argc,&argv); const int Nrhs = 4; Coordinate latt = GridDefaultLatt(); Coordinate simd = GridDefaultSimd(Nd,vComplexD::Nsimd()); Coordinate mpi = GridDefaultMpi(); GridCartesian *UGrid = new GridCartesian(latt,simd,mpi); GridRedBlackCartesian *UrbGrid= SpaceTimeGrid::makeFourDimRedBlackGrid(UGrid); // D+1 grid with Nrhs in dimension 0 GridCartesian *RGrid = SpaceTimeGrid::makeFiveDimGrid(Nrhs,UGrid); std::cout << GridLogMessage << "Nrhs = " << Nrhs << " low grid " << UGrid->_ndimension << "d" << " high grid " << RGrid->_ndimension << "d" << std::endl; GridParallelRNG pRNG(UGrid); pRNG.SeedFixedIntegers(std::vector({1,2,3,4})); LatticeGaugeFieldD Umu(UGrid); SU::HotConfiguration(pRNG,Umu); RealD mass = 0.1; WilsonFermionD Dw(Umu,*UGrid,*UrbGrid,mass); MdagMLinearOperator HermOp(Dw); MrhsPromotedOperator MrhsOp(HermOp,UGrid,Nrhs); ////////////////////////////////////////////////// // Independent random source on each slice ////////////////////////////////////////////////// LatticeFermionD hi_in (RGrid); LatticeFermionD hi_out(RGrid); std::vector lo_in (Nrhs,UGrid); std::vector lo_ref(Nrhs,UGrid); for(int r=0;r 0.0 ); } else { std::cout << GridLogMessage << "untouched rhs["<