matrix_mul.h
1 #ifndef SYMENGINE_MATRICES_MATRIX_MUL_H
2 #define SYMENGINE_MATRICES_MATRIX_MUL_H
3 
4 #include <symengine/basic.h>
5 #include <symengine/constants.h>
6 #include <symengine/matrices/matrix_expr.h>
7 #include <symengine/matrices/size.h>
8 
9 namespace SymEngine
10 {
11 
12 class MatrixMul : public MatrixExpr
13 {
14 private:
15  RCP<const Basic> scalar_;
16  vec_basic factors_;
17 
18 public:
19  MatrixMul(const RCP<const Basic> &scalar, const vec_basic &factors)
20  : scalar_(scalar), factors_(factors)
21  {
22  SYMENGINE_ASSIGN_TYPEID();
23  SYMENGINE_ASSERT(is_canonical(scalar, factors));
24  }
25 
26  IMPLEMENT_TYPEID(SYMENGINE_MATRIXMUL)
27  hash_t __hash__() const override;
28  bool __eq__(const Basic &o) const override;
29  int compare(const Basic &o) const override;
30  bool is_canonical(const RCP<const Basic> &scalar,
31  const vec_basic &factors) const;
32  vec_basic get_args() const override
33  {
34  vec_basic args;
35  if (!eq(*scalar_, *one)) {
36  args.push_back(scalar_);
37  }
38  args.insert(args.end(), factors_.begin(), factors_.end());
39  return args;
40  }
41  inline const vec_basic &get_factors() const
42  {
43  return factors_;
44  }
45  inline const RCP<const Basic> &get_scalar() const
46  {
47  return scalar_;
48  }
49 };
50 
51 RCP<const MatrixExpr> matrix_mul(const vec_basic &factors);
52 
53 } // namespace SymEngine
54 
55 #endif
The base class for SymEngine.
#define IMPLEMENT_TYPEID(SYMENGINE_ID)
Inline members and functions.
Definition: basic.h:340
T begin(T... args)
The lowest unit of symbolic representation.
Definition: basic.h:97
bool __eq__(const Basic &o) const override
Test equality.
Definition: matrix_mul.cpp:23
hash_t __hash__() const override
Definition: matrix_mul.cpp:13
vec_basic get_args() const override
Returns the list of arguments.
Definition: matrix_mul.h:32
int compare(const Basic &o) const override
Definition: matrix_mul.cpp:35
T end(T... args)
T insert(T... args)
Main namespace for SymEngine package.
Definition: add.cpp:19
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21
T push_back(T... args)