// -*- mode:C++ ; compile-command: "g++ -I.. -g -c solve.cc" -*-
/*
* Copyright (C) 2000,2014 B. Parisse, Institut Fourier, 38402 St Martin d'Heres
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#ifndef _GIAC_SOLVE_H
#define _GIAC_SOLVE_H
#include "first.h"
// GIAC_64VARS is currently compatible with GROEBNER_VARS 15 only
#define GIAC_64VARS
// comment if you don't want the modular algorithm for gbasis with >15 var
//#define GIAC_CHARDEGTYPE
// uncomment if you want degrees as unsigned char (8 bits instead of 15)
#ifndef NO_NAMESPACE_GIAC
namespace giac {
#endif // ndef NO_NAMESPACE_GIAC
vecteur lvarfracpow(const gen & e);
std::string print_intvar_counter(GIAC_CONTEXT);
std::string print_realvar_counter(GIAC_CONTEXT);
gen _reset_solve_counter(const gen & args,const context * contextptr);
void set_merge(vecteur & v,const vecteur & w);
bool is_inequation(const gen & g);
gen equal2diff(const gen & g); // rewrite = as -
vecteur protect_sort(const vecteur & res,GIAC_CONTEXT);
vecteur find_singularities(const gen & e,const identificateur & x,int cplxmode,GIAC_CONTEXT);
vecteur protect_find_singularities(const gen & e,const identificateur & x,int cplxmode,GIAC_CONTEXT);
// isolate_mode & 1 is complex_mode, isolate_mode & 2 is 0 for principal sol
vecteur protect_solve(const gen & e,const identificateur & x,int isolate_mode,GIAC_CONTEXT);
vecteur solve(const gen & e,const identificateur & x,int isolate_mode,GIAC_CONTEXT);
vecteur solve(const gen & e,const gen & x,int isolate_mode,GIAC_CONTEXT);
vecteur solve(const vecteur & v,bool complex_mode,GIAC_CONTEXT); // v is a 1-d dense polynomial
void solve(const gen & e,const identificateur & x,vecteur &v,int isolate_mode,GIAC_CONTEXT);
void in_solve(const gen & e,const identificateur & x,vecteur &v,int isolate_mode,GIAC_CONTEXT);
// modular roots, modulo p, p supposed to be prime
// dogcd should be set to true except if you have already done gcd with x^p-x
bool modpolyroot(const vecteur & a,const gen & p,vecteur & v,bool dogcd,GIAC_CONTEXT);
gen solvepostprocess(const gen & g,const gen & x,GIAC_CONTEXT);
// convert solutions to an expression
gen _solve(const gen & args,GIAC_CONTEXT);
extern const unary_function_ptr * const at_solve ;
gen in_fsolve(vecteur & v,GIAC_CONTEXT);
gen _fsolve(const gen & args,GIAC_CONTEXT);
// also sets iszero to -2 if endpoints have same sign, -1 if err or undef
// 1 if zero found, 2 if sign reversal (no undef),
// set iszero to 0 on entry if only one root
// set to -1 or positive if you want many sign reversals
// -1 means no step specified, positive means nstep specified
vecteur bisection_solver(const gen & equation,const gen & var,const gen & a0,const gen &b0,int & iszero,GIAC_CONTEXT);
// FIXME: implement msolve without GSL
// gen msolve(const gen & f,const vecteur & vars,const vecteur & g,int method,double eps,GIAC_CONTEXT);
extern const unary_function_ptr * const at_fsolve ;
vecteur sxa(const vecteur & sl,const vecteur & x,GIAC_CONTEXT);
vecteur linsolve(const vecteur & sl,const vecteur & x,GIAC_CONTEXT);
gen symb_linsolve(const gen & syst,const gen & vars);
gen _linsolve(const gen & args,GIAC_CONTEXT);
extern const unary_function_ptr * const at_linsolve ;
void linsolve_u(const matrice & m,const vecteur & y,vecteur & a);
void linsolve_l(const matrice & m,const vecteur & y,vecteur & a);
/*
gen newtona(const gen & f, const gen & x, const gen & arg,int niter1, int niter2, double eps1,double eps2,double prefact1,double prefact2, int & b);
gen newton(const gen & f, const gen & x,const gen & guess,int niter1=5,int niter2=50,double eps1=1e-3,double eps2=1e-12,double prefact1=0.5,double prefact2=1.0);
*/
// if real is true random re-initialization will be real only,
// if xmin=0)
* m : number of constraints (>=0)
* x : on input, initial estimate ; on output, the solution
* rhobeg : a reasonable initial change to the variables
* rhoend : the required accuracy for the variables
* message : see the cobyla_message enum
* maxfun : on input, the maximum number of function evaluations
* on output, the number of function evaluations done
* calcfc : the function to minimize (see cobyla_function)
* state : used by function (see cobyla_function)
*
* The cobyla function returns a code defined in the cobyla_rc enum.
*
*/
extern int cobyla(int n, int m, double *x, double rhobeg, double rhoend,
int message, int *maxfun, cobyla_function *calcfc, void *state);
#endif /* _COBYLA_ */
#endif // GIAC_HAS_STO_38