implemented diffabs() useful for checks of results up to a sign
This commit is contained in:
16
smat.h
16
smat.h
@@ -186,6 +186,7 @@ public:
|
||||
#endif
|
||||
|
||||
}
|
||||
NRSMat diffabs(const NRSMat &rhs) const; //difference of absolute values
|
||||
};
|
||||
|
||||
}//namespace
|
||||
@@ -389,6 +390,21 @@ inline NRSMat<T> & NRSMat<T>::operator-=(const T &a) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*difference of absolute values*/
|
||||
template <typename T>
|
||||
NRSMat<T> NRSMat<T>::diffabs(const NRSMat<T> &rhs) const {
|
||||
#ifdef DEBUG
|
||||
if (nn != rhs.nn) laerror("incompatible dimensions");
|
||||
#endif
|
||||
NOT_GPU(*this);
|
||||
NOT_GPU(rhs);
|
||||
|
||||
NRSMat<T> r(nn);
|
||||
for(int i=0; i<NN2; ++i) r.v[i] = MYABS(v[i]) - MYABS(rhs.v[i]);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************//**
|
||||
* add up this real symmetric matrix with given symmetric matrix
|
||||
* @param[in] rhs real symmetric matrix to be added
|
||||
|
||||
Reference in New Issue
Block a user