Functions | |
void | fmpq_poly_from_list (fmpq_poly_ptr rop, mpq_t *a, ulong n) |
Constructs a polynomial from a list of rationals. | |
int | fmpq_poly_from_string (fmpq_poly_ptr rop, const char *str) |
char * | fmpq_poly_to_string (const fmpq_poly_ptr op) |
char * | fmpq_poly_to_string_pretty (const fmpq_poly_ptr op, const char *var) |
The following three methods enable users to construct elements of type fmpq_poly_ptr
from strings or to obtain string representations of such elements.
The format used is based on the FLINT format for integer polynomials of type fmpz_poly_t
, which we recall first:
A non-zero polynomial of length is represented by the string n+1 a_0 a_1 ... a_n
, where there are two space characters following the length and single space characters separating the individual coefficients. There is no leading or trailing white-space. In contrast, the zero polynomial is represented by 0
.
We adapt this notation for rational polynomials by using the mpq_t
notation for the coefficients without any additional white-space.
There is also a _pretty
variant available.
Note that currently these functions are not optimized for performance and are intended to be used only for debugging purposes or one-off input and output, rather than as a low-level parser.
void fmpq_poly_from_list | ( | fmpq_poly_ptr | rop, | |
mpq_t * | a, | |||
ulong | n | |||
) |
Constructs a polynomial from a list of rationals.
Given a list of length n
containing rationals of type mpq_t
, this method constructs a polynomial with these coefficients, beginning with the constant term.
int fmpq_poly_from_string | ( | fmpq_poly_ptr | rop, | |
const char * | str | |||
) |
Sets the rational polynomial rop
to the value specified by the null-terminated string str
.
The behaviour is undefined if the format of the string str
does not conform to the specification.
0
or 1
depending on whether the input format was correct. Currently, the method always returns 1
. char* fmpq_poly_to_string | ( | const fmpq_poly_ptr | op | ) |
Returns the string representation of the rational polynomial op
.
char* fmpq_poly_to_string_pretty | ( | const fmpq_poly_ptr | op, | |
const char * | var | |||
) |
Returns the pretty string representation of op
.
Returns the pretty string representation of the rational polynomial op
, using the string var
as the variable name.