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

46
mat.cc
View File

@@ -1429,29 +1429,6 @@ NRMat<std::complex<double> >::operator+=(const NRMat< std::complex<double> > &r
return *this;
}
/***************************************************************************//**
* add a given general matrix (type T) \f$A\f$ to the current complex matrix
* @param[in] rhs matrix \f$A\f$ of type T
* @return reference to the modified matrix
******************************************************************************/
template <typename T>
NRMat<T> & NRMat<T>::operator+=(const NRMat<T> &rhs) {
#ifdef DEBUG
if (nn != rhs.nn || mm != rhs.mm) laerror("incompatible matrices");
#endif
SAME_LOC(*this, rhs);
NOT_GPU(*this);
copyonwrite();
#ifdef MATPTR
for(size_t i=0; i< (size_t)nn*mm; i++) v[0][i] += rhs.v[0][i];
#else
for(size_t i=0; i< (size_t)nn*mm; i++) v[i] += rhs.v[i];
#endif
return *this;
}
/***************************************************************************//**
* subtract a given real matrix \f$A\f$ from the current real matrix
@@ -1505,29 +1482,6 @@ NRMat< std::complex<double> >::operator-=(const NRMat< std::complex<double> > &
}
/***************************************************************************//**
* subtract a given general matrix (type T) \f$A\f$ from the current matrix
* @param[in] rhs matrix \f$A\f$ of type T
* @return reference to the modified matrix
******************************************************************************/
template <typename T>
NRMat<T> & NRMat<T>::operator-=(const NRMat<T> &rhs) {
#ifdef DEBUG
if (nn != rhs.nn || mm != rhs.mm) laerror("incompatible matrices");
#endif
SAME_LOC(*this, rhs);
NOT_GPU(*this);
copyonwrite();
#ifdef MATPTR
for(size_t i=0; i< (size_t)nn*mm; i++) v[0][i] += rhs.v[0][i];
#else
for(size_t i=0; i<(size_t) nn*mm; i++) v[i] += rhs.v[i];
#endif
return *this;
}
/***************************************************************************//**
* add a given sparse real matrix \f$A\f$ stored in packed form to the current