# NumGfun version 0.2
#
# Recurrence unrolling by binary splitting; analytic continuation of holonomic functions; bounds for
# holonomic sequences.
#
# Marc Mezzarobba


#infolevel[ancont] := 10;
#infolevel[bounds] := 10;
#infolevel[nth_term] := 10;
#infolevel[step_transition_matrix] := 1;
#infolevel[binsplit] := 10;
#infolevel[recmatrix] := 10;
# there may be more

####################################################################################################
## Module definition
####################################################################################################

NumGfun := module()

description
    "Binary splitting, analytic continuation of holonomic functions, and bounds";

option
    package,
    load = alpha_warning;

global
    `convert/ndmatrix`,
    `type/ndmatrix`,
    `type/matrix_ring`,
    `type/hrrec`,
    `type/hrdeq`,
    `value/Coeftayl`,
    `abs/RootOf`,
    ndmatrix,
    
    opaquemodules,
    # used by LinearAlgebra
    shape, identity, zero, outputoptions, inplace,
    
    # module names for userinfo
    ancont, bounds
    ;

export 
    ac_eval,
    bound_diffeq,
    bound_rec,
    bound_ratpoly,
    bound_diffeq_tail,
    bound_rec_tail,
    diffeqtoproc,
    local_monodromy,
    ndseries,
    nth_term,
    fnth_term,
    rectoproc_binsplit,
    transition_matrix,
    monodromy,
    waksman_product,
    NumGfun_version,
    NumGfun_settings;

local
    # options
    param_binary_splitting_threshold,
    param_precision_factor,
    param_precision_delta,
    param_terms_factor,
    param_terms_delta,
    #binsplit = `binsplit/inlined`,
    #binsplit = `binsplit/generic`,

    # matrix rings
    LAMain, ReIm, bigint, mvMult, WaksmanInplace, waksman,
    # misc names
    generic, nbterms,

    fail_if_singular,
    evalf_absoluteprec,
    `Nth_term/common`,
    `Nth_term/ndseries`,
    `nth_term/doit`,
    `binsplit/inlined`,
    `makeitfloat/Q[i]`,
    `makeitfloat/ndmatrix`,
    `needed_terms/sharp`,
    `needed_terms/vdH01/zero`,
    `needed_terms/vdH01/maj`,
    `rest_majorant/vdHlike`,
    alpha_warning,
    binsplit,
    bound_ratpoly_coeffs,
    bound_ratpoly_int,
    bound_ratpoly_on_disk,
    bound_transition_matrix,
    bound_values,
    call,
    dominant_root,
    extractline,
    first_root,
    frectomatrix,
    frectopoly,
    genmatring,
    getname,
    deq_inicond_vector,
    majorant_series,
    make_fresh_name_generator,
    rec_inicond_vector,
    makeitfloat,
    myformatrec,
    ndmatrix_multiply,
    ndmatrix_norm,
    needed_terms,
    old_needed_terms,
    orddiffeq,
    ordfrec,
    ordrec,
    parametered_rec,
    path_transition_matrix,
    pole_multiplicity,
    read_diffeq,
    read_diffeq_or_rec,
    read_rec,
    recmatrix,
    rectodiffrec,
    root_multiplicity,
    singularities,
    solve_ineq,
    step_transition_matrix,
    vdH01_bound,
    
    matrix_ring,
    s_opaquemodules,
    s_quiet,

    makediffeq,
    mydiffeqtohomdiffeq,

    # 'new' bounds
    typecheck_hr_eq,
    argmax,
    falling_factorial,
    colinear,
    above_below,
    below,
    above,
    one_sol_of_ineq,
    parse_exppoly_term,
    max_of_exppoly_term,
    normal_type,
    poincare_normalization,
    bound_normal_diffeq_doit,
    bound_rec_doit,
    bound_diffeq_doit,
    normal_majorant_series_formula,
    normal_coeff_formula,
    tail_constant,
    tail_bound,
    nb_terms,
    rewrite_path,
    bit_burst_path
;

alpha_warning := proc()
    WARNING(cat(
        "NumGfun is experimental code (and this version is especially unstable), don't trust it! ",
        "Please report bugs to marc", "@", "mezzarobba", ".", "net."));
end proc:

NumGfun_version := "0.2";

use gfun, LinearAlgebra in

s_quiet := interface(quiet = true);
s_opaquemodules := kernelopts(opaquemodules);
kernelopts(opaquemodules=false);

$include "settings.mpl"
$include "utilities.mpl"
$include "matrices.mpl"
$include "nthterm.mpl"
$include "bounds.mpl"
$include "ancont.mpl"
$include "diffeqtoproc.mpl"

kernelopts(opaquemodules=s_opaquemodules);
interface(quiet=s_quiet);

end use;

end module;

to_save := [
    NumGfun,
    `convert/ndmatrix`,
    `type/ndmatrix`,
    `type/matrix_ring`,
    `type/hrdeq`,
    `type/hrrec`,
    `value/Coeftayl`,
    `abs/RootOf`
];
