tensor: improved diagnostics

This commit is contained in:
2025-11-20 21:00:33 +01:00
parent ad1c4ee968
commit 3da3efa57c
2 changed files with 8 additions and 1 deletions

1
t.cc
View File

@@ -4497,6 +4497,7 @@ for(int i=0; i<n+2; ++i) for(int j=0; j<n+2; ++j) for(int k=0; k<n+2; ++k) for(i
y.lhs(i,j,k,l) += x(ii,jj,kk,ll) * t[0](i,ii) * t[0](j,jj) * t[0](k,kk) * t[1](l,ll) ;
}
cout <<"Error = "<<(xt-y).norm()<<endl;
}
}//main

View File

@@ -84,10 +84,16 @@ if(LA_traits<T>::is_complex()) //condition known at compile time
}
static bool didwarn=false;
static inline bool ptr_ok(void *ptr)
{
#ifdef DEBUG
if(ptr==NULL) std::cout<<"Warning: write to nonexistent tensor element ignored\n";
if(ptr==NULL && !didwarn)
{
std::cout<<"Warning: write to zero element of antisym tensor ignored\n";
std::cerr<<"Warning: write to zero element of antisym tensor ignored\n";
didwarn=true;
}
#endif
return (bool)ptr;
}