GiNaC 1.8.7
|
Symbolic matrices. More...
#include <matrix.h>
Public Member Functions | |
matrix (unsigned r, unsigned c) | |
Very common ctor. More... | |
matrix (unsigned r, unsigned c, const lst &l) | |
Construct matrix from (flat) list of elements. More... | |
matrix (std::initializer_list< std::initializer_list< ex > > l) | |
Construct a matrix from an 2 dimensional initializer list. More... | |
size_t | nops () const override |
nops is defined to be rows x columns. More... | |
ex | op (size_t i) const override |
returns matrix entry at position (i/col, icol). More... | |
ex & | let_op (size_t i) override |
returns writable matrix entry at position (i/col, icol). More... | |
ex | evalm () const override |
Evaluate sums, products and integer powers of matrices. More... | |
ex | subs (const exmap &m, unsigned options=0) const override |
Substitute a set of objects by arbitrary expressions. More... | |
ex | eval_indexed (const basic &i) const override |
Automatic symbolic evaluation of an indexed matrix. More... | |
ex | add_indexed (const ex &self, const ex &other) const override |
Sum of two indexed matrices. More... | |
ex | scalar_mul_indexed (const ex &self, const numeric &other) const override |
Product of an indexed matrix with a number. More... | |
bool | contract_with (exvector::iterator self, exvector::iterator other, exvector &v) const override |
Contraction of an indexed matrix with something else. More... | |
ex | conjugate () const override |
Complex conjugate every matrix entry. More... | |
ex | real_part () const override |
ex | imag_part () const override |
void | archive (archive_node &n) const override |
Save (a.k.a. More... | |
void | read_archive (const archive_node &n, lst &syms) override |
Read (a.k.a. More... | |
unsigned | rows () const |
Get number of rows. More... | |
unsigned | cols () const |
Get number of columns. More... | |
matrix | add (const matrix &other) const |
Sum of matrices. More... | |
matrix | sub (const matrix &other) const |
Difference of matrices. More... | |
matrix | mul (const matrix &other) const |
Product of matrices. More... | |
matrix | mul (const numeric &other) const |
Product of matrix and scalar. More... | |
matrix | mul_scalar (const ex &other) const |
Product of matrix and scalar expression. More... | |
matrix | pow (const ex &expn) const |
Power of a matrix. More... | |
const ex & | operator() (unsigned ro, unsigned co) const |
operator() to access elements for reading. More... | |
ex & | operator() (unsigned ro, unsigned co) |
operator() to access elements for writing. More... | |
matrix & | set (unsigned ro, unsigned co, const ex &value) |
matrix | transpose () const |
Transposed of an m x n matrix, producing a new n x m matrix object that represents the transposed. More... | |
ex | determinant (unsigned algo=determinant_algo::automatic) const |
Determinant of square matrix. More... | |
ex | trace () const |
Trace of a matrix. More... | |
ex | charpoly (const ex &lambda) const |
Characteristic Polynomial. More... | |
matrix | inverse () const |
Inverse of this matrix, with automatic algorithm selection. More... | |
matrix | inverse (unsigned algo) const |
Inverse of this matrix. More... | |
matrix | solve (const matrix &vars, const matrix &rhs, unsigned algo=solve_algo::automatic) const |
Solve a linear system consisting of a m x n matrix and a m x p right hand side by applying an elimination scheme to the augmented matrix. More... | |
unsigned | rank () const |
Compute the rank of this matrix. More... | |
unsigned | rank (unsigned solve_algo) const |
Compute the rank of this matrix using the given algorithm, which should be a member of enum solve_algo. More... | |
bool | is_zero_matrix () const |
Function to check that all elements of the matrix are zero. More... | |
Public Member Functions inherited from GiNaC::basic | |
virtual | ~basic () |
basic destructor, virtual because class ex will delete objects of derived classes via a basic*. More... | |
basic (const basic &other) | |
const basic & | operator= (const basic &other) |
basic assignment operator: the other object might be of a derived class. More... | |
virtual basic * | duplicate () const |
Create a clone of this object on the heap. More... | |
virtual ex | eval () const |
Perform automatic non-interruptive term rewriting rules. More... | |
virtual ex | evalf () const |
Evaluate object numerically. More... | |
virtual ex | evalm () const |
Evaluate sums, products and integer powers of matrices. More... | |
virtual ex | eval_integ () const |
Evaluate integrals, if result is known. More... | |
virtual ex | eval_indexed (const basic &i) const |
Perform automatic symbolic evaluations on indexed expression that contains this object as the base expression. More... | |
virtual void | print (const print_context &c, unsigned level=0) const |
Output to stream. More... | |
virtual void | dbgprint () const |
Little wrapper around print to be called within a debugger. More... | |
virtual void | dbgprinttree () const |
Little wrapper around printtree to be called within a debugger. More... | |
virtual unsigned | precedence () const |
Return relative operator precedence (for parenthezing output). More... | |
virtual bool | info (unsigned inf) const |
Information about the object. More... | |
virtual size_t | nops () const |
Number of operands/members. More... | |
virtual ex | op (size_t i) const |
Return operand/member at position i. More... | |
virtual ex | operator[] (const ex &index) const |
virtual ex | operator[] (size_t i) const |
virtual ex & | let_op (size_t i) |
Return modifiable operand/member at position i. More... | |
virtual ex & | operator[] (const ex &index) |
virtual ex & | operator[] (size_t i) |
virtual bool | has (const ex &other, unsigned options=0) const |
Test for occurrence of a pattern. More... | |
virtual bool | match (const ex &pattern, exmap &repls) const |
Check whether the expression matches a given pattern. More... | |
virtual ex | subs (const exmap &m, unsigned options=0) const |
Substitute a set of objects by arbitrary expressions. More... | |
virtual ex | map (map_function &f) const |
Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively). More... | |
virtual void | accept (GiNaC::visitor &v) const |
virtual bool | is_polynomial (const ex &var) const |
Check whether this is a polynomial in the given variables. More... | |
virtual int | degree (const ex &s) const |
Return degree of highest power in object s. More... | |
virtual int | ldegree (const ex &s) const |
Return degree of lowest power in object s. More... | |
virtual ex | coeff (const ex &s, int n=1) const |
Return coefficient of degree n in object s. More... | |
virtual ex | expand (unsigned options=0) const |
Expand expression, i.e. More... | |
virtual ex | collect (const ex &s, bool distributed=false) const |
Sort expanded expression in terms of powers of some object(s). More... | |
virtual ex | series (const relational &r, int order, unsigned options=0) const |
Default implementation of ex::series(). More... | |
virtual ex | normal (exmap &repl, exmap &rev_lookup, lst &modifier) const |
Default implementation of ex::normal(). More... | |
virtual ex | to_rational (exmap &repl) const |
Default implementation of ex::to_rational(). More... | |
virtual ex | to_polynomial (exmap &repl) const |
virtual numeric | integer_content () const |
virtual ex | smod (const numeric &xi) const |
Apply symmetric modular homomorphism to an expanded multivariate polynomial. More... | |
virtual numeric | max_coefficient () const |
Implementation ex::max_coefficient(). More... | |
virtual exvector | get_free_indices () const |
Return a vector containing the free indices of an expression. More... | |
virtual ex | add_indexed (const ex &self, const ex &other) const |
Add two indexed expressions. More... | |
virtual ex | scalar_mul_indexed (const ex &self, const numeric &other) const |
Multiply an indexed expression with a scalar. More... | |
virtual bool | contract_with (exvector::iterator self, exvector::iterator other, exvector &v) const |
Try to contract two indexed expressions that appear in the same product. More... | |
virtual unsigned | return_type () const |
virtual return_type_t | return_type_tinfo () const |
virtual ex | conjugate () const |
virtual ex | real_part () const |
virtual ex | imag_part () const |
template<class T > | |
void | print_dispatch (const print_context &c, unsigned level) const |
Like print(), but dispatch to the specified class. More... | |
void | print_dispatch (const registered_class_info &ri, const print_context &c, unsigned level) const |
Like print(), but dispatch to the specified class. More... | |
virtual void | archive (archive_node &n) const |
Save (serialize) the object into archive node. More... | |
virtual void | read_archive (const archive_node &n, lst &syms) |
Load (deserialize) the object from an archive node. More... | |
ex | subs_one_level (const exmap &m, unsigned options) const |
Helper function for subs(). More... | |
ex | diff (const symbol &s, unsigned nth=1) const |
Default interface of nth derivative ex::diff(s, n). More... | |
int | compare (const basic &other) const |
Compare objects syntactically to establish canonical ordering. More... | |
bool | is_equal (const basic &other) const |
Test for syntactic equality. More... | |
const basic & | hold () const |
Stop further evaluation. More... | |
unsigned | gethash () const |
const basic & | setflag (unsigned f) const |
Set some status_flags. More... | |
const basic & | clearflag (unsigned f) const |
Clear some status_flags. More... | |
Public Member Functions inherited from GiNaC::refcounted | |
refcounted () noexcept | |
unsigned int | add_reference () noexcept |
unsigned int | remove_reference () noexcept |
unsigned int | get_refcount () const noexcept |
void | set_refcount (unsigned int r) noexcept |
Protected Member Functions | |
matrix (unsigned r, unsigned c, const exvector &m2) | |
Ctor from representation, for internal use only. More... | |
matrix (unsigned r, unsigned c, exvector &&m2) | |
bool | match_same_type (const basic &other) const override |
Returns true if the attributes of two objects are similar enough for a match. More... | |
unsigned | return_type () const override |
ex | determinant_minor () const |
Recursive determinant for small matrices having at least one symbolic entry. More... | |
std::vector< unsigned > | echelon_form (unsigned algo, int n) |
int | gauss_elimination (const bool det=false) |
Perform the steps of an ordinary Gaussian elimination to bring the m x n matrix into an upper echelon form. More... | |
int | division_free_elimination (const bool det=false) |
Perform the steps of division free elimination to bring the m x n matrix into an upper echelon form. More... | |
int | fraction_free_elimination (const bool det=false) |
Perform the steps of Bareiss' one-step fraction free elimination to bring the matrix into an upper echelon form. More... | |
std::vector< unsigned > | markowitz_elimination (unsigned n) |
int | pivot (unsigned ro, unsigned co, bool symbolic=true) |
Partial pivoting method for matrix elimination schemes. More... | |
void | print_elements (const print_context &c, const char *row_start, const char *row_end, const char *row_sep, const char *col_sep) const |
void | do_print (const print_context &c, unsigned level) const |
void | do_print_latex (const print_latex &c, unsigned level) const |
void | do_print_python_repr (const print_python_repr &c, unsigned level) const |
Protected Member Functions inherited from GiNaC::basic | |
basic () | |
virtual ex | eval_ncmul (const exvector &v) const |
virtual bool | match_same_type (const basic &other) const |
Returns true if the attributes of two objects are similar enough for a match. More... | |
virtual ex | derivative (const symbol &s) const |
Default implementation of ex::diff(). More... | |
virtual int | compare_same_type (const basic &other) const |
Returns order relation between two objects of same type. More... | |
virtual bool | is_equal_same_type (const basic &other) const |
Returns true if two objects of same type are equal. More... | |
virtual unsigned | calchash () const |
Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so. More... | |
void | ensure_if_modifiable () const |
Ensure the object may be modified without hurting others, throws if this is not the case. More... | |
void | do_print (const print_context &c, unsigned level) const |
Default output to stream. More... | |
void | do_print_tree (const print_tree &c, unsigned level) const |
Tree output to stream. More... | |
void | do_print_python_repr (const print_python_repr &c, unsigned level) const |
Python parsable output to stream. More... | |
Protected Attributes | |
unsigned | row |
number of rows More... | |
unsigned | col |
number of columns More... | |
exvector | m |
representation (cols indexed first) More... | |
Protected Attributes inherited from GiNaC::basic | |
unsigned | flags |
of type status_flags More... | |
unsigned | hashvalue |
hash value More... | |
GiNaC::matrix::matrix | ( | unsigned | r, |
unsigned | c | ||
) |
Very common ctor.
Initializes to r x c-dimensional zero-matrix.
r | number of rows |
c | number of cols |
Definition at line 71 of file matrix.cpp.
References GiNaC::status_flags::not_shareable, and GiNaC::basic::setflag().
Referenced by add(), conjugate(), determinant(), imag_part(), mul(), mul_scalar(), real_part(), sub(), subs(), and transpose().
GiNaC::matrix::matrix | ( | unsigned | r, |
unsigned | c, | ||
const lst & | l | ||
) |
Construct matrix from (flat) list of elements.
If the list has fewer elements than the matrix, the remaining matrix elements are set to zero. If the list has more elements than the matrix, the excessive elements are thrown away.
Definition at line 80 of file matrix.cpp.
References c, m, GiNaC::status_flags::not_shareable, r, GiNaC::basic::setflag(), and x.
GiNaC::matrix::matrix | ( | std::initializer_list< std::initializer_list< ex > > | l | ) |
Construct a matrix from an 2 dimensional initializer list.
Throws an exception if some row has a different length than all the others.
Definition at line 99 of file matrix.cpp.
References c, col, m, GiNaC::status_flags::not_shareable, r, row, and GiNaC::basic::setflag().
|
protected |
Ctor from representation, for internal use only.
Definition at line 119 of file matrix.cpp.
References GiNaC::status_flags::not_shareable, and GiNaC::basic::setflag().
|
protected |
Definition at line 124 of file matrix.cpp.
References GiNaC::status_flags::not_shareable, and GiNaC::basic::setflag().
|
overridevirtual |
nops is defined to be rows x columns.
Reimplemented from GiNaC::basic.
Definition at line 206 of file matrix.cpp.
|
overridevirtual |
returns matrix entry at position (i/col, icol).
Reimplemented from GiNaC::basic.
Definition at line 212 of file matrix.cpp.
References GINAC_ASSERT, m, and nops().
Referenced by contract_with().
|
overridevirtual |
returns writable matrix entry at position (i/col, icol).
Reimplemented from GiNaC::basic.
Definition at line 220 of file matrix.cpp.
References GiNaC::basic::ensure_if_modifiable(), GINAC_ASSERT, m, and nops().
|
inlineoverridevirtual |
Evaluate sums, products and integer powers of matrices.
Reimplemented from GiNaC::basic.
Substitute a set of objects by arbitrary expressions.
The ex returned will already be evaluated.
Reimplemented from GiNaC::basic.
Definition at line 228 of file matrix.cpp.
References c, col, m, matrix(), options, r, row, and subs().
Referenced by fraction_free_elimination(), and subs().
Automatic symbolic evaluation of an indexed matrix.
Reimplemented from GiNaC::basic.
Definition at line 320 of file matrix.cpp.
References col, GiNaC::idx::get_dim(), GiNaC::idx::get_value(), GINAC_ASSERT, GiNaC::basic::hold(), GiNaC::is_dummy_pair(), GiNaC::ex::is_equal(), GiNaC::info_flags::nonnegint, GiNaC::basic::nops(), GiNaC::basic::op(), row, and trace().
Sum of two indexed matrices.
Reimplemented from GiNaC::basic.
Definition at line 397 of file matrix.cpp.
References add(), col, GINAC_ASSERT, GiNaC::ex::is_equal(), GiNaC::ex::nops(), GiNaC::ex::op(), row, and transpose().
|
overridevirtual |
Product of an indexed matrix with a number.
Reimplemented from GiNaC::basic.
Definition at line 433 of file matrix.cpp.
References GINAC_ASSERT, mul(), GiNaC::ex::nops(), and GiNaC::ex::op().
|
overridevirtual |
Contraction of an indexed matrix with something else.
Reimplemented from GiNaC::basic.
Definition at line 448 of file matrix.cpp.
References GiNaC::_ex1, col, GINAC_ASSERT, GiNaC::is_dummy_pair(), mul(), GiNaC::ex::op(), op(), row, and transpose().
|
overridevirtual |
Complex conjugate every matrix entry.
Reimplemented from GiNaC::basic.
Definition at line 239 of file matrix.cpp.
References GiNaC::are_ex_trivially_equal(), col, m, matrix(), row, and x.
|
overridevirtual |
Reimplemented from GiNaC::basic.
Definition at line 264 of file matrix.cpp.
|
overridevirtual |
Reimplemented from GiNaC::basic.
Definition at line 273 of file matrix.cpp.
|
overridevirtual |
Save (a.k.a.
serialize) object into archive.
Reimplemented from GiNaC::basic.
Definition at line 152 of file matrix.cpp.
|
overridevirtual |
Read (a.k.a.
deserialize) object from archive.
Reimplemented from GiNaC::basic.
Definition at line 134 of file matrix.cpp.
|
overrideprotectedvirtual |
Returns true if the attributes of two objects are similar enough for a match.
This function must not match subexpressions (this is already done by basic::match()). Only attributes not accessible by op() should be compared. This is also the reason why this function doesn't take the wildcard replacement list from match() as an argument: only subexpressions are subject to wildcard matches. Also, this function only needs to be implemented for container classes because is_equal_same_type() is automatically used instead of match_same_type() if nops() == 0.
Reimplemented from GiNaC::basic.
Definition at line 309 of file matrix.cpp.
References col, cols(), GINAC_ASSERT, row, and rows().
|
inlineoverrideprotectedvirtual |
Reimplemented from GiNaC::basic.
Definition at line 71 of file matrix.h.
References GiNaC::return_types::noncommutative.
|
inline |
Get number of rows.
Definition at line 75 of file matrix.h.
References row.
Referenced by division_free_elimination(), fraction_free_elimination(), gauss_elimination(), GiNaC::lsolve(), match_same_type(), mul(), solve(), and transpose().
|
inline |
Get number of columns.
Definition at line 77 of file matrix.h.
References col.
Referenced by determinant_minor(), division_free_elimination(), fraction_free_elimination(), gauss_elimination(), GiNaC::lsolve(), match_same_type(), mul(), solve(), and transpose().
Sum of matrices.
logic_error | (incompatible matrices) |
Definition at line 555 of file matrix.cpp.
References col, m, matrix(), and row.
Referenced by add_indexed(), and GiNaC::add::evalm().
Product of matrices.
logic_error | (incompatible matrices) |
Definition at line 589 of file matrix.cpp.
References c, col, cols(), GiNaC::is_zero(), m, matrix(), row, and rows().
Referenced by charpoly(), contract_with(), GiNaC::ncmul::evalm(), pow(), and scalar_mul_indexed().
Product of matrix and scalar expression.
Definition at line 623 of file matrix.cpp.
References c, col, GiNaC::return_types::commutative, m, matrix(), r, GiNaC::ex::return_type(), and row.
Power of a matrix.
Currently handles integer exponents only.
Definition at line 639 of file matrix.cpp.
References GiNaC::_ex1, GiNaC::_num1_p, GiNaC::_num2_p, col, GiNaC::ex::info(), GiNaC::info_flags::integer, inverse(), GiNaC::numeric::is_odd(), GiNaC::numeric::is_zero(), mul(), GiNaC::info_flags::negative, r, and row.
const ex & GiNaC::matrix::operator() | ( | unsigned | ro, |
unsigned | co | ||
) | const |
operator() to access elements for reading.
ro | row of element |
co | column of element |
range_error | (index out of range) |
Definition at line 686 of file matrix.cpp.
ex & GiNaC::matrix::operator() | ( | unsigned | ro, |
unsigned | co | ||
) |
operator() to access elements for writing.
ro | row of element |
co | column of element |
range_error | (index out of range) |
Definition at line 700 of file matrix.cpp.
References col, GiNaC::basic::ensure_if_modifiable(), m, and row.
matrix GiNaC::matrix::transpose | ( | ) | const |
Transposed of an m x n matrix, producing a new n x m matrix object that represents the transposed.
Definition at line 712 of file matrix.cpp.
References c, cols(), m, matrix(), r, and rows().
Referenced by add_indexed(), and contract_with().
ex GiNaC::matrix::determinant | ( | unsigned | algo = determinant_algo::automatic | ) | const |
Determinant of square matrix.
This routine doesn't actually calculate the determinant, it only implements some heuristics about which algorithm to run. If all the elements of the matrix are elements of an integral domain the determinant is also in that integral domain and the result is expanded only. If one or more elements are from a quotient field the determinant is usually also in that quotient field and the result is normalized before it is returned. This implies that the determinant of the symbolic 2x2 matrix [[a/(a-b),1],[b/(a-b),1]] is returned as unity. (In this respect, it behaves like MapleV and unlike Mathematica.)
algo | allows to chose an algorithm |
logic_error | (matrix not square) |
Definition at line 737 of file matrix.cpp.
References GiNaC::_ex0, GiNaC::determinant_algo::automatic, GiNaC::determinant_algo::bareiss, c, col, GiNaC::info_flags::crational_polynomial, determinant_minor(), GiNaC::determinant_algo::divfree, division_free_elimination(), fraction_free_elimination(), GiNaC::determinant_algo::gauss, gauss_elimination(), GINAC_ASSERT, GiNaC::ex::info(), GiNaC::ex::is_zero(), GiNaC::is_zero(), GiNaC::determinant_algo::laplace, m, matrix(), GiNaC::ex::normal(), GiNaC::info_flags::numeric, GiNaC::permutation_sign(), r, GiNaC::info_flags::rational_function, and row.
Referenced by charpoly(), and GiNaC::tensepsilon::contract_with().
ex GiNaC::matrix::trace | ( | ) | const |
Trace of a matrix.
The result is normalized if it is in some quotient field and expanded only otherwise. This implies that the trace of the symbolic 2x2 matrix [[a/(a-b),x],[y,b/(b-a)]] is recognized to be unity.
logic_error | (matrix not square) |
Definition at line 866 of file matrix.cpp.
References col, GiNaC::info_flags::crational_polynomial, GiNaC::ex::expand(), GiNaC::ex::info(), m, GiNaC::ex::normal(), r, GiNaC::info_flags::rational_function, and row.
Referenced by charpoly(), and eval_indexed().
Characteristic Polynomial.
Following mathematica notation the characteristic polynomial of a matrix M is defined as the determinant of (M - lambda * 1) where 1 stands for the unit matrix of the same dimension as M. Note that some CASs define it with a sign inside the determinant which gives rise to an overall sign if the dimension is odd. This method returns the characteristic polynomial collected in powers of lambda as a new expression.
logic_error | (matrix not square) |
Definition at line 894 of file matrix.cpp.
References c, col, GiNaC::ex::collect(), determinant(), GiNaC::basic::ex, m, mul(), GiNaC::info_flags::numeric, poly, r, row, and trace().
matrix GiNaC::matrix::inverse | ( | ) | const |
Inverse of this matrix, with automatic algorithm selection.
Definition at line 939 of file matrix.cpp.
References GiNaC::solve_algo::automatic, and inverse().
matrix GiNaC::matrix::inverse | ( | unsigned | algo | ) | const |
Inverse of this matrix.
algo | selects the algorithm (one of solve_algo) |
logic_error | (matrix not square) |
runtime_error | (singular matrix) |
Definition at line 950 of file matrix.cpp.
matrix GiNaC::matrix::solve | ( | const matrix & | vars, |
const matrix & | rhs, | ||
unsigned | algo = solve_algo::automatic |
||
) | const |
Solve a linear system consisting of a m x n matrix and a m x p right hand side by applying an elimination scheme to the augmented matrix.
vars | n x p matrix, all elements must be symbols |
rhs | m x p matrix |
algo | selects the solving algorithm |
logic_error | (incompatible matrices) |
invalid_argument | (1st argument must be matrix of symbols) |
runtime_error | (inconsistent linear system) |
Definition at line 995 of file matrix.cpp.
References c, cols(), echelon_form(), GiNaC::basic::info(), m, n, GiNaC::basic::normal(), r, GiNaC::rhs(), rows(), and GiNaC::info_flags::symbol.
Referenced by inverse(), GiNaC::lsolve(), and GiNaC::sqrfree_parfrac().
unsigned GiNaC::matrix::rank | ( | ) | const |
Compute the rank of this matrix.
Definition at line 1058 of file matrix.cpp.
References GiNaC::solve_algo::automatic, and rank().
Referenced by rank().
unsigned GiNaC::matrix::rank | ( | unsigned | solve_algo | ) | const |
Compute the rank of this matrix using the given algorithm, which should be a member of enum solve_algo.
Definition at line 1065 of file matrix.cpp.
References col, echelon_form(), GINAC_ASSERT, m, r, and row.
bool GiNaC::matrix::is_zero_matrix | ( | ) | const |
Function to check that all elements of the matrix are zero.
Definition at line 1676 of file matrix.cpp.
References m.
|
protected |
Recursive determinant for small matrices having at least one symbolic entry.
The basic algorithm, known as Laplace-expansion, is enhanced by some bookkeeping to avoid calculation of the same submatrices ("minors") more than once. According to W.M.Gentleman and S.C.Johnson this algorithm is better than elimination schemes for matrices of sparse multivariate polynomials and also for matrices of dense univariate polynomials if the matrix' dimension is larger than 7.
Definition at line 1096 of file matrix.cpp.
References GiNaC::_ex0, GiNaC::_ex1, c, cols(), GiNaC::ex::expand(), GiNaC::ex::is_zero(), GiNaC::is_zero(), m, n, and r.
Referenced by determinant().
|
protected |
Definition at line 1197 of file matrix.cpp.
References GiNaC::solve_algo::automatic, GiNaC::solve_algo::bareiss, c, col, GiNaC::solve_algo::divfree, division_free_elimination(), fraction_free_elimination(), GiNaC::solve_algo::gauss, gauss_elimination(), m, GiNaC::solve_algo::markowitz, markowitz_elimination(), n, GiNaC::info_flags::numeric, r, and row.
|
protected |
Perform the steps of an ordinary Gaussian elimination to bring the m x n matrix into an upper echelon form.
The algorithm is ok for matrices with numeric coefficients but quite unsuited for symbolic matrices.
det | may be set to true to save a lot of space if one is only interested in the diagonal elements (i.e. for calculating determinants). The others are set to zero in this case. |
Definition at line 1269 of file matrix.cpp.
References GiNaC::_ex0, c, cols(), GiNaC::basic::ensure_if_modifiable(), GINAC_ASSERT, GiNaC::basic::info(), GiNaC::is_zero(), m, n, GiNaC::ex::normal(), GiNaC::info_flags::numeric, pivot(), r, and rows().
Referenced by determinant(), and echelon_form().
|
protected |
Perform the steps of division free elimination to bring the m x n matrix into an upper echelon form.
det | may be set to true to save a lot of space if one is only interested in the diagonal elements (i.e. for calculating determinants). The others are set to zero in this case. |
Definition at line 1441 of file matrix.cpp.
References GiNaC::_ex0, c, cols(), GiNaC::basic::ensure_if_modifiable(), GINAC_ASSERT, m, n, pivot(), r, and rows().
Referenced by determinant(), and echelon_form().
|
protected |
Perform the steps of Bareiss' one-step fraction free elimination to bring the matrix into an upper echelon form.
Fraction free elimination means that divide is used straightforwardly, without computing GCDs first. This is possible, since we know the divisor at each step.
det | may be set to true to save a lot of space if one is only interested in the last element (i.e. for calculating determinants). The others are set to zero in this case. |
Definition at line 1495 of file matrix.cpp.
References GiNaC::_ex0, GiNaC::_ex1, c, cols(), GiNaC::divide(), GiNaC::basic::ensure_if_modifiable(), GiNaC::basic::expand(), GINAC_ASSERT, GiNaC::is_zero(), m, n, GiNaC::subs_options::no_pattern, GiNaC::ex::normal(), GiNaC::ex::numer_denom(), GiNaC::ex::op(), r, rows(), subs(), and GiNaC::ex::to_rational().
Referenced by determinant(), and echelon_form().
|
protected |
Definition at line 1326 of file matrix.cpp.
References GiNaC::_ex0, c, col, GINAC_ASSERT, GiNaC::ex::is_zero(), GiNaC::is_zero(), k, m, n, GiNaC::basic::normal(), r, row, and std::swap().
Referenced by echelon_form().
|
protected |
Partial pivoting method for matrix elimination schemes.
Usual pivoting (symbolic==false) returns the index to the element with the largest absolute value in column ro and swaps the current row with the one where the element was found. With (symbolic==true) it does the same thing with the first non-zero element.
ro | is the row from where to begin |
co | is the column to be inspected |
symbolic | signal if we want the first non-zero element to be pivoted (true) or the one with the largest absolute value (false). |
Definition at line 1636 of file matrix.cpp.
References GiNaC::abs(), c, col, GiNaC::basic::ensure_if_modifiable(), GiNaC::basic::expand(), GINAC_ASSERT, GiNaC::numeric::is_zero(), GiNaC::is_zero(), k, m, row, and GiNaC::swap().
Referenced by division_free_elimination(), and gauss_elimination().
|
protected |
Definition at line 168 of file matrix.cpp.
References c, col, m, and row.
Referenced by do_print(), do_print_latex(), and do_print_python_repr().
|
protected |
Definition at line 184 of file matrix.cpp.
References c, and print_elements().
|
protected |
Definition at line 191 of file matrix.cpp.
References c, col, and print_elements().
|
protected |
Definition at line 198 of file matrix.cpp.
References c, and print_elements().
|
protected |
number of rows
Definition at line 115 of file matrix.h.
Referenced by add(), add_indexed(), archive(), charpoly(), conjugate(), contract_with(), determinant(), echelon_form(), eval_indexed(), imag_part(), inverse(), markowitz_elimination(), match_same_type(), matrix(), mul(), mul_scalar(), nops(), operator()(), pivot(), pow(), print_elements(), rank(), read_archive(), real_part(), rows(), sub(), subs(), and trace().
|
protected |
number of columns
Definition at line 116 of file matrix.h.
Referenced by add(), add_indexed(), archive(), charpoly(), cols(), conjugate(), contract_with(), determinant(), do_print_latex(), echelon_form(), eval_indexed(), imag_part(), inverse(), markowitz_elimination(), match_same_type(), matrix(), mul(), mul_scalar(), nops(), operator()(), pivot(), pow(), print_elements(), rank(), read_archive(), real_part(), sub(), subs(), and trace().
|
protected |
representation (cols indexed first)
Definition at line 117 of file matrix.h.
Referenced by add(), archive(), charpoly(), conjugate(), determinant(), determinant_minor(), division_free_elimination(), echelon_form(), fraction_free_elimination(), gauss_elimination(), imag_part(), is_zero_matrix(), let_op(), markowitz_elimination(), matrix(), mul(), mul_scalar(), op(), operator()(), pivot(), print_elements(), rank(), read_archive(), real_part(), solve(), sub(), subs(), trace(), and transpose().