From 6a5f778aa2e9e1aeac4a14d49356ad6a2874a39e Mon Sep 17 00:00:00 2001 From: Jiri Pittner Date: Fri, 6 Feb 2026 15:28:42 +0100 Subject: [PATCH] added debug diagnostics to operator() --- mat.h | 2 ++ smat.h | 1 + vec.h | 1 + 3 files changed, 4 insertions(+) diff --git a/mat.h b/mat.h index 26c868f..8355df5 100644 --- a/mat.h +++ b/mat.h @@ -758,6 +758,7 @@ inline const NRMat NRMat::operator-(const NRSMat &rhs) const { template inline T* NRMat::operator[](const int i) { #ifdef DEBUG + if(nn==0||mm==0) laerror("operator[] on unallocated matrix"); if (_LA_count_check && *count != 1) laerror("matrix with *count>1 used as l-value"); if(i<0||i>=nn) std::cout<<"INDEX PROBLEM "<<0<<" "<::operator[](const int i) const { template inline T& NRMat::operator()(const int i, const int j){ #ifdef DEBUG + if(nn==0||mm==0) laerror("operator() of unallocated matrix"); if (_LA_count_check && *count != 1) laerror("NRMat::operator(,) used as l-value for a matrix with count > 1"); if(i<0||i>=nn||j<0||j>mm) std::cout<<"INDEX PROBLEM "<<0<<" "<j)? (i-2)*(i-1)/2+j-1 : (j-2)*(j-1)/2+i-1; template inline T & NRSMat::operator()(const int i, const int j) { #ifdef DEBUG + if(nn==0) laerror("operator() of unallocated smatrix"); if(_LA_count_check && *count != 1) laerror("T & NRSMat::operator()(const int, const int) used for matrix with count > 1"); if(i<0||i>=nn||j<0||j>=nn) std::cout<<"INDEX PROBLEM "<<0<<" "<::operator()(const int, const int) first index out of range - low"); diff --git a/vec.h b/vec.h index 08c2d2c..a6095fe 100644 --- a/vec.h +++ b/vec.h @@ -1101,6 +1101,7 @@ inline const T NRVec::dot(const T *a, const int stride , bool conjugate) cons template inline T& NRVec::operator[](const int i) { #ifdef DEBUG + if(nn==0) laerror("operator[] of unallocated vector"); if(_LA_count_check && *count != 1) laerror("possible use of NRVec[] with count>1 as l-value"); if(i<0||i >= nn) std::cout<<"INDEX PROBLEM "<<0<<" "<