* Implementation of symbolic matrices */
/*
- * GiNaC Copyright (C) 1999-2017 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2018 Johannes Gutenberg University Mainz, Germany
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
/** Inverse of this matrix.
*
+ * @param algo selects the algorithm (one of solve_algo)
* @return the inverted matrix
* @exception logic_error (matrix not square)
* @exception runtime_error (singular matrix) */
-matrix matrix::inverse() const
+matrix matrix::inverse(unsigned algo) const
{
if (row != col)
throw (std::logic_error("matrix::inverse(): matrix not square"));
matrix sol(row,col);
try {
- sol = this->solve(vars,identity);
+ sol = this->solve(vars, identity, algo);
} catch (const std::runtime_error & e) {
if (e.what()==std::string("matrix::solve(): inconsistent linear system"))
throw (std::runtime_error("matrix::inverse(): singular matrix"));
unsigned last_assigned_sol = n+1;
for (int r=m-1; r>=0; --r) {
unsigned fnz = 1; // first non-zero in row
- while ((fnz<=n) && (aug.m[r*(n+p)+(fnz-1)].is_zero()))
+ while ((fnz<=n) && (aug.m[r*(n+p)+(fnz-1)].normal().is_zero()))
++fnz;
if (fnz>n) {
// row consists only of zeros, corresponding rhs must be 0, too
- if (!aug.m[r*(n+p)+n+co].is_zero()) {
+ if (!aug.m[r*(n+p)+n+co].normal().is_zero()) {
throw (std::runtime_error("matrix::solve(): inconsistent linear system"));
}
} else {