MPSolve 3.2.1
Loading...
Searching...
No Matches
secular-equation.h File Reference

Header file for secular-related routines. More...

#include <mps/mps.h>
#include <float.h>

Go to the source code of this file.

Classes

struct  mps_secular_equation_double_buffer
 
struct  mps_secular_equation
 Secular equation data. More...
 
struct  mps_secular_iteration_data
 This is a struct that represent an iteration on a root. It contains information that could be useful for mps_secular_*iterate() routine to determine some error bound and provide a method for the routine to communicate if it was able to set the radius or not (by setting the radius_set in the right way). More...
 

Macros

#define MPS_SECULAR_EQUATION(t)   (MPS_POLYNOMIAL_CAST (mps_secular_equation, t))
 
#define MPS_IS_SECULAR_EQUATION(t)   (mps_polynomial_check_type (t, "mps_secular_equation"))
 
#define MPS_SECULAR_STARTING_MP_PRECISION   128
 This is the number of bits used when first passed in multiprecision.
 
#define MPS_SECULAR_EQUIVALENT_FP_PRECISION   (MPS_SECULAR_STARTING_MP_PRECISION / 2)
 This is the higher precision supported by GMP that is lower than the precision supported by the standard floating point machinery. It is used to set an "equivalent" precision in s->mpwp for the step of multiprecision coefficient regeneration.
 
#define mps_secular_equation_from_status(s)   (mps_secular_equation*)(s)->secular_equation
 

Functions

void mps_secular_fnewton (mps_context *st, mps_polynomial *p, mps_approximation *root, cplx_t corr)
 
void mps_secular_dnewton (mps_context *st, mps_polynomial *p, mps_approximation *root, cdpe_t corr)
 
void mps_secular_mnewton (mps_context *st, mps_polynomial *p, mps_approximation *root, mpc_t corr, long int wp)
 
mps_boolean mps_secular_ga_regenerate_coefficients (mps_context *s)
 Regenerate $a_i$ and $b_i$ setting $b_i = z_i$, i.e. the current root approximation and recomputing $a_i$ accordingly. More...
 
void mps_secular_deflate (mps_context *s, mps_secular_equation *sec)
 Deflate a secular equation lowering the degree of the polynomial that represent it, if that is possible. More...
 
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 sec->starting_case. More...
 
void mps_secular_restart (mps_context *s)
 
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. More...
 
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 the system) to wp. More...
 
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 coefficients via mps_secular_raise_coefficient_precision (), of the roots via mps_secular_raise_root_precision () and set s->mpwp. More...
 
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. More...
 
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). More...
 
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). More...
 
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). More...
 
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. More...
 
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. More...
 
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. More...
 
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 approximate. If the target was approximation then mps_secular_improve () should be used to reach the required precision. More...
 
void mps_secular_ga_update_coefficients (mps_context *s)
 Update all the coefficients of the secular equation, and their moduli, using the recomputed one stored in the multiprecision version. More...
 
mps_secular_equationmps_secular_equation_new (mps_context *s, cplx_t *afpc, cplx_t *bfpc, unsigned long int n)
 Create a new secular equation struct. More...
 
mps_secular_equationmps_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 the user to fill their values. More...
 
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. More...
 
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. More...
 
void mps_secular_equation_free (mps_context *ctx, mps_polynomial *p)
 Free a secular equation and the data in it. More...
 
void mps_secular_set_radii (mps_context *s)
 Update radii of the roots according to the coefficients of the secular equation in this moment, if they are better of the radii present now. More...
 
mps_boolean mps_secular_poly_feval_with_error (mps_context *ctx, mps_polynomial *p, cplx_t x, cplx_t value, double *error)
 
mps_boolean mps_secular_poly_deval_with_error (mps_context *ctx, mps_polynomial *p, cdpe_t x, cdpe_t value, rdpe_t error)
 
mps_boolean mps_secular_poly_meval_with_error (mps_context *ctx, mps_polynomial *p, mpc_t x, mpc_t value, rdpe_t error)
 
void mps_secular_poly_fstart (mps_context *ctx, mps_polynomial *p, mps_approximation **approximations)
 
void mps_secular_poly_dstart (mps_context *ctx, mps_polynomial *p, mps_approximation **approximations)
 
void mps_secular_poly_mstart (mps_context *ctx, mps_polynomial *p, mps_approximation **approximations)
 
mps_secular_equationmps_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. More...
 

Detailed Description

Header file for secular-related routines.

Function Documentation

◆ mps_secular_check_data()

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 sec->starting_case.

Parameters
sThe current mps_context.
which_casePointer to a char that will be set to 'f' or 'd' depending on the chosen start phase.

◆ mps_secular_deflate()

void mps_secular_deflate ( mps_context s,
mps_secular_equation sec 
)

Deflate a secular equation lowering the degree of the polynomial that represent it, if that is possible.

Please note the s->n and s->deg will not be touched by this routine, so you should check that they are set according to MPS_POLYNOMIAL (sec)->degree if deflation takes place.

See also
mps_context_set_degree ()
Parameters
sThe mps_context of the computation
secThe secular equation that will be deflated.

◆ mps_secular_dstart()

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).

Parameters
sThe current mps_context.
secThe secular equation for which the starting points shall be computed.

◆ mps_secular_equation_free()

