1 #include <symengine/matrices/diagonal_matrix.h>
2 #include <symengine/matrices/zero_matrix.h>
3 #include <symengine/matrices/identity_matrix.h>
11 hash_t seed = SYMENGINE_DIAGONALMATRIX;
12 for (
const auto &a : diag_)
13 hash_combine<Basic>(seed, *a);
19 if (is_a<DiagonalMatrix>(o)) {
20 const DiagonalMatrix &other = down_cast<const DiagonalMatrix &>(o);
21 return unified_eq(diag_, other.diag_);
28 SYMENGINE_ASSERT(is_a<DiagonalMatrix>(o));
29 const DiagonalMatrix &other = down_cast<const DiagonalMatrix &>(o);
33 bool is_zero_vec(
const vec_basic &container)
35 for (
auto &e : container) {
36 if (!(is_a<Integer>(*e) && down_cast<const Integer &>(*e).is_zero())) {
43 bool is_identity_vec(
const vec_basic &container)
45 for (
auto &e : container) {
46 if (!(is_a<Integer>(*e) && down_cast<const Integer &>(*e).is_one())) {
53 bool DiagonalMatrix::is_canonical(
const vec_basic &container)
const
55 if (container.size() == 0) {
58 if (is_zero_vec(container)) {
61 if (is_identity_vec(container)) {
67 RCP<const MatrixExpr> diagonal_matrix(
const vec_basic &container)
69 if (is_zero_vec(container)) {
70 return make_rcp<const ZeroMatrix>(
integer(container.size()),
72 }
else if (is_identity_vec(container)) {
73 return make_rcp<const IdentityMatrix>(
integer(container.size()));
75 return make_rcp<const DiagonalMatrix>(container);
The lowest unit of symbolic representation.
int compare(const Basic &o) const override
bool __eq__(const Basic &o) const override
Test equality.
hash_t __hash__() const override
Main namespace for SymEngine package.
std::enable_if< std::is_integral< T >::value, RCP< const Integer > >::type integer(T i)
int unified_compare(const T &a, const T &b)