From 4f8293dbf09fa202b2d0ca1c3d62667026b74b75 Mon Sep 17 00:00:00 2001 From: Jiri Pittner Date: Thu, 30 Oct 2025 15:25:06 +0100 Subject: [PATCH] tensor lhs() signedpointer debug diagnostics --- t.cc | 26 ++++++++++++++++++++++++-- tensor.h | 15 +++++++++++---- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/t.cc b/t.cc index 789de85..4af391f 100644 --- a/t.cc +++ b/t.cc @@ -3853,7 +3853,7 @@ for(int l=1; l<=n; ++l) } -if(1) +if(0) { int n; cin>>n; @@ -3879,7 +3879,29 @@ for(int l=1; l<=n; ++l) } - +if(1) +{ +//tensor lhs operator() and signed pointer +int n; +cin >>n; +INDEXGROUP shape; + { + shape.number=3; + shape.symmetry= -1; + shape.range=n; + shape.offset=0; + } +Tensor t(shape); +t.clear(); +for(int i=0; i0) *ptr=rhs; else *ptr = -rhs; return *ptr;} + //dereferencing *ptr should be ignored for sgn==0 + const T operator=(const T rhs) + { + if(sgn>0) *ptr = rhs; + if(sgn<0) *ptr = -rhs; +#ifdef DEBUG + if(sgn==0) laerror("dereferencing lhs Signedpointer to nonexistent tensor element"); +#endif + return rhs; + } T& operator*=(const T rhs) {*ptr *= rhs; return *ptr;} T& operator/=(const T rhs) {*ptr /= rhs; return *ptr;} T& operator+=(const T rhs) {if(sgn>0) *ptr += rhs; else *ptr -= rhs; return *ptr;}