2014-06-19 15:43:48 +02:00
|
|
|
/*=============================================================================
|
|
|
|
|
|
|
|
This file is part of ARB.
|
|
|
|
|
|
|
|
ARB 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 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
ARB 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 ARB; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
=============================================================================*/
|
|
|
|
/******************************************************************************
|
|
|
|
|
|
|
|
Copyright (C) 2013 Fredrik Johansson
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
#ifndef ARB_CALC_H
|
|
|
|
#define ARB_CALC_H
|
|
|
|
|
2016-01-01 17:18:55 -05:00
|
|
|
#include <stdio.h>
|
2014-06-19 15:43:48 +02:00
|
|
|
#include "arb.h"
|
|
|
|
#include "arb_poly.h"
|
|
|
|
#include "arb_mat.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern TLS_PREFIX int arb_calc_verbose;
|
|
|
|
|
|
|
|
typedef int (*arb_calc_func_t)(arb_ptr out,
|
2015-11-06 11:13:44 +00:00
|
|
|
const arb_t inp, void * param, slong order, slong prec);
|
2014-06-19 15:43:48 +02:00
|
|
|
|
|
|
|
#define ARB_CALC_SUCCESS 0
|
|
|
|
#define ARB_CALC_IMPRECISE_INPUT 1
|
|
|
|
#define ARB_CALC_NO_CONVERGENCE 2
|
|
|
|
|
|
|
|
/* Root-finding */
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
arf_struct a;
|
|
|
|
arf_struct b;
|
|
|
|
}
|
|
|
|
arf_interval_struct;
|
|
|
|
|
|
|
|
typedef arf_interval_struct arf_interval_t[1];
|
|
|
|
typedef arf_interval_struct * arf_interval_ptr;
|
|
|
|
typedef const arf_interval_struct * arf_interval_srcptr;
|
|
|
|
|
|
|
|
static __inline__ void
|
|
|
|
arf_interval_init(arf_interval_t v)
|
|
|
|
{
|
|
|
|
arf_init(&v->a);
|
|
|
|
arf_init(&v->b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
|
|
|
arf_interval_clear(arf_interval_t v)
|
|
|
|
{
|
|
|
|
arf_clear(&v->a);
|
|
|
|
arf_clear(&v->b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ arf_interval_ptr
|
2015-11-06 11:13:44 +00:00
|
|
|
_arf_interval_vec_init(slong n)
|
2014-06-19 15:43:48 +02:00
|
|
|
{
|
2015-11-06 11:13:44 +00:00
|
|
|
slong i;
|
2014-06-19 15:43:48 +02:00
|
|
|
arf_interval_ptr v = (arf_interval_ptr) flint_malloc(sizeof(arf_interval_struct) * n);
|
|
|
|
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
arf_interval_init(v + i);
|
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
2015-11-06 11:13:44 +00:00
|
|
|
_arf_interval_vec_clear(arf_interval_ptr v, slong n)
|
2014-06-19 15:43:48 +02:00
|
|
|
{
|
2015-11-06 11:13:44 +00:00
|
|
|
slong i;
|
2014-06-19 15:43:48 +02:00
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
arf_interval_clear(v + i);
|
|
|
|
flint_free(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
|
|
|
arf_interval_set(arf_interval_t v, const arf_interval_t u)
|
|
|
|
{
|
|
|
|
arf_set(&v->a, &u->a);
|
|
|
|
arf_set(&v->b, &u->b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
|
|
|
arf_interval_swap(arf_interval_t v, arf_interval_t u)
|
|
|
|
{
|
|
|
|
arf_swap(&v->a, &u->a);
|
|
|
|
arf_swap(&v->b, &u->b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
2015-11-06 11:13:44 +00:00
|
|
|
arf_interval_get_arb(arb_t x, const arf_interval_t v, slong prec)
|
2014-06-19 15:43:48 +02:00
|
|
|
{
|
|
|
|
arb_set_interval_arf(x, &v->a, &v->b, prec);
|
|
|
|
}
|
|
|
|
|
2015-12-31 18:26:05 -05:00
|
|
|
static __inline__ void
|
|
|
|
arf_interval_fprintd(FILE * file, const arf_interval_t v, slong n)
|
|
|
|
{
|
|
|
|
flint_fprintf(file, "[");
|
|
|
|
arf_fprintd(file, &v->a, n);
|
|
|
|
flint_fprintf(file, ", ");
|
|
|
|
arf_fprintd(file, &v->b, n);
|
|
|
|
flint_fprintf(file, "]");
|
|
|
|
}
|
|
|
|
|
2016-01-01 17:18:55 -05:00
|
|
|
static __inline__ void
|
|
|
|
arf_interval_printd(const arf_interval_t v, slong n)
|
|
|
|
{
|
|
|
|
arf_interval_fprintd(stdout, v, n);
|
|
|
|
}
|
|
|
|
|
2014-06-19 15:43:48 +02:00
|
|
|
/* bisection */
|
|
|
|
|
|
|
|
int arb_calc_partition(arf_interval_t L, arf_interval_t R,
|
2015-11-06 11:13:44 +00:00
|
|
|
arb_calc_func_t func, void * param, const arf_interval_t block, slong prec);
|
2014-06-19 15:43:48 +02:00
|
|
|
|
2015-11-10 13:41:43 +00:00
|
|
|
slong arb_calc_isolate_roots(arf_interval_ptr * blocks, int ** flags,
|
2014-06-19 15:43:48 +02:00
|
|
|
arb_calc_func_t func, void * param,
|
2015-11-06 11:13:44 +00:00
|
|
|
const arf_interval_t block, slong maxdepth, slong maxeval, slong maxfound,
|
|
|
|
slong prec);
|
2014-06-19 15:43:48 +02:00
|
|
|
|
|
|
|
int arb_calc_refine_root_bisect(arf_interval_t r, arb_calc_func_t func,
|
2015-11-06 11:13:44 +00:00
|
|
|
void * param, const arf_interval_t start, slong iter, slong prec);
|
2014-06-19 15:43:48 +02:00
|
|
|
|
|
|
|
/* newton iteration */
|
|
|
|
|
|
|
|
void arb_calc_newton_conv_factor(arf_t conv_factor,
|
2015-11-06 11:13:44 +00:00
|
|
|
arb_calc_func_t func, void * param, const arb_t conv_region, slong prec);
|
2014-06-19 15:43:48 +02:00
|
|
|
|
|
|
|
int arb_calc_newton_step(arb_t xnew, arb_calc_func_t func, void * param,
|
2015-11-06 11:13:44 +00:00
|
|
|
const arb_t x, const arb_t conv_region, const arf_t conv_factor, slong prec);
|
2014-06-19 15:43:48 +02:00
|
|
|
|
|
|
|
int arb_calc_refine_root_newton(arb_t r, arb_calc_func_t func,
|
|
|
|
void * param, const arb_t start, const arb_t conv_region,
|
2015-11-06 11:13:44 +00:00
|
|
|
const arf_t conv_factor, slong eval_extra_prec, slong prec);
|
2014-06-19 15:43:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|