NRSMat sum()

This commit is contained in:
2025-03-04 16:46:59 +01:00
parent ad1bee99a5
commit 8f037f7ccf
3 changed files with 65 additions and 5 deletions

11
smat.h
View File

@@ -169,6 +169,17 @@ public:
inline const T amax() const;
inline const T amin() const;
//! sum all matrix elements
const T sum(bool onlytriangle=false) const
{
T s = NRVec<T>(*this).sum();
if(onlytriangle) return s;
s*=2;
for(int i=0; i<nn; ++i) s -= (*this)(i,i);
return s;
}
const T trace() const;
void get(int fd, bool dimensions = 1, bool transp = 0);
void put(int fd, bool dimensions = 1, bool transp = 0) const;