fmpq_poly.h File Reference

Fast implementation of the rational polynomial ring. More...

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

Go to the source code of this file.

Data Structures

struct  fmpq_poly_struct
 Data type for a rational polynomial. More...

Defines

#define fmpq_poly_numref(op)   ((op)->num)
 Returns a reference to the numerator of op.
#define fmpq_poly_denref(op)   ((op)->den)
 Returns a reference to the denominator of op.

Typedefs

typedef fmpq_poly_struct fmpq_poly_t [1]
 Array of fmpq_poly_struct of length one.
typedef fmpq_poly_structfmpq_poly_ptr
 Pointer to fmpq_poly_struct.

Functions

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.
static void fmpq_poly_init (fmpq_poly_ptr rop)
static void fmpq_poly_clear (fmpq_poly_ptr rop)
static void fmpq_poly_set (fmpq_poly_ptr rop, const fmpq_poly_ptr op)
static void fmpq_poly_set_si (fmpq_poly_ptr rop, long op)
static void fmpq_poly_set_fmpz (fmpq_poly_ptr rop, const fmpz_t x)
static void fmpq_poly_set_mpz (fmpq_poly_ptr rop, const mpz_t x)
static void fmpq_poly_set_mpq (fmpq_poly_ptr rop, const mpq_t x)
static void fmpq_poly_swap (fmpq_poly_ptr op1, fmpq_poly_ptr op2)
static void fmpq_poly_zero (fmpq_poly_ptr rop)
static void fmpq_poly_one (fmpq_poly_ptr rop)
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)
static int fmpq_poly_is_zero (const fmpq_poly_ptr op)
 Returns whether op is zero.Returns whether the element op is zero.
static int fmpq_poly_is_one (const fmpq_poly_ptr op)
 Returns whether op is equal to $1$.Returns whether the element op is equal to the constant polynomial $1$.
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 ulong fmpq_poly_length (const fmpq_poly_ptr op)
 Returns the length of op.
static long fmpq_poly_degree (const fmpq_poly_ptr op)
 Returns the degree of op.
void fmpq_poly_add (fmpq_poly_ptr rop, const fmpq_poly_ptr op1, const fmpq_poly_ptr op2)
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)
void fmpq_poly_scalar_div_si (fmpq_poly_ptr rop, const fmpq_poly_ptr op, long 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)
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)
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 *s)
char * fmpq_poly_to_string (const fmpq_poly_ptr op)
char * fmpq_poly_to_string_pretty (const fmpq_poly_ptr op, const char *x)
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 polynomial ring.

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

Function Documentation

static long fmpq_poly_degree ( const fmpq_poly_ptr  op  )  [inline, static]

Returns the degree of op.

Returns the degree of the polynomial op.

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.

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