diff --git a/mat.h b/mat.h index e0d9a3f..c3e8561 100644 --- a/mat.h +++ b/mat.h @@ -744,6 +744,7 @@ template inline T* NRMat::operator[](const int i) { #ifdef DEBUG 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<<" "<= nn) laerror("Mat [] out of range - high"); if (!v) laerror("unallocated matrix"); @@ -762,6 +763,7 @@ inline T* NRMat::operator[](const int i) { template inline const T* NRMat::operator[](const int i) const { #ifdef DEBUG + if(i<0||i>=nn) std::cout<<"INDEX PROBLEM "<<0<<" "<= nn) laerror("index out of range - high"); if (!v) laerror("unallocated matrix"); @@ -785,6 +787,7 @@ template inline T& NRMat::operator()(const int i, const int j){ #ifdef DEBUG 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<<" "<= nn) laerror("first index out of range - high"); if (j < 0) laerror("second index out of range - low"); @@ -809,6 +812,7 @@ template inline const T& NRMat::operator()(const int i, const int j) const{ T ret; #ifdef DEBUG + if(i<0||i>=nn||j<0||j>mm) std::cout<<"INDEX PROBLEM "<<0<<" "<= nn) laerror("first index out of range - high"); if (j < 0) laerror("second index out of range - low"); @@ -833,6 +837,7 @@ template inline const T NRMat::get_ij(const int i, const int j) const{ T ret; #ifdef DEBUG + if(i<0||i>=nn||j<0||j>mm) std::cout<<"INDEX PROBLEM "<<0<<" "<= nn) laerror("first index out of range - high"); if (j < 0) laerror("second index out of range - low"); @@ -1399,6 +1404,7 @@ public: inline const T& operator() (const int i, const int j) const { #ifdef DEBUG + if(i<=0||i>NRMat::nn||j<=0||j>NRMat::mm) std::cout<<"INDEX PROBLEM "<<1<<" "<::nn<<" "<<1<<" "<::mm< NRMat::nn) laerror("first index out of range - high"); if (j < 1) laerror("second index out of range - low"); @@ -1416,6 +1422,7 @@ public: inline T& operator() (const int i, const int j) { #ifdef DEBUG if (_LA_count_check && *NRMat::count != 1) laerror("matrix with *count > 1 used as l-value"); + if(i<=0||i>NRMat::nn||j<=0||j>NRMat::mm) std::cout<<"INDEX PROBLEM "<<1<<" "<::nn<<" "<<1<<" "<::mm< NRMat::nn) laerror("first index out of range - high"); if (j < 1) laerror("second index out of range - low"); @@ -1433,6 +1440,7 @@ public: inline const T get_ij(const int i, const int j) const { T ret; #ifdef DEBUG + if(i<=0||i>NRMat::nn||j<=0||j>NRMat::mm) std::cout<<"INDEX PROBLEM "<<1<<" "<::nn<<" "<<1<<" "<::mm< NRMat::nn) laerror("first index out of range - high"); if (j < 1) laerror("second index out of range - low"); diff --git a/smat.h b/smat.h index b51fef7..0cab729 100644 --- a/smat.h +++ b/smat.h @@ -626,6 +626,7 @@ template inline T& NRSMat::operator[](const size_t ij) { #ifdef DEBUG if(_LA_count_check && *count != 1) laerror("T& NRSMat::operator[] used for matrix with count>1"); + if(ij<0||ij>=NN2) std::cout<<"INDEX PROBLEM "<<0<<" "<::operator[] out of range - low"); if(ij>=NN2) laerror("T& NRSMat::operator[] out of range - high"); if(!v) laerror("T& NRSMat::operator[] used for unallocated NRSmat object"); @@ -646,6 +647,7 @@ inline T& NRSMat::operator[](const size_t ij) { template inline const T & NRSMat::operator[](const size_t ij) const { #ifdef DEBUG + if(ij<0||ij>=NN2) std::cout<<"INDEX PROBLEM "<<0<<" "<::operator[] out of range - low"); if(ij>=NN2) laerror("T& NRSMat::operator[] out of range - high"); if(!v) laerror("T& NRSMat::operator[] used for unallocated NRSmat object"); @@ -754,6 +756,7 @@ template inline T & NRSMat::operator()(const int i, const int j) { #ifdef DEBUG 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"); if(i>=nn) laerror("T & NRSMat::operator()(const int, const int) first index out of range - high"); if(j<0) laerror("T & NRSMat::operator()(const int, const int) second index out of range - low"); @@ -775,6 +778,7 @@ inline T & NRSMat::operator()(const int i, const int j) { template inline const T & NRSMat::operator()(const int i, const int j) const { #ifdef DEBUG + 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"); if(i>=nn) laerror("T & NRSMat::operator()(const int, const int) first index out of range - high"); if(j<0) laerror("T & NRSMat::operator()(const int, const int) second index out of range - low"); @@ -1313,6 +1317,7 @@ public: inline const T& operator() (const int i, const int j) const { #ifdef DEBUG + if(i<=0||i>NRSMat::nn||j<=0||j>NRSMat::nn) std::cout<<"INDEX PROBLEM "<<1<<" "<::nn<<" "<<1<<" "<::nn<::operator() (const int, const int) first indexout of range - low"); if(i>NRSMat::nn) laerror("index in const T& NRSMat_from1::operator() (const int, const int) first indexout of range - high"); if(j<=0) laerror("index in const T& NRSMat_from1::operator() (const int, const int) second index out of range - low"); @@ -1323,6 +1328,7 @@ public: inline T& operator() (const int i, const int j){ #ifdef DEBUG + if(i<=0||i>NRSMat::nn||j<=0||j>NRSMat::nn) std::cout<<"INDEX PROBLEM "<<1<<" "<::nn<<" "<<1<<" "<::nn<::operator() (const int, const int) first indexout of range - low"); if(i>NRSMat::nn) laerror("index in const T& NRSMat_from1::operator() (const int, const int) first indexout of range - high"); if(j<=0) laerror("index in const T& NRSMat_from1::operator() (const int, const int) second index out of range - low"); diff --git a/vec.h b/vec.h index e0d176a..6e722ee 100644 --- a/vec.h +++ b/vec.h @@ -620,6 +620,7 @@ template inline T& NRVec_from1::operator[](const int i) { #ifdef DEBUG if(_LA_count_check && *NRVec::count != 1) laerror("possible use of NRVec[] with count>1 as l-value"); + if(i<1||i > NRVec::nn) std::cout<<"INDEX PROBLEM "<<1<<" "<::nn< NRVec::nn) laerror("out of range - high"); if(!NRVec::v) laerror("unallocated NRVec"); @@ -638,6 +639,7 @@ inline T& NRVec_from1::operator[](const int i) { template inline const T& NRVec_from1::operator[](const int i) const { #ifdef DEBUG + if(i<1||i > NRVec::nn) std::cout<<"INDEX PROBLEM "<<1<<" "<::nn< NRVec::nn) laerror("out of range - high"); if(!NRVec::v) laerror("unallocated NRVec"); @@ -1082,6 +1084,7 @@ template inline T& NRVec::operator[](const int i) { #ifdef DEBUG 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<<" "<= nn) laerror("out of range - high"); if(!v) laerror("unallocated NRVec"); @@ -1100,6 +1103,7 @@ inline T& NRVec::operator[](const int i) { template inline const T& NRVec::operator[](const int i) const { #ifdef DEBUG + if(i<0||i >= nn) std::cout<<"INDEX PROBLEM "<<0<<" "<= nn) laerror("out of range - high"); if(!v) laerror("unallocated NRVec");