matrix_symbol.cpp
1 #include <symengine/matrices/matrix_symbol.h>
2 
3 namespace SymEngine
4 {
5 
6 hash_t MatrixSymbol::__hash__() const
7 {
8  hash_t seed = SYMENGINE_MATRIXSYMBOL;
9  hash_combine(seed, name_);
10  return seed;
11 }
12 
13 bool MatrixSymbol::__eq__(const Basic &o) const
14 {
15  return (is_a<MatrixSymbol>(o)
16  && name_ == down_cast<const MatrixSymbol &>(o).name_);
17 }
18 
19 int MatrixSymbol::compare(const Basic &o) const
20 {
21  SYMENGINE_ASSERT(is_a<MatrixSymbol>(o));
22 
23  const MatrixSymbol &s = down_cast<const MatrixSymbol &>(o);
24  if (name_ == s.name_)
25  return 0;
26  return name_ < s.name_ ? -1 : 1;
27 }
28 
29 RCP<const MatrixExpr> matrix_symbol(const std::string &name)
30 {
31  return make_rcp<const MatrixSymbol>(name);
32 }
33 
34 } // namespace SymEngine
The lowest unit of symbolic representation.
Definition: basic.h:97
hash_t __hash__() const override
bool __eq__(const Basic &o) const override
Test equality.
int compare(const Basic &o) const override
Main namespace for SymEngine package.
Definition: add.cpp:19
void hash_combine(hash_t &seed, const T &v)
Definition: basic-inl.h:95