# Function `lsolve()'

Richard B. Kreckel kreckel at thep.physik.uni-mainz.de
Wed Sep 18 19:12:02 CEST 2002

```Hi there,

On Wed, 18 Sep 2002, Tatiana Zolo wrote:
> we need to use the function `lsolve()' that appears on page 5 of the
> tutorial for GiNaC 1.0.10, but not in the Concept Index. We couldn't
> find it elsewhere, not even in the specifications for the class matrix.
> We would like to know its specifications, if possible. In particular, we
> have linear systems whose associated matrix may have some linear
> dependencies.

That is indeed not very well documented, sorry.  `lsolve()' is declared
and implemented in inifcns.h and inifcns.cpp, respectively.  It basically
calls `matrix::solve()' where an appropiate elimination method is chosen
heuristically.  It also works on underdetermined linear systems, since the
elimination tries to find an echelon form as opposed to a pure trinagular
form.  The solutions will then contain trivial entries like x==x (where
`x' is a symbol).  For that reason, a vector (or even matrix) of
undeterminates needs to be passed to `matrix::solve()'.

You may either directly use `lsolve()' or `matrix::solve()'.  The best way
to find out how they are used is by looking into the check/ subdirectory
and study the files {exam|check}_{matrices|lsolve}.cpp.

A formal specification is not given anywhere since there really isn't
anyhting open for discussion -- solving linear systems not trivial but
totally unambiguous.  Either a solution exists and it is returned or the
system is overdetermined and an exception is thrown by `matrix::solve()'
in which case the list of solutions of `lsolve()' is empty.  The only
problematic thing may be the heuristic choice of elimination algorithm
when the dimension of the system becomes larger than three, say.  For that
reason you may force it to use some algorithm of your choice.  They may
differ greatly in asymptotic runtime.  Please refer to ginac/flags.h for
an enumeration of such algorithms.

Regards
-richy.
--
Richard B. Kreckel
<Richard.Kreckel at GiNaC.DE>
<http://www.ginac.de/~kreckel/>

```