diagonal_matrix.h
1 #ifndef SYMENGINE_MATRICES_DIAGONAL_MATRIX_H
2 #define SYMENGINE_MATRICES_DIAGONAL_MATRIX_H
3 
4 #include <symengine/basic.h>
5 #include <symengine/matrices/matrix_expr.h>
6 
7 namespace SymEngine
8 {
9 
10 class DiagonalMatrix : public MatrixExpr
11 {
12 private:
13  vec_basic diag_;
14 
15 public:
16  DiagonalMatrix(const vec_basic &container) : diag_(container)
17  {
18  SYMENGINE_ASSIGN_TYPEID();
19  SYMENGINE_ASSERT(is_canonical(container));
20  }
21 
22  IMPLEMENT_TYPEID(SYMENGINE_DIAGONALMATRIX)
23  hash_t __hash__() const override;
24  bool __eq__(const Basic &o) const override;
25  int compare(const Basic &o) const override;
26  bool is_canonical(const vec_basic &container) const;
27 
28  vec_basic get_args() const override
29  {
30  return vec_basic(diag_.begin(), diag_.end());
31  }
32 
33  inline const vec_basic &get_container() const
34  {
35  return diag_;
36  }
37 
38  inline RCP<const Basic> get(size_t i) const
39  {
40  return diag_[i];
41  }
42 };
43 
44 bool is_zero_vec(const vec_basic &container);
45 bool is_identity_vec(const vec_basic &container);
46 
47 RCP<const MatrixExpr> diagonal_matrix(const vec_basic &container);
48 
49 } // namespace SymEngine
50 
51 #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
vec_basic get_args() const override
Returns the list of arguments.
int compare(const Basic &o) const override
bool __eq__(const Basic &o) const override
Test equality.
hash_t __hash__() const override
T end(T... args)
Main namespace for SymEngine package.
Definition: add.cpp:19