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
134 virtual bool is_lower()
const;
135 virtual bool is_upper()
const;
136 virtual tribool is_zero()
const;
137 virtual tribool is_diagonal()
const;
138 tribool is_real(
const Assumptions *assumptions =
nullptr)
const override;
139 virtual tribool is_symmetric()
const;
140 virtual tribool is_hermitian()
const;
141 virtual tribool is_weakly_diagonally_dominant()
const;
142 virtual tribool is_strictly_diagonally_dominant()
const;
143 virtual tribool is_positive_definite()
const;
144 virtual tribool is_negative_definite()
const;
146 RCP<const Basic> trace()
const;
147 unsigned rank()
const override;
148 RCP<const Basic> det()
const override;
158 void elementwise_mul_matrix(
const MatrixBase &other,
162 void add_scalar(
const RCP<const Basic> &k,
166 void mul_scalar(
const RCP<const Basic> &k,
170 void conjugate(
MatrixBase &result)
const override;
173 void transpose(
MatrixBase &result)
const override;
176 void conjugate_transpose(
MatrixBase &result)
const override;
179 void submatrix(
MatrixBase &result,
unsigned row_start,
unsigned col_start,
180 unsigned row_end,
unsigned col_end,
unsigned row_step = 1,
181 unsigned col_step = 1)
const override;
212 friend void diff(
const DenseMatrix &A,
const RCP<const Symbol> &x,
215 friend void sdiff(
const DenseMatrix &A,
const RCP<const Basic> &x,
225 friend void elementwise_mul_dense_dense(
const DenseMatrix &A,
234 unsigned row_start,
unsigned col_start,
235 unsigned row_end,
unsigned col_end,
236 unsigned row_step,
unsigned col_step);
239 void row_insert(
const DenseMatrix &B,
unsigned pos);
240 void col_insert(
const DenseMatrix &B,
unsigned pos);
241 void row_del(
unsigned k);
242 void col_del(
unsigned k);
245 friend void row_exchange_dense(
DenseMatrix &A,
unsigned i,
unsigned j);
246 friend void row_mul_scalar_dense(
DenseMatrix &A,
unsigned i,
247 RCP<const Basic> &c);
248 friend void row_add_row_dense(
DenseMatrix &A,
unsigned i,
unsigned j,
249 RCP<const Basic> &c);
253 friend void column_exchange_dense(
DenseMatrix &A,
unsigned i,
unsigned j);
256 friend void pivoted_gaussian_elimination(
const DenseMatrix &A,
259 friend void fraction_free_gaussian_elimination(
const DenseMatrix &A,
261 friend void pivoted_fraction_free_gaussian_elimination(
263 friend void pivoted_gauss_jordan_elimination(
const DenseMatrix &A,
266 friend void fraction_free_gauss_jordan_elimination(
const DenseMatrix &A,
268 friend void pivoted_fraction_free_gauss_jordan_elimination(
270 friend unsigned pivot(
DenseMatrix &B,
unsigned r,
unsigned c);
274 bool normalize_last);
283 friend void fraction_free_gaussian_elimination_solve(
const DenseMatrix &A,
286 friend void fraction_free_gauss_jordan_solve(
const DenseMatrix &A,
304 friend bool is_symmetric_dense(
const DenseMatrix &A);
307 friend RCP<const Basic> det_bareis(
const DenseMatrix &A);
337 tribool shortcut_to_posdef()
const;
338 tribool is_positive_definite_GE();
356 bool is_canonical()
const;
358 bool eq(
const MatrixBase &other)
const override;
361 RCP<const Basic> get(
unsigned i,
unsigned j)
const override;
362 void set(
unsigned i,
unsigned j,
const RCP<const Basic> &e)
override;
364 unsigned nrows()
const override
368 unsigned ncols()
const override
373 tribool is_real(
const Assumptions *assumptions =
nullptr)
const override;
374 unsigned rank()
const override;
375 RCP<const Basic> det()
const override;
385 void elementwise_mul_matrix(
const MatrixBase &other,
389 void add_scalar(
const RCP<const Basic> &k,
393 void mul_scalar(
const RCP<const Basic> &k,
397 void conjugate(
MatrixBase &result)
const override;
400 void transpose(
MatrixBase &result)
const override;
404 void conjugate_transpose(
MatrixBase &result)
const override;
407 void submatrix(
MatrixBase &result,
unsigned row_start,
unsigned col_start,
408 unsigned row_end,
unsigned col_end,
unsigned row_step = 1,
409 unsigned col_step = 1)
const override;
452 static CSRMatrix from_coo(
unsigned row,
unsigned col,
457 bool diff_cache =
true);
459 bool diff_cache =
true);
469 friend void csr_binop_csr_canonical(
471 RCP<const Basic> (&bin_op)(
const RCP<const Basic> &,
472 const RCP<const Basic> &));
485 bool diff_cache =
true);
488 bool diff_cache =
true);
492 bool diff_cache =
true);
495 bool diff_cache =
true);
499 unsigned col_start,
unsigned row_end,
unsigned col_end,
500 unsigned row_step = 1,
unsigned col_step = 1);
503 void row_exchange_dense(
DenseMatrix &A,
unsigned i,
unsigned j);
504 void row_mul_scalar_dense(
DenseMatrix &A,
unsigned i, RCP<const Basic> &c);
505 void row_add_row_dense(
DenseMatrix &A,
unsigned i,
unsigned j,
506 RCP<const Basic> &c);
509 void column_exchange_dense(
DenseMatrix &A,
unsigned i,
unsigned j);
530 void fraction_free_gauss_jordan_solve(
const DenseMatrix &A,
541 RCP<const Basic> det_berkowitz(
const DenseMatrix &A);
566 bool normalize_last =
false);
573 return typeid(T) ==
typeid(b);
587 return not lhs.eq(rhs);
596 return out << A.__str__();
The base class for SymEngine.
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.