fmpq_poly.c File Reference

Fast implementation of the rational function field. More...

#include "fmpq_poly.h"
#include <stdio.h>
#include <gmp.h>
#include "fmpz.h"
#include "fmpz_poly.h"

Defines

#define FMPQ_POLY_INV_NEWTON_CUTOFF   32

Functions

unsigned int fmpq_poly_places (ulong n)
void fmpq_poly_canonicalize (fmpq_poly_ptr f, fmpz_t temp)
 Puts f into canonical form.This method ensures that the denominator is coprime to the content of the numerator polynomial, and that the denominator is positive.
void fmpq_poly_neg (fmpq_poly_ptr rop, const fmpq_poly_ptr op)
void fmpq_poly_inv (fmpq_poly_ptr rop, const fmpq_poly_ptr op)
void fmpq_poly_get_coeff_mpq (mpq_t rop, const fmpq_poly_ptr op, ulong i)
void fmpq_poly_set_coeff_fmpz (fmpq_poly_ptr rop, ulong i, const fmpz_t x)
void fmpq_poly_set_coeff_mpz (fmpq_poly_ptr rop, ulong i, const mpz_t x)
void fmpq_poly_set_coeff_mpq (fmpq_poly_ptr rop, ulong i, const mpq_t x)
void fmpq_poly_set_coeff_si (fmpq_poly_ptr rop, ulong i, long x)
int fmpq_poly_equal (const fmpq_poly_ptr op1, const fmpq_poly_ptr op2)
 Returns whether op1 and op2 are equal.Returns whether the two elements op1 and op2 are equal.
int fmpq_poly_cmp (const fmpq_poly_ptr left, const fmpq_poly_ptr right)
 Compares the two polynomials left and right.Compares the two polnomials left and right, returning -1, 0, or 1 as left is less than, equal to, or greater than right.
static void _fmpq_poly_add_in_place (fmpq_poly_ptr rop, const fmpq_poly_ptr op)
void fmpq_poly_add (fmpq_poly_ptr rop, const fmpq_poly_ptr op1, const fmpq_poly_ptr op2)
static void _fmpq_poly_sub_in_place (fmpq_poly_ptr rop, const fmpq_poly_ptr op)
void fmpq_poly_sub (fmpq_poly_ptr rop, const fmpq_poly_ptr op1, const fmpq_poly_ptr op2)
void fmpq_poly_addmul (fmpq_poly_ptr rop, const fmpq_poly_ptr op1, const fmpq_poly_ptr op2)
void fmpq_poly_submul (fmpq_poly_ptr rop, const fmpq_poly_ptr op1, const fmpq_poly_ptr op2)
void fmpq_poly_scalar_mul_si (fmpq_poly_ptr rop, const fmpq_poly_ptr op, long x)
void fmpq_poly_scalar_mul_mpz (fmpq_poly_ptr rop, const fmpq_poly_ptr op, const mpz_t x)
void fmpq_poly_scalar_mul_mpq (fmpq_poly_ptr rop, const fmpq_poly_ptr op, const mpq_t x)
static void _fmpq_poly_scalar_div_si_in_place (fmpq_poly_ptr rop, long x)
void fmpq_poly_scalar_div_si (fmpq_poly_ptr rop, const fmpq_poly_ptr op, long x)
static void _fmpq_poly_scalar_div_mpz_in_place (fmpq_poly_ptr rop, const mpz_t x)
void fmpq_poly_scalar_div_mpz (fmpq_poly_ptr rop, const fmpq_poly_ptr op, const mpz_t x)
void fmpq_poly_scalar_div_mpq (fmpq_poly_ptr rop, const fmpq_poly_ptr op, const mpq_t x)
static void _fmpq_poly_mul_in_place (fmpq_poly_ptr rop, const fmpq_poly_ptr op)
void fmpq_poly_mul (fmpq_poly_ptr rop, const fmpq_poly_ptr op1, const fmpq_poly_ptr op2)
void fmpq_poly_floordiv (fmpq_poly_ptr q, const fmpq_poly_ptr a, const fmpq_poly_ptr b)
void fmpq_poly_mod (fmpq_poly_ptr r, const fmpq_poly_ptr a, const fmpq_poly_ptr b)
void fmpq_poly_divrem (fmpq_poly_ptr q, fmpq_poly_ptr r, const fmpq_poly_ptr a, const fmpq_poly_ptr b)
void fmpq_poly_inv_series (fmpq_poly_ptr rop, const fmpq_poly_ptr op, long n)
void fmpq_poly_div_series (fmpq_poly_ptr rop, const fmpq_poly_ptr op1, const fmpq_poly_ptr op2, long n)
void fmpq_poly_power (fmpq_poly_ptr rop, const fmpq_poly_ptr op, ulong exp)
void fmpq_poly_gcd (fmpq_poly_ptr rop, const fmpq_poly_ptr a, const fmpq_poly_ptr b)
void fmpq_poly_xgcd (fmpq_poly_ptr rop, fmpq_poly_ptr s, fmpq_poly_ptr t, const fmpq_poly_ptr a, const fmpq_poly_ptr b)
void fmpq_poly_lcm (fmpq_poly_ptr rop, const fmpq_poly_ptr a, const fmpq_poly_ptr b)
void fmpq_poly_derivative (fmpq_poly_ptr rop, fmpq_poly_ptr op)
static void _fmpz_poly_evaluate_mpq_horner (mpq_t rop, const fmpz_poly_t f, const mpq_t a)
void fmpq_poly_evaluate_mpz (mpq_t rop, fmpq_poly_ptr f, const mpz_t a)
void fmpq_poly_evaluate_mpq (mpq_t rop, fmpq_poly_ptr f, const mpq_t a)
void fmpq_poly_content (mpq_t rop, const fmpq_poly_ptr op)
void fmpq_poly_primitive_part (fmpq_poly_ptr rop, const fmpq_poly_ptr op)
int fmpq_poly_is_monic (const fmpq_poly_ptr op)
 Returns whether op is monic.Returns whether op is monic.
