semisparsemat ostream output

This commit is contained in:
2026-02-03 17:21:04 +01:00
parent b1f1be8457
commit 22818a539c
2 changed files with 10 additions and 2 deletions

View File

@@ -326,10 +326,9 @@ return *this;
template <typename T>
class SemiSparseMat {
friend class NRMat<T>;
protected:
public:
NRVec<T> diagonal;
SparseMat<T> offdiagonal;
public:
SemiSparseMat() {};
SemiSparseMat(const SPMatindex n, const SPMatindex m) : offdiagonal(n,m) {if(n==m) diagonal.resize(n);};
SPMatindex nrows() const {return offdiagonal.nrows();}
@@ -361,6 +360,14 @@ public:
void resize(const SPMatindex n, const SPMatindex m) {offdiagonal.resize(n,m); diagonal.resize(n==m?n:0);}
};
template <class T>
std::ostream& operator<<(std::ostream &s, const SemiSparseMat<T> &x)
{
s << "diagonal= "<<x.diagonal;
s << "offdiagonal= "<<x.offdiagonal;
return s;
}
}//namespace
#endif