2 #include <symengine/matrices/matrix_expr.h>
3 #include <symengine/matrices/transpose.h>
11 hash_t seed = SYMENGINE_TRANSPOSE;
12 hash_combine<Basic>(seed, *arg_);
18 return (is_a<Transpose>(o)
19 && arg_->__eq__(*down_cast<const Transpose &>(o).arg_));
22 bool Transpose::is_canonical(
const RCP<const MatrixExpr> &arg)
const
24 if (is_a<IdentityMatrix>(*arg) || is_a<ZeroMatrix>(*arg)
25 || is_a<DiagonalMatrix>(*arg) || is_a<ImmutableDenseMatrix>(*arg)
26 || is_a<Transpose>(*arg) || is_a<MatrixAdd>(*arg)
27 || is_a<HadamardProduct>(*arg)) {
35 SYMENGINE_ASSERT(is_a<Transpose>(o));
37 return arg_->compare(*down_cast<const Transpose &>(o).arg_);
48 RCP<const MatrixExpr> transpose_;
53 void bvisit(
const Basic &x){};
57 auto arg = rcp_static_cast<const MatrixExpr>(x.
rcp_from_this());
58 transpose_ = make_rcp<const Transpose>(arg);
63 transpose_ = rcp_static_cast<const MatrixExpr>(x.
rcp_from_this());
68 transpose_ = make_rcp<const ZeroMatrix>(x.ncols(), x.nrows());
73 transpose_ = rcp_static_cast<const MatrixExpr>(x.
rcp_from_this());
78 auto values = x.get_values();
81 for (
size_t i = 0; i < x.nrows(); i++)
82 for (
size_t j = 0; j < x.ncols(); j++)
83 t[j * x.nrows() + i] = x.get(i, j);
86 = make_rcp<const ImmutableDenseMatrix>(x.ncols(), x.nrows(), t);
91 transpose_ = x.get_arg();
97 for (
auto &e : x.get_terms()) {
101 transpose_ = make_rcp<const MatrixAdd>(t);
107 for (
auto &e : x.get_factors()) {
111 transpose_ = make_rcp<const HadamardProduct>(t);
114 RCP<const MatrixExpr> apply(
const MatrixExpr &s)
121 RCP<const MatrixExpr> transpose(
const RCP<const MatrixExpr> &arg)
124 return visitor.apply(*arg);
The base class for SymEngine.
The lowest unit of symbolic representation.
RCP< T > rcp_from_this()
Get RCP<T> pointer to self (it will cast the pointer to T)
vec_basic get_args() const override
Returns the list of arguments.
bool __eq__(const Basic &o) const override
Test equality.
int compare(const Basic &o) const override
hash_t __hash__() const override
Main namespace for SymEngine package.