implemented diffabs() useful for checks of results up to a sign

This commit is contained in:
2021-06-30 14:54:35 +02:00
parent 9d0249cdc4
commit cf86493a6f
5 changed files with 121 additions and 52 deletions

16
smat.h
View File

@@ -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