fixed clear() for nested types
This commit is contained in:
parent
222c1cfb8c
commit
6135a4b595
10
la_traits.h
10
la_traits.h
@ -349,17 +349,17 @@ typedef X<C> producttype; \
|
|||||||
typedef typename LA_traits<C>::normtype normtype; \
|
typedef typename LA_traits<C>::normtype normtype; \
|
||||||
typedef X<typename LA_traits<C>::realtype> realtype; \
|
typedef X<typename LA_traits<C>::realtype> realtype; \
|
||||||
typedef X<typename LA_traits<C>::complextype> complextype; \
|
typedef X<typename LA_traits<C>::complextype> complextype; \
|
||||||
static bool gencmp(const C *x, const C *y, size_t n) {for(size_t i=0; i<n; ++i) if(x[i]!=y[i]) return true; return false;} \
|
static bool gencmp(const X<C> *x, const X<C> *y, size_t n) {for(size_t i=0; i<n; ++i) if(x[i]!=y[i]) return true; return false;} \
|
||||||
static inline bool bigger(const C &x, const C &y) {return x>y;} \
|
static inline bool bigger(const X<C> &x, const X<C> &y) {return x>y;} \
|
||||||
static inline bool smaller(const C &x, const C &y) {return x<y;} \
|
static inline bool smaller(const X<C> &x, const X<C> &y) {return x<y;} \
|
||||||
static inline normtype norm (const X<C> &x) {return x.norm();} \
|
static inline normtype norm (const X<C> &x) {return x.norm();} \
|
||||||
static inline void axpy (X<C>&s, const X<C> &x, const C c) {s.axpy(c,x);} \
|
static inline void axpy (X<C>&s, const X<C> &x, const C c) {s.axpy(c,x);} \
|
||||||
static void put(int fd, const X<C> &x, bool dimensions=1, bool transp=0) {x.put(fd,dimensions,transp);} \
|
static void put(int fd, const X<C> &x, bool dimensions=1, bool transp=0) {x.put(fd,dimensions,transp);} \
|
||||||
static void get(int fd, X<C> &x, bool dimensions=1, bool transp=0) {x.get(fd,dimensions,transp);} \
|
static void get(int fd, X<C> &x, bool dimensions=1, bool transp=0) {x.get(fd,dimensions,transp);} \
|
||||||
static void multiput(size_t n,int fd, const X<C> *x, bool dimensions=1) {for(size_t i=0; i<n; ++i) x[i].put(fd,dimensions);} \
|
static void multiput(size_t n,int fd, const X<C> *x, bool dimensions=1) {for(size_t i=0; i<n; ++i) x[i].put(fd,dimensions);} \
|
||||||
static void multiget(size_t n,int fd, X<C> *x, bool dimensions=1) {for(size_t i=0; i<n; ++i) x[i].get(fd,dimensions);} \
|
static void multiget(size_t n,int fd, X<C> *x, bool dimensions=1) {for(size_t i=0; i<n; ++i) x[i].get(fd,dimensions);} \
|
||||||
static void copy(C *dest, C *src, size_t n) {for(size_t i=0; i<n; ++i) dest[i]=src[i];} \
|
static void copy(X<C> *dest, X<C> *src, size_t n) {for(size_t i=0; i<n; ++i) dest[i]=src[i];} \
|
||||||
static void clear(C *dest, size_t n) {for(size_t i=0; i<n; ++i) dest[i].clear();}\
|
static void clear(X<C> *dest, size_t n) {for(size_t i=0; i<n; ++i) dest[i].clear();}\
|
||||||
static void copyonwrite(X<C> &x) {x.copyonwrite();}\
|
static void copyonwrite(X<C> &x) {x.copyonwrite();}\
|
||||||
static bool is_plaindata() {return false;}\
|
static bool is_plaindata() {return false;}\
|
||||||
static void clearme(X<C> &x) {x.clear();}\
|
static void clearme(X<C> &x) {x.clear();}\
|
||||||
|
2
mat.h
2
mat.h
@ -292,7 +292,7 @@ public:
|
|||||||
//! set all matrix elements equal to zero
|
//! set all matrix elements equal to zero
|
||||||
void clear(){
|
void clear(){
|
||||||
if(nn&&mm){
|
if(nn&&mm){
|
||||||
copyonwrite(true);
|
copyonwrite(LA_traits<T>::is_plaindata());
|
||||||
LA_traits<T>::clear((*this)[0], (size_t)nn*mm);
|
LA_traits<T>::clear((*this)[0], (size_t)nn*mm);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
2
smat.h
2
smat.h
@ -162,7 +162,7 @@ public:
|
|||||||
|
|
||||||
void copyonwrite(bool detachonly=false);
|
void copyonwrite(bool detachonly=false);
|
||||||
|
|
||||||
void clear() {copyonwrite(true); LA_traits<T>::clear(v,NN2);}; //zero out
|
void clear() {copyonwrite(LA_traits<T>::is_plaindata()); LA_traits<T>::clear(v,NN2);}; //zero out
|
||||||
void resize(const int n);
|
void resize(const int n);
|
||||||
void dealloc(void) {resize(0);}
|
void dealloc(void) {resize(0);}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public:
|
|||||||
inline bool issymmetric() const {return symmetric;}
|
inline bool issymmetric() const {return symmetric;}
|
||||||
unsigned int length() const;
|
unsigned int length() const;
|
||||||
void copyonwrite(bool detachonly=false);
|
void copyonwrite(bool detachonly=false);
|
||||||
void clear() {copyonwrite(true); if(count) {delete count; count=NULL;}}
|
void clear() {copyonwrite(LA_traits<T>::is_plaindata()); if(count) {delete count; count=NULL;}}
|
||||||
void simplify();
|
void simplify();
|
||||||
const T trace() const;
|
const T trace() const;
|
||||||
const typename LA_traits<T>::normtype norm(const T scalar=(T)0) const; //is const only mathematically, not in internal implementation - we have to simplify first
|
const typename LA_traits<T>::normtype norm(const T scalar=(T)0) const; //is const only mathematically, not in internal implementation - we have to simplify first
|
||||||
|
2
vec.h
2
vec.h
@ -155,7 +155,7 @@ public:
|
|||||||
void copyonwrite(bool detachonly=false);
|
void copyonwrite(bool detachonly=false);
|
||||||
|
|
||||||
//! purge this vector
|
//! purge this vector
|
||||||
void clear() { copyonwrite(true); LA_traits<T>::clear(v, nn); };
|
void clear() { copyonwrite(LA_traits<T>::is_plaindata()); LA_traits<T>::clear(v, nn); };
|
||||||
|
|
||||||
//! assignment operator assigns given vector
|
//! assignment operator assigns given vector
|
||||||
NRVec& operator=(const NRVec &rhs);
|
NRVec& operator=(const NRVec &rhs);
|
||||||
|
Loading…
Reference in New Issue
Block a user