/* qopt_private.h */

static void constrained_quadopt_helper(dym *a,dyv *b,double c,dyv *lo,dyv *hi,ivec *att_types, dyv **r_xopt,double *r_opt_value, int k,int k_att_type);


static void quadopt_regular_to_eqv(int j,double q,
                            dym *a,dyv *b,double c,
                            dyv *lo,dyv *hi,ivec *att_types,
                            dym **eqv_a,dyv **eqv_b,double *eqv_c,
                            dyv **eqv_lo,dyv **eqv_hi,ivec **eqv_att_types);

static void xopt_regular_to_eqv(int j,dyv *xopt,dyv **eqv_xopt);

static void xopt_eqv_to_regular(int j,double q,dyv *eqv_xopt,dyv **xopt);

static dyv *mk_derivative_function(dym *a,dyv *b,int k,double *r_p);

static dyv *mk_rectangle_center(dyv *lo,dyv *hi);


static void compute_derivative_limits(dym *a,dyv *b,dyv *lo,dyv *hi,int k,
                               double *r_deriv_lo,double *r_deriv_hi);

static int find_known_lo_or_hi_att_num(dym *a,dyv *b,dyv *lo,dyv *hi,ivec *att_types, int *r_known_att_type);

static void compute_var_att_deriv_limits(dym *a,dyv *b,dyv *lo,dyv *hi,
                                  dyv **r_lo_deriv,dyv **r_hi_deriv);

static double compute_max_possible(dym *a,dyv *b,double c,dyv *lo,dyv *hi,
                            dyv *var_att_min_deriv,
                            dyv *var_att_max_deriv);

static bool dyv_strictly_outside_bounds(dyv *x,dyv *lo,dyv *hi);

static void constrained_quadopt_1d(double a,double b,double c,double lo,double hi, dyv **r_xopt,double *r_opt_value);

static void constrained_quadopt(dym *a,dyv *b,double c,dyv *lo,dyv *hi,ivec *att_types, bool do_cutoff_check, dyv **r_xopt,double *r_opt_value);

static void free_quadargs(quadargs *qa);

static quadargs *mk_empty_quadargs(void);

void check_next_line(FILE *s,char *string,char **r_errmess); /* XXX: move to am_string */
/* Actually, check_next_line is NEVER used. Check the source :) */

char *mk_check_quadargs_errmess(quadargs *qa); /* Also unused */

static dyv *mk_random_dyv(int size); /* Move to am_dyv_extended */

static dym *mk_random_symmetric_dym(int rows,int cols);

static quadargs *mk_random_quadargs(int seed,int size);

static dym *mk_quadres_dym(int start_seed,int size,int num_runs,ivec **nodes,double *r_mean_nodes,int *r_time);

void run_quadres(void);

void test_quadargs(quadargs *qa); /* Usually unused */

