mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-10 02:39:03 +08:00
Print diagonal matrix
This commit is contained in:
parent
fba12e02b3
commit
c999284bad
@ -72,6 +72,13 @@ class DiagonalBase : public EigenBase<Derived>
|
||||
EIGEN_DEVICE_FUNC
|
||||
inline DiagonalVectorType& diagonal() { return derived().diagonal(); }
|
||||
|
||||
/** \returns the value of the coefficient as if \c *this was a dense matrix. */
|
||||
EIGEN_DEVICE_FUNC
|
||||
inline Scalar coeff(Index row, Index col) const {
|
||||
eigen_assert(row >= 0 && col >= 0 && row < rows() && col <= cols());
|
||||
return row == col ? diagonal().coeff(row) : Scalar(0);
|
||||
}
|
||||
|
||||
/** \returns the number of rows. */
|
||||
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
|
||||
inline Index rows() const { return diagonal().size(); }
|
||||
|
@ -253,6 +253,11 @@ std::ostream & operator <<
|
||||
return internal::print_matrix(s, m.eval(), EIGEN_DEFAULT_IO_FORMAT);
|
||||
}
|
||||
|
||||
template <typename Derived>
|
||||
std::ostream& operator<<(std::ostream& s, const DiagonalBase<Derived>& m) {
|
||||
return internal::print_matrix(s, m.derived(), EIGEN_DEFAULT_IO_FORMAT);
|
||||
}
|
||||
|
||||
} // end namespace Eigen
|
||||
|
||||
#endif // EIGEN_IO_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user