Merge branch 'gmp_integration' of necada:~/repo/qpms into gmp_integration

Former-commit-id: 7d6118efbb06d1cee0eb3e89afc4aeb65665d023
This commit is contained in:
Marek Nečada 2019-10-25 20:43:46 +03:00
commit 5f77fd9386
2 changed files with 42 additions and 0 deletions

View File

@ -325,3 +325,30 @@ void qpq_deriv(qpq_t *dp, const qpq_t *p) {
dp->order = p->order - 1;
dp->offset = p->offset - 1 + !p->offset;
}
void qpq_legendroid_init(qpq_legendroid_t *p) {
qpq_init(&p->p);
p->f = 0;
}
void qpq_legendroid_clear(qpq_legendroid_t *p) {
qpq_clear(&p->p);
p->f = 0;
}
void qpq_legendroid_mul(qpq_legendroid_t *p, const qpq_legendroid_t *a, const qpq_legendroid_t *b) {
qpq_mul(&p->p, &a->p, &b->p);
if (a->f && b->f) {
// TODO make somehow a static representation of this constant polynomial
qpq_t ff;
qpq_init(&ff);
qpq_extend(&ff, 3);
qpq_set_elem_si(&ff, 0, -1, 1);
qpq_set_elem_si(&ff, 2, 1, 1);
qpq_mul(p, &ff);
qpq_clear(&ff);
}
p->f = !(a->f) != !(b->f);
}

View File

@ -71,6 +71,21 @@ void qpq_deriv(qpq_t *dPdx, const qpq_t *P);
/// Tests whether a polynomial is non-zero.
_Bool qpq_nonzero(const qpq_t *);
/// A type representing a polynomial with rational coefficients times an optional factor \f$ \sqrt{1-x^2} \f$.
typedef struct qpq_legendroid_t {
qpq_t p;
_Bool f;
} qpq_legendroid_t;
void qpq_legendroid_init(qpq_legendroid_t *p);
void qpq_legendroid_clear(qpq_legendroid_t *p);
/// Polynomial multiplication.
void qpq_legendroid_mul(qpq_legendroid_t *product, const qpq_legendroid_t *multiplier, const qpq_legendroid_t *multiplicand);
/// Polynomial derivative.
void qpq_legendroid_deriv(qpq_legendroid_t *dP_dx, const qpq_legendroid_t *P);
/// Polynomial with double coeffs.
typedef struct qpz_t {