realroot_doc 0.1.1
|
The default names for the variables are x0
, x1
, x2
, ... But one can use specific variable environments, in order to precise which variables to consider. The class variables implements such dictionary between the internal variables xi
and the one we want. It can be used either when constructing a polynomial or when printing it. For instance,
variables V("u v"); polynom_t p("x0^2+x0*x1-x1+2*x1-1", V);
defines a dictionnary V
where the variable x0
is u
, x1
is v
so that the polynomial which
is constructed from the string "u^2+..."
is in fact:
x0^2+x0*x1+2*x0-x1-1
The name of the variables can be recovered from their indices V
[0], V[1]. If new variable names are used when constructing a polynomial, they are added to the dictionnary V
, in the order they are parsed:
polynom_t q("u^3-w+t", V);
Now V
[2] is w
, and V
[3] the variable t
. Notice, that here if we use an index i<= 4, we get for V
[i], the variable xi
. In order to print the polynomial, with the appropriate variable names, instead of the operator <<
, one can use the following functions:
variables W("a b c d"); print(std::cout,p,W); std::cout<< std::endl;
In this example, it yields:
a^2+a*b+2*a-b-1