void fmpq_poly_monic (fmpq_poly_ptr rop, const fmpq_poly_ptr op)
void fmpq_poly_resultant (mpq_t rop, const fmpq_poly_ptr a, const fmpq_poly_ptr b)
 Returns the resultant of a and b.Returns the resultant of a and b.
void fmpq_poly_discriminant (mpq_t disc, fmpq_poly_t a)
 Computes the discriminant of a.Computes the discriminant of the polynomial $a$.
void fmpq_poly_compose (fmpq_poly_ptr rop, const fmpq_poly_ptr a, const fmpq_poly_ptr b)
 Returns the composition of a and b.Returns the composition of a and b.
void fmpq_poly_rescale (fmpq_poly_ptr rop, const fmpq_poly_ptr op, const mpq_t x)
 Rescales the co-ordinate.Denoting this polynomial $a(T)$, computes the polynomial $a(x T)$.
int fmpq_poly_is_squarefree (const fmpq_poly_ptr op)
 Returns whether op is squarefree.Returns whether op is squarefree.
void fmpq_poly_getslice (fmpq_poly_ptr rop, const fmpq_poly_ptr op, ulong i, ulong j)
 Returns a contiguous subpolynomial.Returns the slice with coefficients from $x^i$ (including) to $x^j$ (excluding).
void fmpq_poly_left_shift (fmpq_poly_ptr rop, const fmpq_poly_ptr op, ulong n)
 Shifts this polynomial to the left by $n$ coefficients.Notionally multiplies op by $t^n$ and stores the result in rop.
void fmpq_poly_right_shift (fmpq_poly_ptr rop, const fmpq_poly_ptr op, ulong n)
 Shifts this polynomial to the right by $n$ coefficients.Notationally returns the quotient of floor division of rop by op.
void fmpq_poly_truncate (fmpq_poly_ptr rop, const fmpq_poly_ptr op, ulong n)
 Truncates this polynomials.Truncates op modulo $x^n$ whenever $n$ is positive. Returns zero otherwise.
void fmpq_poly_reverse (fmpq_poly_ptr rop, const fmpq_poly_ptr op, ulong n)
 Reverses this polynomial.Reverses the coefficients of op - thought of as a polynomial of length n - and places the result in rop.
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)
void fmpq_poly_print (const fmpq_poly_ptr op)
void fmpq_poly_print_pretty (const fmpq_poly_ptr op, const char *x)

Detailed Description

Fast implementation of the rational function field.

Author:
Sebastian Pancratz
Date:
Mar 2010 -- July 2010
Version:
0.1.8

Define Documentation

#define FMPQ_POLY_INV_NEWTON_CUTOFF   32

Threshold value for power series inversion using Newton's method.


Function Documentation

static void _fmpq_poly_scalar_div_si_in_place ( fmpq_poly_ptr  rop,
long  x 
) [static]

/ingroup ScalarMul

Divides rop by the integer x.

Assumes that x is non-zero. Otherwise, an exception is raised in the form of an abort statement.

void fmpq_poly_discriminant ( mpq_t  disc,
fmpq_poly_t  a 
)

Computes the discriminant of a.Computes the discriminant of the polynomial $a$.

The discriminant $R_n$ is defined as

\[ R_n = a_n^{2 n-2} \prod_{1 \le i < j \le n} (r_i - r_j)^2, \]

where $n$ is the degree of this polynomial, $a_n$ is the leading coefficient and $r_1, \ldots, r_n$ are the roots over $\bar{\mathbf{Q}}$ are.

The discriminant of constant polynomials is defined to be $0$.

This implementation uses the identity

\[ R_n(f) := (-1)^(n (n-1)/2) R(f,f') / a_n, \]

where $n$ is the degree of this polynomial, $a_n$ is the leading coefficient and $f'$ is the derivative of $f$.

See also:
fmpq_poly_resultant()
void fmpq_poly_monic ( fmpq_poly_ptr  rop,
const fmpq_poly_ptr  op 
)

Sets rop to the unique monic scalar multiple of op.

As the only special case, if op is the zero polynomial, rop is set to zero, too.

unsigned int fmpq_poly_places ( ulong  n  ) 

Returns the number of digits in the decimal representation of n.

void fmpq_poly_print ( const fmpq_poly_ptr  op  ) 
void fmpq_poly_print_pretty ( const fmpq_poly_ptr  op,
const char *  x 
)
Generated on Wed Dec 8 21:13:35 2010 for FMPQ_POLY by  doxygen 1.6.3