From 3a243630de87b75c7747ee1461538e52f98c955e Mon Sep 17 00:00:00 2001 From: jiri Date: Sun, 9 Apr 2006 21:07:54 +0000 Subject: [PATCH] *** empty log message *** --- la_traits.h | 10 +++++++--- laerror.cc | 12 +++++++++++- mat.h | 1 + smat.h | 1 + test.cc | 13 +++++++++++++ vec.h | 1 + 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/la_traits.h b/la_traits.h index be533a1..1c24561 100644 --- a/la_traits.h +++ b/la_traits.h @@ -127,6 +127,7 @@ static inline void put(int fd, const complex &x, bool dimensions=0, bool tran static void multiget(unsigned int n,int fd, complex *x, bool dimensions=0){if((ssize_t)(n*sizeof(complex))!=read(fd,x,n*sizeof(complex))) laerror("read error");} static void multiput(unsigned int n, int fd, const complex *x, bool dimensions=0) {if((ssize_t)(n*sizeof(complex))!=write(fd,x,n*sizeof(complex))) laerror("write error");} static void copy(complex *dest, complex *src, unsigned int n) {memcpy(dest,src,n*sizeof(complex));} +static void clear(complex *dest, unsigned int n) {memset(dest,0,n*sizeof(complex));} }; //non-complex scalars @@ -145,6 +146,7 @@ static inline void get(int fd, C &x, bool dimensions=0, bool transp=0) {if(sizeo static void multiput(unsigned int n,int fd, const C *x, bool dimensions=0){if((ssize_t)(n*sizeof(C))!=write(fd,x,n*sizeof(C))) laerror("write error");} static void multiget(unsigned int n, int fd, C *x, bool dimensions=0) {if((ssize_t)(n*sizeof(C))!=read(fd,x,n*sizeof(C))) laerror("read error");} static void copy(C *dest, C *src, unsigned int n) {memcpy(dest,src,n*sizeof(C));} +static void clear(C *dest, unsigned int n) {memset(dest,0,n*sizeof(C));} }; @@ -169,6 +171,7 @@ static void get(int fd, C &x, bool dimensions=1, bool transp=0) {x.get(fd,dimens static void multiput(unsigned int n,int fd, const C *x, bool dimensions=1) {for(unsigned int i=0; i &x) {return x.norm();} static inline void axpy (NRSMat&s, const NRSMat &x, const C c) {s.axpy(c,x);} static void put(int fd, const C &x, bool dimensions=1, bool transp=0) {x.put(fd,dimensions);} static void get(int fd, C &x, bool dimensions=1, bool transp=0) {x.get(fd,dimensions);} -static void multiput(unsigned int n,int fd, const C *x, bool dimensions=1) {for(unsigned int i=0; i #include + +#ifdef USE_TRACEBACK +#include "traceback.h" +#endif + void laerror(const char *s1) { std::cerr << "LA:ERROR - "; @@ -13,8 +18,13 @@ void laerror(const char *s1) std::cout << s1 << "\n"; } if(errno) perror("system error"); - throw LAerror(s1); + +#ifdef USE_TRACEBACK + traceback(1); exit(1); +#else + throw LAerror(s1); //traceback possible via sigtraceback, but BFD library might fail for -O3 code on some machines and source lines would not be available +#endif } //stub for f77 blas called from strassen routine diff --git a/mat.h b/mat.h index 4117695..8a86dc0 100644 --- a/mat.h +++ b/mat.h @@ -38,6 +38,7 @@ public: const bool operator==(const NRMat &rhs) const {return !(*this != rhs);}; inline int getcount() const {return count?*count:0;} NRMat & operator=(const NRMat &rhs); //assignment + void clear() {LA_traits::clear((*this)[0],nn*mm);}; //zero out NRMat & operator=(const T &a); //assign a to diagonal NRMat & operator|=(const NRMat &rhs); //assignment to a new copy NRMat & operator+=(const T &a); //add diagonal diff --git a/smat.h b/smat.h index 5ec2bb6..fe76612 100644 --- a/smat.h +++ b/smat.h @@ -23,6 +23,7 @@ public: explicit NRSMat(const NRVec &rhs, const int n); //construct matrix from vector NRSMat & operator|=(const NRSMat &rhs); //assignment to a new copy NRSMat & operator=(const NRSMat &rhs); //assignment + void clear() {LA_traits::clear(v,NN2);}; //zero out NRSMat & operator=(const T &a); //assign a to diagonal const bool operator!=(const NRSMat &rhs) const {if(nn!=rhs.nn) return 1; return LA_traits::gencmp(v,rhs.v,NN2);} //memcmp for scalars else elementwise const bool operator==(const NRSMat &rhs) const {return !(*this != rhs);}; diff --git a/test.cc b/test.cc index 4b0a3fb..e66bf74 100644 --- a/test.cc +++ b/test.cc @@ -2,10 +2,21 @@ #include "qsort.h" #include "la.h" #include "fourindex.h" +#include "laerror.h" +#include "traceback.h" +void test2(char *msg) +{ +laerror(msg); +} int main(void) { +sigtraceback(SIGSEGV,1); +sigtraceback(SIGABRT,1); +sigtraceback(SIGBUS,1); +sigtraceback(SIGFPE,1); + bitvector v(100); v.fill(); bitvector x(50); x=v; @@ -37,6 +48,8 @@ cout< a(5),b(5),c; c=a+b; +test2("pokus"); + fourindex f; fourindex_dense ff(f); } diff --git a/vec.h b/vec.h index 8ab9e79..590031a 100644 --- a/vec.h +++ b/vec.h @@ -52,6 +52,7 @@ public: #endif NRVec & operator=(const NRVec &rhs); NRVec & operator=(const T &a); //assign a to every element + void clear() {LA_traits::clear(v,nn);}; //zero out NRVec & operator|=(const NRVec &rhs); const bool operator!=(const NRVec &rhs) const {if(nn!=rhs.nn) return 1; return LA_traits::gencmp(v,rhs.v,nn);} //memcmp for scalars else elementwise const bool operator==(const NRVec &rhs) const {return !(*this != rhs);};