1 #ifndef SYMENGINE_MATRIX_H
2 #define SYMENGINE_MATRIX_H
16 bool is_square()
const
18 return ncols() == nrows();
25 virtual unsigned nrows()
const = 0;
26 virtual unsigned ncols()
const = 0;
27 virtual bool eq(
const MatrixBase &other)
const;
29 virtual tribool is_real(
const Assumptions *assumptions =
nullptr)
const = 0;
32 virtual RCP<const Basic> get(
unsigned i,
unsigned j)
const = 0;
33 virtual void set(
unsigned i,
unsigned j,
const RCP<const Basic> &e) = 0;
39 virtual unsigned rank()
const = 0;
40 virtual RCP<const Basic> det()
const = 0;
41 virtual void inv(
MatrixBase &result)
const = 0;
44 virtual void add_matrix(
const MatrixBase &other,
48 virtual void mul_matrix(
const MatrixBase &other,
52 virtual void elementwise_mul_matrix(
const MatrixBase &other,
56 virtual void add_scalar(
const RCP<const Basic> &k,
60 virtual void mul_scalar(
const RCP<const Basic> &k,
64 virtual void conjugate(
MatrixBase &result)
const = 0;
67 virtual void transpose(
MatrixBase &result)
const = 0;
70 virtual void conjugate_transpose(
MatrixBase &result)
const = 0;
73 virtual void submatrix(
MatrixBase &result,
unsigned row_start,
74 unsigned col_start,
unsigned row_end,
75 unsigned col_end,
unsigned row_step = 1,
76 unsigned col_step = 1)
const = 0;
93 virtual void cholesky(
MatrixBase &L)
const = 0;
115 void resize(
unsigned i,
unsigned j);
121 RCP<const Basic> get(
unsigned i,
unsigned j)
const override;
122 void set(
unsigned i,
unsigned j,
const RCP<const Basic> &e)
override;
125 unsigned nrows()
const override
129 unsigned ncols()
const override
140 virtual bool is_lower()
const;
141 virtual bool is_upper()
const;
142 virtual tribool is_zero()
const;
143 virtual tribool is_diagonal()
const;
144 tribool is_real(
const Assumptions *assumptions =
nullptr)
const override;
145 virtual tribool is_symmetric()
const;
146 virtual tribool is_hermitian()
const;
147 virtual tribool is_weakly_diagonally_dominant()
const;
148 virtual tribool is_strictly_diagonally_dominant()
const;
149 virtual tribool is_positive_definite()
const;
150 virtual tribool is_negative_definite()
const;
152 RCP<const Basic> trace()
const;
153 unsigned rank()
const override;
154 RCP<const Basic> det()
const override;
164 void elementwise_mul_matrix(
const MatrixBase &other,
168 void add_scalar(
const RCP<const Basic> &k,
172 void mul_scalar(
const RCP<const Basic> &k,
176 void conjugate(
MatrixBase &result)
const override;
179 void transpose(
MatrixBase &result)
const override;
182 void conjugate_transpose(
MatrixBase &result)
const override;
185 void submatrix(
MatrixBase &result,
unsigned row_start,
unsigned col_start,
186 unsigned row_end,
unsigned col_end,
unsigned row_step = 1,
187 unsigned col_step = 1)
const override;
218 friend void diff(
const DenseMatrix &A,
const RCP<const Symbol> &x,
221 friend void sdiff(
const DenseMatrix &A,
const RCP<const Basic> &x,
231 friend void elementwise_mul_dense_dense(
const DenseMatrix &A,
240 unsigned row_start,
unsigned col_start,
241 unsigned row_end,
unsigned col_end,
242 unsigned row_step,
unsigned col_step);
245 void row_insert(
const DenseMatrix &B,
unsigned pos);
246 void col_insert(
const DenseMatrix &B,
unsigned pos);
247 void row_del(
unsigned k);
248 void col_del(
unsigned k);
251 friend void row_exchange_dense(
DenseMatrix &A,
unsigned i,
unsigned j);
252 friend void row_mul_scalar_dense(
DenseMatrix &A,
unsigned i,
253 RCP<const Basic> &c);
254 friend void row_add_row_dense(
DenseMatrix &A,
unsigned i,
unsigned j,
255 RCP<const Basic> &c);
259 friend void column_exchange_dense(
DenseMatrix &A,
unsigned i,
unsigned j);
262 friend void pivoted_gaussian_elimination(
const DenseMatrix &A,
265 friend void fraction_free_gaussian_elimination(
const DenseMatrix &A,
267 friend void pivoted_fraction_free_gaussian_elimination(
269 friend void pivoted_gauss_jordan_elimination(
const DenseMatrix &A,
272 friend void fraction_free_gauss_jordan_elimination(
const DenseMatrix &A,
274 friend void pivoted_fraction_free_gauss_jordan_elimination(
276 friend unsigned pivot(
DenseMatrix &B,
unsigned r,
unsigned c);
280 bool normalize_last);
289 friend void fraction_free_gaussian_elimination_solve(
const DenseMatrix &A,
292 friend void fraction_free_gauss_jordan_solve(
const DenseMatrix &A,
310 friend bool is_symmetric_dense(
const DenseMatrix &A);
313 friend RCP<const Basic> det_bareis(
const DenseMatrix &A);
343 tribool shortcut_to_posdef()
const;
344 tribool is_positive_definite_GE();
362 bool is_canonical()
const;
364 bool eq(
const MatrixBase &other)
const override;
367 RCP<const Basic> get(
unsigned i,
unsigned j)
const override;
368 void set(
unsigned i,
unsigned j,
const RCP<const Basic> &e)
override;
370 unsigned nrows()
const override
374 unsigned ncols()
const override
379 tribool is_real(
const Assumptions *assumptions =
nullptr)
const override;
380 unsigned rank()
const override;
381 RCP<const Basic> det()
const override;
391 void elementwise_mul_matrix(
const MatrixBase &other,
395 void add_scalar(
const RCP<const Basic> &k,
399 void mul_scalar(
const RCP<const Basic> &k,
403 void conjugate(
MatrixBase &result)
const override;
406 void transpose(
MatrixBase &result)
const override;
410 void conjugate_transpose(
MatrixBase &result)
const override;
413 void submatrix(
MatrixBase &result,
unsigned row_start,
unsigned col_start,
414 unsigned row_end,
unsigned col_end,
unsigned row_step = 1,
415 unsigned col_step = 1)
const override;
458 static CSRMatrix from_coo(
unsigned row,
unsigned col,
463 bool diff_cache =
true);
465 bool diff_cache =
true);
475 friend void csr_binop_csr_canonical(
477 RCP<const Basic> (&bin_op)(
const RCP<const Basic> &,
478 const RCP<const Basic> &));
491 bool diff_cache =
true);
494 bool diff_cache =
true);
498 bool diff_cache =
true);
501 bool diff_cache =
true);
505 unsigned col_start,
unsigned row_end,
unsigned col_end,
506 unsigned row_step = 1,
unsigned col_step = 1);
509 void row_exchange_dense(
DenseMatrix &A,
unsigned i,
unsigned j);
510 void row_mul_scalar_dense(
DenseMatrix &A,
unsigned i, RCP<const Basic> &c);
511 void row_add_row_dense(
DenseMatrix &A,
unsigned i,
unsigned j,
512 RCP<const Basic> &c);
515 void column_exchange_dense(
DenseMatrix &A,
unsigned i,
unsigned j);
536 void fraction_free_gauss_jordan_solve(
const DenseMatrix &A,
547 RCP<const Basic> det_berkowitz(
const DenseMatrix &A);
572 bool normalize_last =
false);
579 return typeid(T) ==
typeid(b);
593 return not lhs.eq(rhs);
602 return out << A.__str__();
The base class for SymEngine.
static DenseMatrix loads(const std::string &)
Creates an instance of a serialized string.
std::string dumps() const
Returns a string of the instance serialized.
Main namespace for SymEngine package.
bool is_a(const Basic &b)
Templatised version to check is_a type.
std::ostream & operator<<(std::ostream &out, const SymEngine::Basic &p)
<< Operator
RCP< const Basic > conjugate(const RCP< const Basic > &arg)
Canonicalize Conjugate.