void mps_secular_equation_free ( mps_context ctx,
mps_polynomial p 
)

Free a secular equation and the data in it.

Parameters
ctxThe current context.
pThe secular equation casted to a mps_polynomial

◆ mps_secular_equation_new()

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.

Parameters
sThe mps_context of the computation.
afpcThe floating point complex numerator coefficients.
bfpcThe floating point complex denominator coefficients.
nThe degree of the secular equation.

◆ mps_secular_equation_new_raw()

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 the user to fill their values.

Parameters
sThe mps_context of the computation.
nThe degree of the new secular equation to be created.

◆ mps_secular_equation_read_from_stream()

mps_secular_equation * mps_secular_equation_read_from_stream ( mps_context s,
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.

Parameters
sThe current mps_context
bufferThe buffer that needs to be parsed
Thestructure of the secular equation
Thedensity configuration of the secular equation
Theinput precision of the coefficients, if specified, 0 otherwise
Returns
A newly allocated mps_secular_equation, or NULL if the parsing fails.

◆ mps_secular_equation_set_coefficient_f()

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.

Parameters
ctxThe current context.
pThe secular equation whose coefficient should be set.
iThe index of the coefficient to set.
aThe numerator of the coefficient.
bThe zero of the denominator.

The new coefficient will have the form a / (x - b).

◆ mps_secular_equation_set_coefficient_q()

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.

Parameters
ctxThe current context.
pThe secular equation whose coefficient should be set.
iThe index of the coefficient to set.
aThe numerator of the coefficient.
bThe zero of the denominator.

The new coefficient will have the form a / (x - b).

◆ mps_secular_fstart()

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).

Parameters
sThe current mps_context.
secThe secular equation for which the starting points shall be computed.

◆ mps_secular_ga_check_stop()

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 approximate. If the target was approximation then mps_secular_improve () should be used to reach the required precision.

Parameters
sThe mps_context of the computation.

◆ mps_secular_ga_diterate()

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.

Parameters
sthe pointer to the mps_context struct.
maxitMaximum number of iteration to perform.
Returns
The number of approximated roots after the iteration.
Parameters
just_regeneratedtrue if this is the first iteration after a coefficient regeneration. If just_regenerated is true and the iteration packet is completed in less than 2 * (n - computed_roots) iterations that best_approx is set to true in s->secular_equation so a raise in the precision will be triggered.

◆ mps_secular_ga_fiterate()

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.

Parameters
sthe pointer to the mps_context struct.
maxitMaximum number of iteration to perform.
just_regeneratedtrue if this is the first iteration after a coefficient regeneration. If just_regenerated is true and the iteration packet is completed in less than 2 * (n - computed_roots) iterations that best_approx is set to true in s->secular_equation so a raise in the precision will be triggered.
Returns
The number of approximated roots after the iteration.

◆ mps_secular_ga_miterate()

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.

Parameters
sthe pointer to the mps_context struct.
maxitMaximum number of iteration to perform.
just_regeneratedtrue if this is the first iteration after a coefficient regeneration. If just_regenerated is true and the iteration packet is completed in less than 2 * (n - computed_roots) iterations that best_approx is set to true in s->secular_equation so a raise in the precision will be triggered.
Returns
The number of approximated roots after the iteration.

◆ mps_secular_ga_regenerate_coefficients()

mps_boolean mps_secular_ga_regenerate_coefficients ( mps_context s)

Regenerate $a_i$ and $b_i$ setting $b_i = z_i$, i.e. the current root approximation and recomputing $a_i$ accordingly.

Parameters
sThe mps_context of the computation.

◆ mps_secular_ga_update_coefficients()

void mps_secular_ga_update_coefficients ( mps_context s)

Update all the coefficients of the secular equation, and their moduli, using the recomputed one stored in the multiprecision version.

Parameters
sThe mps_context of the computation.

◆ mps_secular_mstart()

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).

Parameters
sThe current mps_context.
secThe secular equation for which the starting points shall be computed.

◆ mps_secular_raise_coefficient_precision()

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 the system) to wp.

Parameters
sThe mps_context of the computation.
pThe secular equation casted to a mps_polynomial.
wpThe bits of precision to which the coefficients will be set.
See also
mps_secular_raise_root_precision ()
mps_secular_raise_precision ()

◆ mps_secular_raise_precision()

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 coefficients via mps_secular_raise_coefficient_precision (), of the roots via mps_secular_raise_root_precision () and set s->mpwp.

Parameters
sThe mps_context of the computation.
wpThe bits of precision to which all the computation will be brought.

◆ mps_secular_raise_root_precision()

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.

Parameters
sThe mps_context of the computation.
wpThe bits of precision to which the roots will be set.
See also
mps_secular_raise_coefficient_precision ()
mps_secular_raise_precision ()

◆ mps_secular_set_radii()

void mps_secular_set_radii ( mps_context s)

Update radii of the roots according to the coefficients of the secular equation in this moment, if they are better of the radii present now.

Parameters
sThe mps_context of the computation.

◆ mps_secular_switch_phase()

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.

Note that for now this function is only able to handle switch from floating point phases (i.e. float_phase or dpe_phase) to multiprecision, and not coming back.

Parameters
sThe mps_context of the computation.
phaseThe phase to switch the computation to.