MPSolve 3.2.1
Loading...
Searching...
No Matches
secular-equation.h
Go to the documentation of this file.
1/*
2 * This file is part of MPSolve 3.2.1
3 *
4 * Copyright (C) 2001-2020, Dipartimento di Matematica "L. Tonelli", Pisa.
5 * License: http://www.gnu.org/licenses/gpl.html GPL version 3 or higher
6 *
7 * Authors:
8 * Leonardo Robol <leonardo.robol@unipi.it>
9 */
10
16#ifndef MPS_SECULAR_H_
17#define MPS_SECULAR_H_
18
19#include <mps/mps.h>
20#include <float.h>
21
22MPS_BEGIN_DECLS
23
24#define MPS_SECULAR_EQUATION(t) (MPS_POLYNOMIAL_CAST (mps_secular_equation, t))
25#define MPS_IS_SECULAR_EQUATION(t) (mps_polynomial_check_type (t, "mps_secular_equation"))
26
27#ifdef _MPS_PRIVATE
28
29/* CONSTANTS */
30
35#define MPS_SECULAR_STARTING_MP_PRECISION 128
36
43#define MPS_SECULAR_EQUIVALENT_FP_PRECISION (MPS_SECULAR_STARTING_MP_PRECISION / 2)
44
46 char active;
47 mpc_t *ampc1;
48 mpc_t *ampc2;
49 mpc_t *bmpc1;
50 mpc_t *bmpc2;
51};
52
64 struct mps_polynomial __base_class__;
65
67
72 cplx_t *afpc;
73
78 cdpe_t *adpc;
79
84 cplx_t *bfpc;
85
90 cdpe_t *bdpc;
91
96 mpc_t *ampc;
97
102 pthread_mutex_t * ampc_mutex;
103
108 mpc_t *bmpc;
109
114 pthread_mutex_t * bmpc_mutex;
115
120 double *aafpc;
121
126 double *abfpc;
127
132 rdpe_t *aadpc;
133
138 rdpe_t *abdpc;
139
145
151
157
163
169
175
179 pthread_mutex_t precision_mutex;
180}; /* End of struct mps_secular_equation {... */
181
194 long int k;
195
202 mps_boolean radius_set;
203
208 pthread_mutex_t * gs_mutex;
209
214 mpc_t * local_ampc;
215
220 mpc_t * local_bmpc;
221
226 cplx_t * local_afpc;
227
232 cplx_t * local_bfpc;
233
238 cdpe_t * local_adpc;
239
244 cdpe_t * local_bdpc;
245};
246
247#endif /* #ifdef _MPS_PRIVATE */
248
249
250/* MACROS */
251#define mps_secular_equation_from_status(s) (mps_secular_equation*)(s)->secular_equation
252
253/* Routines in secular-newton.c */
254void mps_secular_fnewton (mps_context * st, mps_polynomial * p, mps_approximation * root, cplx_t corr);
255void mps_secular_dnewton (mps_context * st, mps_polynomial * p, mps_approximation * root, cdpe_t corr);
256void mps_secular_mnewton (mps_context * st, mps_polynomial * p, mps_approximation * root, mpc_t corr, long int wp);
257
258/* Routines in secular-regeneartion.c */
260
261/* Routines in secular.c */
263
264void mps_secular_check_data (mps_context * s, char *which_case);
265
266void mps_secular_restart (mps_context * s);
267
268void mps_secular_switch_phase (mps_context * s, mps_phase phase);
269
271
273
275
276/* Routines in secular-starting.c */
277void mps_secular_fstart (mps_context * s, mps_secular_equation * sec, mps_approximation ** approximations);
278void mps_secular_dstart (mps_context * s, mps_secular_equation * sec, mps_approximation ** approximations);
279void mps_secular_mstart (mps_context * s, mps_secular_equation * sec, mps_approximation ** approximations);
280
281/* Routines in secular-iteration.c */
282int mps_secular_ga_fiterate (mps_context * s, int maxit, mps_boolean just_regenerated);
283
284int mps_secular_ga_diterate (mps_context * s, int maxit, mps_boolean just_regenerated);
285
286int mps_secular_ga_miterate (mps_context * s, int maxit, mps_boolean just_regenerated);
287
288/* Routines in secular-ga.c */
289mps_boolean mps_secular_ga_check_stop (mps_context * s);
290
292
293/* Interface functions in secular.c */
295 cplx_t * afpc,
296 cplx_t * bfpc,
297 unsigned long int n);
298
300 unsigned long int n);
301
302void mps_secular_equation_set_coefficient_f (mps_context *ctx, mps_secular_equation *p, int i, mpc_t a, mpc_t b);
303void mps_secular_equation_set_coefficient_q (mps_context *ctx, mps_secular_equation *p, int i, mpq_t ar, mpq_t ai, mpq_t br, mpq_t bi);
304
306
308
309mps_boolean mps_secular_poly_feval_with_error (mps_context * ctx, mps_polynomial * p, cplx_t x, cplx_t value, double * error);
310
311mps_boolean mps_secular_poly_deval_with_error (mps_context * ctx, mps_polynomial * p, cdpe_t x, cdpe_t value, rdpe_t error);
312
313mps_boolean mps_secular_poly_meval_with_error (mps_context * ctx, mps_polynomial * p, mpc_t x, mpc_t value, rdpe_t error);
314
315void mps_secular_poly_fstart (mps_context * ctx, mps_polynomial * p, mps_approximation ** approximations);
316
317void mps_secular_poly_dstart (mps_context * ctx, mps_polynomial * p, mps_approximation ** approximations);
318
319void mps_secular_poly_mstart (mps_context * ctx, mps_polynomial * p, mps_approximation ** approximations);
320
322 mps_structure structure, mps_density density,
323 long int precision);
324
325
326MPS_END_DECLS
327
328#endif /* SECULAR_H */
Header file for libmps.
mps_secular_equation * mps_secular_equation_new(mps_context *s, cplx_t *afpc, cplx_t *bfpc, unsigned long int n)
Create a new secular equation struct.
Definition: secular-equation.c:310
int mps_secular_ga_miterate(mps_context *s, int maxit, mps_boolean just_regenerated)
Routine that performs a block of iteration in floating point on the secular equation using CDPE.
Definition: secular-iteration.c:625
mps_secular_equation * mps_secular_equation_read_from_stream(mps_context *ctx, mps_input_buffer *buffer, mps_structure structure, mps_density density, long int precision)
Parse the stream that has been loaded into buffer and that describe a mps_secular_equation.
Definition: secular-parser.c:26
int mps_secular_ga_fiterate(mps_context *s, int maxit, mps_boolean just_regenerated)
Routine that performs a block of iteration in floating point on the secular equation.
Definition: secular-iteration.c:133
void mps_secular_equation_set_coefficient_q(mps_context *ctx, mps_secular_equation *p, int i, mpq_t ar, mpq_t ai, mpq_t br, mpq_t bi)
Sets a coefficient of a secular equation.
Definition: secular-equation.c:405
void mps_secular_switch_phase(mps_context *s, mps_phase phase)
Prepare data for the iteration in the new phase specified in the second parameter.
Definition: secular-equation.c:695
void mps_secular_equation_free(mps_context *ctx, mps_polynomial *p)
Free a secular equation and the data in it.
Definition: secular-equation.c:441
void mps_secular_fstart(mps_context *s, mps_secular_equation *sec, mps_approximation **approximations)
Compute some sensible starting points for the given secular equation (floating point version).
Definition: secular-starting.c:26
void mps_secular_check_data(mps_context *s, char *which_case)
Secular version of mps_check_data () that does nothing except to set the starting case according to s...
Definition: secular-equation.c:544
int mps_secular_ga_diterate(mps_context *s, int maxit, mps_boolean just_regenerated)
Routine that performs a block of iteration in floating point on the secular equation using CDPE.
Definition: secular-iteration.c:374
mps_boolean mps_secular_ga_regenerate_coefficients(mps_context *s)
Regenerate and setting , i.e. the current root approximation and recomputing accordingly.
Definition: secular-regeneration.c:637
void mps_secular_raise_root_precision(mps_context *s, int wp)
Raise precision of the roots (not the coefficients nor the system) to wp bits.
Definition: secular-equation.c:638
void mps_secular_ga_update_coefficients(mps_context *s)
Update all the coefficients of the secular equation, and their moduli, using the recomputed one store...
Definition: secular-ga.c:41
mps_secular_equation * mps_secular_equation_new_raw(mps_context *s, unsigned long int n)
Raw version of mps_secular_equation_new that only allocate space for the coefficients but relies on t...
Definition: secular-equation.c:210
void mps_secular_equation_set_coefficient_f(mps_context *ctx, mps_secular_equation *p, int i, mpc_t a, mpc_t b)
Sets a coefficient of a secular equation.
Definition: secular-equation.c:358
void mps_secular_mstart(mps_context *s, mps_secular_equation *sec, mps_approximation **approximations)
Compute some sensible starting points for the given secular equation (MP version).
Definition: secular-starting.c:93
mps_boolean mps_secular_ga_check_stop(mps_context *s)
Check if iterations can terminate, i.e. if newton isolation has been reached, if the target was appro...
Definition: secular-ga.c:72
void mps_secular_deflate(mps_context *s, mps_secular_equation *sec)
Deflate a secular equation lowering the degree of the polynomial that represent it,...
Definition: secular-equation.c:107
void mps_secular_set_radii(mps_context *s)
Update radii of the roots according to the coefficients of the secular equation in this moment,...
Definition: secular-equation.c:765
void mps_secular_raise_precision(mps_context *s, int wp)
Raise (or lower) the precision of the coefficients to wp bits. This will change precision of the coef...
Definition: secular-equation.c:661
void mps_secular_dstart(mps_context *s, mps_secular_equation *sec, mps_approximation **approximations)
Compute some sensible starting points for the given secular equation (DPE version).
Definition: secular-starting.c:56
long int mps_secular_raise_coefficient_precision(mps_context *s, mps_polynomial *p, long int wp)
Raise precision of the coefficient of the secular equation (not the roots and neither the precison of...
Definition: secular-equation.c:564
Definition: approximation.h:24
this struct holds the state of the mps computation
Definition: context.h:55
Buffer used to parse input files in MPSolve. It can read a stream line by line.
Definition: input-buffer.h:33
Struct that represents an abstract polynomial. All the other real polynomial implementations (such as...
Definition: polynomial.h:111
Definition: secular-equation.h:45
Secular equation data.
Definition: secular-equation.h:63
pthread_mutex_t * ampc_mutex
Mutexes thatn need to be locked to ensure consistent access to ampc[j] variable.
Definition: secular-equation.h:102
mpq_t * initial_bmpqrc
Initial rational coefficients, if rational input is selected. This value is the real part of the coe...
Definition: secular-equation.h:162
mpc_t * bmpc
Same as bfpc, but the multiprecision version.
Definition: secular-equation.h:108
mpc_t * ampc
Same as afpc, but the multiprecision version.
Definition: secular-equation.h:96
mpc_t * initial_ampc
Initial multiprecision coefficients saved for latter regeneration in mps_secular_ga_regenerate_coeffi...
Definition: secular-equation.h:144
rdpe_t * aadpc
DPE Moduli of the CDPE of Multiprecision a_i coefficients of the secular equation.
Definition: secular-equation.h:132
cdpe_t * bdpc
Same as bfpc, but the dpe version.
Definition: secular-equation.h:90
pthread_mutex_t * bmpc_mutex
Mutexes that need to be locked to ensure consistent access to bmpc[j] variable.
Definition: secular-equation.h:114
rdpe_t * abdpc
DPE Moduli of the CDPE of Multiprecision b_i coefficients of the secular equation.
Definition: secular-equation.h:138
cplx_t * bfpc
Vector with the values of as complex floating point numbers.
Definition: secular-equation.h:84
cplx_t * afpc
Vector of as complex floating point numbers.
Definition: secular-equation.h:72
mpq_t * initial_bmpqic
Initial rational coefficients, if rational input is selected. This value is the imaginary part of the...
Definition: secular-equation.h:174
pthread_mutex_t precision_mutex
This mutex is locked while changing precision.
Definition: secular-equation.h:179
double * abfpc
Moduli of the floating point b_i coefficients of the secular equation.
Definition: secular-equation.h:126
mpc_t * initial_bmpc
Initial multiprecision coefficients saved for latter regeneration in mps_secular_ga_regenerate_coeffi...
Definition: secular-equation.h:150
mpq_t * initial_ampqrc
Initial rational coefficients, if rational input is selected. This value is the real part of the coe...
Definition: secular-equation.h:156
mpq_t * initial_ampqic
Initial rational coefficients, if rational input is selected. This value is the imaginary part of the...
Definition: secular-equation.h:168
cdpe_t * adpc
Same as afpc, but the dpe version.
Definition: secular-equation.h:78
double * aafpc
Moduli of the floating point a_i coefficients of the secular equation.
Definition: secular-equation.h:120
This is a struct that represent an iteration on a root. It contains information that could be useful ...
Definition: secular-equation.h:189
cdpe_t * local_bdpc
Thread local copy of the CDPE coefficients of the secular equation.
Definition: secular-equation.h:244
cplx_t * local_bfpc
Thread local copy of the floating point coefficients of the secular equation.
Definition: secular-equation.h:232
long int k
The index of the roots on which the iterations is being carried out.
Definition: secular-equation.h:194
pthread_mutex_t * gs_mutex
Global mutex used to synchronization, but mainly while testing new MP implementations.
Definition: secular-equation.h:208
mpc_t * local_bmpc
Thread local copy of the coefficients of the secular equation.
Definition: secular-equation.h:220
mps_boolean radius_set
The state of the iteration. This is a pointer to a boolean that tells if the iterator has been able t...
Definition: secular-equation.h:202
cdpe_t * local_adpc
Thread local copy of the CDPE coefficients of the secular equation.
Definition: secular-equation.h:238
mpc_t * local_ampc
Thread local copy of the coefficients of the secular equation.
Definition: secular-equation.h:214
cplx_t * local_afpc
Thread local copy of the floating point coefficients of the secular equation.
Definition: secular-equation.h:226