immutable_dense_matrix.h
1 #ifndef SYMENGINE_MATRICES_IMMUTABLE_DENSE_MATRIX_H
2 #define SYMENGINE_MATRICES_IMMUTABLE_DENSE_MATRIX_H
3 
4 #include <symengine/basic.h>
5 #include <symengine/matrices/matrix_expr.h>
6 #include <symengine/integer.h>
7 
8 namespace SymEngine
9 {
10 
12 {
13 private:
14  size_t m_, n_;
15  vec_basic values_;
16 
17 public:
18  ImmutableDenseMatrix(size_t m, size_t n, const vec_basic &values)
19  : m_(m), n_(n), values_(values)
20  {
21  SYMENGINE_ASSIGN_TYPEID();
22  SYMENGINE_ASSERT(is_canonical(m, n, values));
23  }
24 
25  IMPLEMENT_TYPEID(SYMENGINE_IMMUTABLEDENSEMATRIX)
26  hash_t __hash__() const override;
27  bool __eq__(const Basic &o) const override;
28  int compare(const Basic &o) const override;
29  bool is_canonical(size_t m, size_t n, const vec_basic &values) const;
30 
31  vec_basic get_args() const override
32  {
33  vec_basic args = vec_basic({integer(m_), integer(n_)});
34  args.insert(args.begin(), values_.begin(), values_.end());
35  return args;
36  }
37 
38  inline RCP<const Basic> get(size_t i, size_t j) const
39  {
40  return values_[i * n_ + j];
41  }
42 
43  inline size_t nrows() const
44  {
45  return m_;
46  }
47 
48  inline size_t ncols() const
49  {
50  return n_;
51  }
52 
53  inline const vec_basic &get_values() const
54  {
55  return values_;
56  }
57 };
58 
59 RCP<const MatrixExpr> immutable_dense_matrix(size_t m, size_t n,
60  const vec_basic &container);
61 
62 } // namespace SymEngine
63 
64 #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.
T end(T... args)
T insert(T... args)
Main namespace for SymEngine package.
Definition: add.cpp:19
std::enable_if< std::is_integral< T >::value, RCP< const Integer > >::type integer(T i)
Definition: integer.h:197