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

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;
}