1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
|
/*
* This file is part of MPSolve 3.2.2
*
* Copyright (C) 2001-2020, Dipartimento di Matematica "L. Tonelli", Pisa.
* License: http://www.gnu.org/licenses/gpl.html GPL version 3 or higher
*
* Authors:
* Leonardo Robol <leonardo.robol@unipi.it>
*/
#ifndef MPS_MONOMIAL_POLY_H_
#define MPS_MONOMIAL_POLY_H_
/**
* @file
* @brief Implementation of the allocation and edit functions for the
* handling of monomial polynomials.
*/
#include <mps/polynomial.h>
#include <mps/mps.h>
#include <gmp.h>
#include <pthread.h>
#define MPS_MONOMIAL_POLY(t) (MPS_POLYNOMIAL_CAST (mps_monomial_poly, t))
#define MPS_IS_MONOMIAL_POLY(t) (mps_polynomial_check_type (t, "mps_monomial_poly"))
MPS_BEGIN_DECLS
#ifdef _MPS_PRIVATE
struct mps_monomial_poly_double_buffer {
char active;
mpc_t *mfpc1;
mpc_t *mfpc2;
};
/**
* @brief Data regarding a polynomial represented in the monomial
* base.
*/
struct mps_monomial_poly {
/**
* @brief Implementation of the methods.
*/
struct mps_polynomial methods;
struct mps_monomial_poly_double_buffer db;
/**
* @brief This array contains the structure of the sparse
* polynomial.
*
* <code>spar[i]</code> is <code>true</code> if and only if
* the i-th coefficients of the polynomial is a non-zero
* coefficients
*/
mps_boolean *spar;
/**
* @brief Standard real coefficients.
*/
double *fpr;
/**
* @brief Standard complex coefficients.
*/
cplx_t *fpc;
/**
* @brief Array containing standard complex coefficients
*/
cplx_t *fppc;
/**
* @brief Dpe real coefficients.
*/
rdpe_t *dpr;
/**
* @brief Dpe complex coefficients.
*/
cdpe_t *dpc;
/**
* @brief Multiprecision real coefficients.
*/
mpf_t *mfpr;
/**
* @brief Multiprecision complex coefficients.
*/
mpc_t *mfpc;
/**
* @brief Array of mutexes that need to be locked when reading at the
* i-th compoenent of the poly.
*/
pthread_mutex_t * mfpc_mutex;
/**
* @brief Multiprecision complex coefficients of \f$p'(x)\f$.
*/
mpc_t *mfppc;
/**
* @brief Array containing moduli of the coefficients as double numbers.
*/
double *fap;
/**
* @brief Array containing moduli of the coefficients as dpe numbers.
*/
rdpe_t *dap;
/**
* @brief Real part of rational input coefficients.
*/
mpq_t *initial_mqp_r;
/**
* @brief Imaginary part of rational input coefficients.
*/
mpq_t *initial_mqp_i;
/**
* @brief This mutex must be locked while regenerating the coefficients
* of the polynomial.
*/
pthread_mutex_t regenerating;
/**
* @brief Precision of the polynomial coefficients.
*/
long int prec;
};
#endif /* #ifdef _MPS_PRIVATE */
/* These routines are thought for polynomial handling, i.e. allocating and
* setting coefficients of the polynomials, and setting the precision of the
* floating point coefficients that are in there */
mps_monomial_poly * mps_monomial_poly_new (mps_context * s, long int degree);
void mps_monomial_poly_free (mps_context * s, mps_polynomial * mp);
long int mps_monomial_poly_get_precision (mps_context * s, mps_monomial_poly * mp);
long int mps_monomial_poly_raise_precision (mps_context * s, mps_polynomial * mp, long int prec);
void mps_monomial_poly_set_coefficient_q (mps_context * s, mps_monomial_poly * mp, long int i,
mpq_t real_part, mpq_t imag_part);
void mps_monomial_poly_set_coefficient_d (mps_context * s, mps_monomial_poly * mp, long int i,
double real_part, double imag_part);
void mps_monomial_poly_set_coefficient_f (mps_context * s, mps_monomial_poly * p, long int i,
mpc_t coeff);
void mps_monomial_poly_set_coefficient_int (mps_context * s, mps_monomial_poly * mp, long int i,
long long real_part, long long imag_part);
void mps_monomial_poly_set_coefficient_s (mps_context * s, mps_monomial_poly * p,
int i, const char * real_coeff,
const char * imag_coeff);
void mps_monomial_poly_get_coefficient_d (mps_context * s, mps_monomial_poly * p,
int i, cplx_t output);
void mps_monomial_poly_get_coefficient_q (mps_context * s, mps_monomial_poly * p,
int i, mpq_t real_output, mpq_t imag_output);
mps_monomial_poly * mps_monomial_poly_derive (mps_context * s, mps_monomial_poly * p, int k, long int wp);
mps_boolean mps_monomial_poly_feval (mps_context * ctx, mps_polynomial *p, cplx_t x, cplx_t value, double * error);
mps_boolean mps_monomial_poly_deval (mps_context * ctx, mps_polynomial *p, cdpe_t x, cdpe_t value, rdpe_t error);
mps_boolean mps_monomial_poly_meval (mps_context * ctx, mps_polynomial *p, mpc_t x, mpc_t value, rdpe_t error);
void mps_monomial_poly_fstart (mps_context * ctx, mps_polynomial * p, mps_approximation ** approximations);
void mps_monomial_poly_dstart (mps_context * ctx, mps_polynomial * p, mps_approximation ** approximations);
void mps_monomial_poly_mstart (mps_context * ctx, mps_polynomial * p, mps_approximation ** approximations);
void mps_monomial_poly_fnewton (mps_context * ctx, mps_polynomial * p,
mps_approximation * root, cplx_t corr);
void mps_monomial_poly_dnewton (mps_context * ctx, mps_polynomial * p,
mps_approximation * root, cdpe_t corr);
void mps_monomial_poly_mnewton (mps_context * ctx, mps_polynomial * p,
mps_approximation * root, mpc_t corr, long int wp);
void mps_monomial_poly_get_leading_coefficient (mps_context * ctx, mps_polynomial * p,
mpc_t leading_coefficient);
void mps_monomial_poly_deflate (mps_context * ctx, mps_polynomial * p);
mps_monomial_poly * mps_monomial_poly_read_from_stream (mps_context * s, mps_input_buffer * buffer,
mps_structure structure, mps_density density,
long int precision);
MPS_END_DECLS
#endif
|