matrix.cpp
1 #include <symengine/matrix.h>
2 
3 namespace SymEngine
4 {
5 
6 std::string MatrixBase::__str__() const
7 {
9 
10  for (unsigned i = 0; i < nrows(); i++) {
11  o << "[";
12  for (unsigned j = 0; j < ncols() - 1; j++)
13  o << *this->get(i, j) << ", ";
14  o << *this->get(i, ncols() - 1) << "]" << std::endl;
15  }
16 
17  return o.str();
18 }
19 
20 bool MatrixBase::eq(const MatrixBase &other) const
21 {
22  if (this->nrows() != other.nrows() or this->ncols() != other.ncols())
23  return false;
24 
25  for (unsigned i = 0; i < this->nrows(); i++)
26  for (unsigned j = 0; j < this->ncols(); j++)
27  if (neq(*this->get(i, j), *(other.get(i, j))))
28  return false;
29 
30  return true;
31 }
32 
33 } // namespace SymEngine
T endl(T... args)
Main namespace for SymEngine package.
Definition: add.cpp:19
bool neq(const Basic &a, const Basic &b)
Checks inequality for a and b
Definition: basic-inl.h:29
T str(T... args)