12 runLog()<<__PRETTY_FUNCTION__<<" passed!" 16 std::string printIntSeq(IntSeq<Ints...>)
18 std::ostringstream os;
19 for(
int a : {Ints...})
35 void checkNonComplConjCancelation()
65 void checkNestedConjCancelation()
83 decltype(conj(conj(c)));
94 void checkDuplicatedUMinusCancellation()
125 void checkFilterVariadicClassPos()
133 FilterVariadicClassPos<IsNotNull,
146 void checkScalarWrap()
161 CRASH<<
"Wrapping 10 from rvalue failed";
171 CRASH<<
"Wrapping 10 from rvalue failed";
177 void checkTensKindIscontained()
190 static_assert(MyTk1::contains<MyTk2>,
"First TensKind not contained");
191 static_assert(
not MyTk2::contains<MyTk1>,
"Second TensKind contained");
197 void checkCallOperator()
225 CRASH<<
"Tens is "<<res<<
" expected "<<val;
231 static_assert(std::is_lvalue_reference_v<D>,
"Expected lvalue");
240 static constexpr
int flags=
241 combineFlags<GridFlag::HASHED,
242 GridFlag::SHIFTED_BC>;
247 const int64_t expVolume)
250 const int64_t volume=
253 if(expVolume!=volume)
254 CRASH<<
"Expected volume"<<expVolume<<
"obtained"<<volume;
259 Grid<2,int32_t,int64_t,flags>({1,2});
267 grid.setSides({3,3});
273 std::vector<
typename Grid::Neigh>;
276 auto checkNeigh=[](
const auto& grid,
277 const GridNeighs& expNeighs)
279 grid.forAllPoints([&](
const int64_t i)
281 Grid::forAllOriDirs([&](
const int oriDir)
285 grid.neighOfPoint(i,oriDir);
289 expNeighs[i][oriDir];
292 CRASH<<
"Point"<<i<<
"direction"<<oriDir<<
"expected neighbor"<<expNeigh<<
"obtained"<<neigh;
298 const GridNeighs expUnshiftedNeigh=
309 checkNeigh(grid,expUnshiftedNeigh);
311 grid.setShiftBC(1,{1,0});
314 const GridNeighs expShiftedNeigh=
326 const int shiftOfBC0=
330 CRASH<<
"Expected shift of"<<1<<
"obtained"<<shiftOfBC0;
332 checkNeigh(grid,expShiftedNeigh);
338 void checkFlagMasks()
344 constexpr
int maskAC=
346 static_assert(maskAC==5,
"Expecting 5");
349 constexpr
int maskABC=
351 static_assert(maskABC==7,
"Expecting 7");
355 remFlags<maskABC,A,C>;
356 static_assert(maskB==2,
"Expecting 2");
362 void checkSafeModulo()
366 [](
const int val,
const int mod,
const int expRes)
373 CRASH<<val<<
" MOD "<<res<<
" expected "<<expRes<<
", is "<<res;
384 void checkFactorize()
389 const std::vector<
int> expFacts)
392 const std::vector<
int> facts=
395 if(facts.size()!=expFacts.size())
396 CRASH<<
"Factorizing "<<n<<
" facts size "<<(
int)facts.size()<<
" different from size expected, "<<(
int)expFacts.size();
398 for(
int iFact=0;iFact<(
int)facts.size();iFact++)
409 CRASH<<
"Factorizing "<<n<<
" Factor "<<iFact<<
" is expected to be "<<eF<<
" is"<<f;
425 void checkLhsTranspose()
435 for(
int rw_c=0;rw_c<NCOL;rw_c++)
436 for(
int cn_c=0;cn_c<NCOL;cn_c++)
437 rwCol(cnCol(transpose(t),cn_c),rw_c)=cn_c;
440 for(
int rw_c=0;rw_c<NCOL;rw_c++)
441 for(
int cn_c=0;cn_c<NCOL;cn_c++)
442 if(rwCol(cnCol(t,cn_c),rw_c)!=rw_c)
443 CRASH<<
"Matrix entry ("<<rw_c<<
","<<cn_c<<
" expected "<<rw_c<<
" obtained "<<rwCol(cnCol(t,cn_c),rw_c);
449 #define STATIC_ASSERT_DUPLICATED_CALL_REMOVER(FUN,...) 450 static_assert(isSame< 452 RemRef<decltype(FUN(FUN(__VA_ARGS__{})))> 456 #define STATIC_ASSERT_DUPLICATED_CALL_ABSORBER(FUN,...) 457 static_assert(isSame< 458 RemRef<decltype(FUN(__VA_ARGS__{}))>, 459 RemRef<decltype(FUN(FUN(__VA_ARGS__{})))> 463 void checkDuplicatedCallRemoverOrAbsorber()
499 CRASH<<
"Expected "<<value<<
" obtained "<<res;
505 decltype(rwSpin(imag(co),0));
507 static_assert(isConst<T>,
"Expected const");
508 static_assert(isLvalue<T>,
"Expected const");
539 CRASH<<
"Real part: "<<real(c)<<
" expected: "<<re;
543 CRASH<<
"Imag part: "<<imag(c)<<
" expected: "<<-im;
549 template <
typename T>
561 void checkSingleInstances()
573 void checkMPIisInitalized()
576 const int isInitialized=
579 if(
not isInitialized)
580 CRASH<<
"MPI not initialized!";
586 void checkMPIallReduce()
601 CRASH<<
"Summing "<<val<<
" on all "<<mpi.nRanks()<<
" nodes produced "<<sum<<
" instead of expected "<<expSum;
607 void checkSignUnsign()
610 #define CHECK_UNSIGN(A,B) 611 static_assert(isSame<UnsignedOf<A>,B>,"Unsigned version of " #A " is not the same of " #B) 614 #define CHECK_SIGN(A,B) 615 static_assert(isSame<SignedOf<A>,B>,"Signed version of " #A " is not the same of " #B) 634 void checkVectorClass()
640 const long int expSize=
644 if(a.size()!=expSize)
645 CRASH<<
"Expected size: "<<expSize<<
", obtained: "<<a.size();
650 auto check=[&a](
const int& searching,
651 const int& expectedPos,
652 const bool& firstLast)
657 a.findFirst(searching):
658 a.findLast(searching);
662 CRASH<<
"First "<<searching<<
" expected at position "<<expectedPos<<
"found at "<<pos;
666 check(4,expSize,
false);
682 CRASH<<
"Expected sum: "<<expSum<<
", obtained: "<<sum;
696 CRASH<<
"Expected prod: "<<expProd<<
",obtained: "<<prod;
704 void checkCombinatorial()
707 const Vector<int64_t> nMaxPerSlot=
715 Combinatorial c(nMaxPerSlot,nObj);
722 const Vector<int64_t> expFirst=
726 CRASH<<
"First combinatorial not working";
732 CRASH<<
"Advancing and rewinding not coming back to first combinatorial";
776 WARNING<<
"NO SITMO CHECKED!!!!!";
782 void checkSerializer()
791 std::pair<std::string,std::string>;
816 test1().subTestClass().b=
819 test1().subTestClass().v()[2]=
822 test1().subTestClass().p().first=
828 test2.deSerialize(test1.serialize(ONLY_NON_DEFAULT));
830 test3.deBinarize(test1.binarize());
833 if(test1().A!=test2().A) 834 CRASH<<"Expected "<<test1().A<<" for " #A ", obtained in serialized: "<<test2().A<<"\n"<<test1.serialize(ONLY_NON_DEFAULT)<<"\n\n"<<test2; 836 if(test1().A!=test3().A) 837 CRASH<<"Expected "<<test1().A<<" for " #A ", obtained in binarized: "<<test3().A<<"\n"<<test1<<"\n\n"<<test3; 839 CHECK(subTestClass().b);
840 CHECK(subTestClass().v()[2]);
841 CHECK(subTestClass().p().first);
850 void checkValWithMax()
857 const int64_t second=
865 ValWithMax<int64_t> a=
875 const int64_t expExtr=
879 const int64_t expFin=
882 if(a.extreme()!=expExtr)
883 CRASH<<
"Extreme expected: "<<expExtr<<
", obtained: "<<a.extreme();
886 CRASH<<
"Final expected: "<<expFin<<
", obtained: "<<a;
893 void checkIsAliasing()
901 auto a=wrap(Tens<TensKind<Compl>,
double>{});
902 auto b=wrap(wrap(Tens<TensKind<Compl>,
double>{}));
904 runLog()<< isSame<RemRef<decltype(a)>,RemRef<decltype(b)>> ;
905 runLog()<<isSame<decltype(a),decltype(b)>;
906 runLog()<<
"t.isAliasing(t): "<<t.isAliasing(t.getStor());
907 runLog()<<
"t.isAliasing(u): "<<t.isAliasing(u.getStor());
908 runLog()<<
"conj(t).isAliasing(t): "<<conj(t).isAliasing(t.getStor());
911 void checkBindComplicatedExpression()
916 auto tr=transpose(wrap(wrap(t)));
917 reIm(transpose(tr),0)=1.0;
920 using MyTk=
TensKind<Spacetime,Col,Spin,Compl>;
922 using MyTens=
Tens<MyTk,
double>;
936 for(
int ic=0;ic<NCOL;ic++)
937 for(
int id=0;id<NSPIN;id++)
938 for(
int ri=0;ri<NCOMPL;ri++)
941 double &ref=site(reIm(spin(col(transpose(transpose(cicc)),ic),id),ri),0);
946 auto binder1=site(reIm(spin(col(cicc,2),3),1),0);
951 printf(
"ANNA %lg\n",binder1);
1033 void checkNnaryBuilder()
1077 mulAdd(tens3,tens2,tens1);
1082 mulAdder.eval(0,0,0);
1228 void checkSumOfTwoSmETs()
1255 for(
int iCnCol=0;iCnCol<NCOL;iCnCol++)
1256 for(
int iRwCol=0;iRwCol<NCOL;iRwCol++)
1257 for(
int iCnSpin=0;iCnSpin<NSPIN;iCnSpin++)
1258 cnCol(rwCol(cnSpin(a,iCnSpin),iRwCol),iCnCol)=3.0;
1261 for(
int iRwCol=0;iRwCol<NCOL;iRwCol++)
1262 for(
int iCnSpin=0;iCnSpin<NSPIN;iCnSpin++)
1263 for(
int iReIm=0;iReIm<NCOMPL;iReIm++)
1264 rwCol(cnSpin(reIm(b,iReIm),iCnSpin),iRwCol)=5.0;
1266 Tens<decltype((a+b).getMaximallyMergedCompsView())::Tk,
double> d;
1268 d=(a+b).getMaximallyMergedCompsView();
1270 runLog()<<
"d: "<<d.eval(1,1,1);
1281 runLog()<<
"Tensor Kind of addendum 1: "<<decltype(a)::Tk::name();
1283 typename decltype(a)::MergeableComps;
1284 runLog()<<
"Mergeability of addendum 1: "<<printIntSeq(M1{});
1285 runLog()<<
"Tensor Kind of addendum 2: "<<decltype(b)::Tk::name();
1287 typename decltype(b)::MergeableComps;
1288 runLog()<<
"Mergeability of addendum 2: "<<printIntSeq(M2{});
1289 runLog()<<
"Tensor Kind: "<<decltype(a+b)::Tk::name();
1291 runLog()<<
"PosOf types 1 present: "<<printIntSeq(TupleElementType<0,decltype(a+b)::PosOfResTcsPresInRefsTk>{});
1292 runLog()<<
"PosOf types 2 present: "<<printIntSeq(TupleElementType<1,decltype(a+b)::PosOfResTcsPresInRefsTk>{});
1321 runLog()<<
"Timings: "<<timings.isStarted()<<
" "<<timings.currentMeasure().count();
1322 runLog()<<
"Timings: "<<timings[
"ciao"].isStarted()<<
" "<<timings[
"ciao"].currentMeasure().count();
1332 runLog()<<1.23523524<<
"\n";
1334 runLog()<<1.23523524<<
"\n";
1336 runLog()<<
"Elena\n";
1339 runLog()<<
"Caterina\n";
1345 checkCombinatorial();
1347 checkNonComplConjCancelation();
1349 checkNestedConjCancelation();
1351 checkDuplicatedUMinusCancellation();
1353 checkFilterVariadicClassPos();
1357 checkTensKindIscontained();
1370 checkLhsTranspose();
1372 checkDuplicatedCallRemoverOrAbsorber();
1378 checkSingleInstances();
1380 checkMPIisInitalized();
1382 checkMPIallReduce();
#define STATIC_ASSERT_IS_BASE_OF(BASE, DERIVED)
Static assert if DERIVED does not derive from BASE.
#define DEFINE_SERIALIZABLE_CLASS(T)
Shortcut to define a serializable class.
#define LIST_SERIALIZABLE_MEMBERS(...)
Defines a list of serializable members.
#define CRASH
Initialize the crasher.
bool isInitialized() const
Check initialization flag.
#define SCOPE_ALWAYS_PUT_SIGN(STREAM)
Set printing always sign at the beginning of a number for current scope.
static constexpr const char * name()
Name of the Tk provided with "name()" suffix.
#define SERIALIZABLE_SCALAR_WITH_TAG(TYPE, NAME, TAG,...)
Defines a serializable scalar with an explicit tag.
ScopeIndenter(Logger &logger)
Create and increase indent level.
#define STATIC_ASSERT_DUPLICATED_CALL_ABSORBER(FUN,...)
Assert if a duplicated call is not absorbed.
void divWithMod(Vector< TOut > "ient, Vector< TOut > &remainder, const Vector &divisor) const
Returns the result and remainder of the division.
#define SERIALIZABLE_SCALAR(TYPE, NAME,...)
Defines a serializable scalar with the same tag of the variable name.
Logger runLog("/dev/stdout")
Global logger.
int nRanks() const
Cached value of total number of ranks.
static constexpr int element()
Get the I element of the sequence.
#define SCOPE_REAL_PRECISION(STREAM, VAL)
Set the precision for current scope.
decltype(auto) operator+(T1 &&smet1, T2 &&smet2)
Implement smet1+smet2.
#define SCOPE_INDENT(VAR)
Mark the stream to be more indented.
#define TEST_PASSED
Report that a test is passed.
#define WARNING
Starts a new line in bold brown.
#define CHECK_UNSIGN(A, B)
#define SERIALIZABLE_CLASS(TYPE, NAME)
Defines a serializable class.
#define STATIC_ASSERT_DUPLICATED_CALL_REMOVER(FUN,...)
Assert if a duplicated call is not removed.