This file is indexed.

/usr/include/arb.h is in libflint-arb-dev 2.8.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
/*=============================================================================

    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) 2014 Fredrik Johansson

******************************************************************************/

#ifndef ARB_H
#define ARB_H

#ifdef ARB_INLINES_C
#define ARB_INLINE
#else
#define ARB_INLINE static __inline__
#endif

#include "fmprb.h"
#include "mag.h"
#include "arf.h"

#ifdef __cplusplus
extern "C" {
#endif

extern const char * arb_version;

typedef struct
{
    arf_struct mid;
    mag_struct rad;
}
arb_struct;

typedef arb_struct arb_t[1];
typedef arb_struct * arb_ptr;
typedef const arb_struct * arb_srcptr;

#define arb_midref(x) (&(x)->mid)
#define arb_radref(x) (&(x)->rad)

#define ARB_IS_LAGOM(x) (ARF_IS_LAGOM(arb_midref(x)) && MAG_IS_LAGOM(arb_radref(x)))

#define ARB_RND ARF_RND_DOWN

ARB_INLINE void
arb_init(arb_t x)
{
    arf_init(arb_midref(x));
    mag_init(arb_radref(x));
}

ARB_INLINE void
arb_clear(arb_t x)
{
    arf_clear(arb_midref(x));
    mag_clear(arb_radref(x));
}

ARB_INLINE arb_ptr
_arb_vec_init(slong n)
{
    slong i;
    arb_ptr v = (arb_ptr) flint_malloc(sizeof(arb_struct) * n);

    for (i = 0; i < n; i++)
        arb_init(v + i);

    return v;
}

ARB_INLINE void
_arb_vec_clear(arb_ptr v, slong n)
{
    slong i;
    for (i = 0; i < n; i++)
        arb_clear(v + i);
    flint_free(v);
}

ARB_INLINE void
arb_set_fmprb(arb_t x, const fmprb_t y)
{
    arf_set_fmpr(arb_midref(x), fmprb_midref(y));
    mag_set_fmpr(arb_radref(x), fmprb_radref(y));
}

ARB_INLINE void
arb_get_fmprb(fmprb_t x, const arb_t y)
{
    arf_get_fmpr(fmprb_midref(x), arb_midref(y));
    mag_get_fmpr(fmprb_radref(x), arb_radref(y));
}

ARB_INLINE arf_ptr arb_mid_ptr(arb_t z) { return arb_midref(z); }
ARB_INLINE mag_ptr arb_rad_ptr(arb_t z) { return arb_radref(z); }

ARB_INLINE int
arb_is_exact(const arb_t x)
{
    return mag_is_zero(arb_radref(x));
}

ARB_INLINE int
arb_equal(const arb_t x, const arb_t y)
{
    return arf_equal(arb_midref(x), arb_midref(y)) &&
           mag_equal(arb_radref(x), arb_radref(y));
}

int arb_eq(const arb_t x, const arb_t y);
int arb_ne(const arb_t x, const arb_t y);
int arb_lt(const arb_t x, const arb_t y);
int arb_le(const arb_t x, const arb_t y);
int arb_gt(const arb_t x, const arb_t y);
int arb_ge(const arb_t x, const arb_t y);

ARB_INLINE void
arb_zero(arb_t x)
{
    arf_zero(arb_midref(x));
    mag_zero(arb_radref(x));
}

ARB_INLINE int
arb_is_zero(const arb_t x)
{
    return arf_is_zero(arb_midref(x)) && mag_is_zero(arb_radref(x));
}

ARB_INLINE void
arb_pos_inf(arb_t x)
{
    arf_pos_inf(arb_midref(x));
    mag_zero(arb_radref(x));
}

ARB_INLINE void
arb_neg_inf(arb_t x)
{
    arf_neg_inf(arb_midref(x));
    mag_zero(arb_radref(x));
}

ARB_INLINE void
arb_zero_pm_inf(arb_t x)
{
    arf_zero(arb_midref(x));
    mag_inf(arb_radref(x));
}

ARB_INLINE void
arb_indeterminate(arb_t x)
{
    arf_nan(arb_midref(x));
    mag_inf(arb_radref(x));
}

ARB_INLINE int
arb_is_finite(const arb_t x)
{
    return arf_is_finite(arb_midref(x)) && mag_is_finite(arb_radref(x));
}

void arb_set(arb_t x, const arb_t y);

ARB_INLINE void
arb_swap(arb_t x, arb_t y)
{
    arb_struct t = *x;
    *x = *y;
    *y = t;
}

void arb_set_round(arb_t z, const arb_t x, slong prec);

void arb_trim(arb_t y, const arb_t x);

void arb_neg(arb_t y, const arb_t x);

void arb_neg_round(arb_t x, const arb_t y, slong prec);

void arb_abs(arb_t y, const arb_t x);

void _arb_digits_round_inplace(char * s, mp_bitcnt_t * shift, fmpz_t error, slong n, arf_rnd_t rnd);

int arb_set_str(arb_t res, const char * inp, slong prec);

#define ARB_STR_MORE UWORD(1)
#define ARB_STR_NO_RADIUS UWORD(2)
#define ARB_STR_CONDENSE UWORD(16)

char * arb_get_str(const arb_t x, slong n, ulong flags);


ARB_INLINE void
arb_set_arf(arb_t x, const arf_t y)
{
    arf_set(arb_midref(x), y);
    mag_zero(arb_radref(x));
}

ARB_INLINE void
arb_set_si(arb_t x, slong y)
{
    arf_set_si(arb_midref(x), y);
    mag_zero(arb_radref(x));
}

ARB_INLINE void
arb_set_ui(arb_t x, ulong y)
{
    arf_set_ui(arb_midref(x), y);
    mag_zero(arb_radref(x));
}

ARB_INLINE void
arb_set_d(arb_t x, double y)
{
    arf_set_d(arb_midref(x), y);
    mag_zero(arb_radref(x));
}

ARB_INLINE void
arb_set_fmpz(arb_t x, const fmpz_t y)
{
    arf_set_fmpz(arb_midref(x), y);
    mag_zero(arb_radref(x));
}

ARB_INLINE void
arb_set_fmpz_2exp(arb_t x, const fmpz_t y, const fmpz_t exp)
{
    arf_set_fmpz_2exp(arb_midref(x), y, exp);
    mag_zero(arb_radref(x));
}

void arb_set_round_fmpz_2exp(arb_t y, const fmpz_t x, const fmpz_t exp, slong prec);

void arb_set_round_fmpz(arb_t y, const fmpz_t x, slong prec);

ARB_INLINE int
arb_is_one(const arb_t f)
{
    return arf_is_one(arb_midref(f)) && mag_is_zero(arb_radref(f));
}

ARB_INLINE void
arb_one(arb_t f)
{
    arf_one(arb_midref(f));
    mag_zero(arb_radref(f));
}

void arb_print(const arb_t x);

void arb_printd(const arb_t x, slong digits);

void arb_printn(const arb_t x, slong digits, ulong flags);

ARB_INLINE void
arb_mul_2exp_si(arb_t y, const arb_t x, slong e)
{
    arf_mul_2exp_si(arb_midref(y), arb_midref(x), e);
    mag_mul_2exp_si(arb_radref(y), arb_radref(x), e);
}

ARB_INLINE void
arb_mul_2exp_fmpz(arb_t y, const arb_t x, const fmpz_t e)
{
    arf_mul_2exp_fmpz(arb_midref(y), arb_midref(x), e);
    mag_mul_2exp_fmpz(arb_radref(y), arb_radref(x), e);
}

ARB_INLINE int
arb_is_int(const arb_t x)
{
    return mag_is_zero(arb_radref(x)) &&
           arf_is_int(arb_midref(x));
}

ARB_INLINE int
arb_contains_zero(const arb_t x)
{
    return arf_cmpabs_mag(arb_midref(x), arb_radref(x)) <= 0;
}

ARB_INLINE int
arb_is_nonzero(const arb_t x)
{
    return !arb_contains_zero(x);
}

ARB_INLINE int
arb_is_positive(const arb_t x)
{
    return (arf_sgn(arb_midref(x)) > 0) &&
        (arf_mag_cmpabs(arb_radref(x), arb_midref(x)) < 0) &&
         !arf_is_nan(arb_midref(x));
}

ARB_INLINE int
arb_is_nonnegative(const arb_t x)
{
    return (arf_sgn(arb_midref(x)) >= 0) &&
        (arf_mag_cmpabs(arb_radref(x), arb_midref(x)) <= 0) &&
         !arf_is_nan(arb_midref(x));
}

ARB_INLINE int
arb_is_negative(const arb_t x)
{
    return (arf_sgn(arb_midref(x)) < 0) &&
        (arf_mag_cmpabs(arb_radref(x), arb_midref(x)) < 0) &&
         !arf_is_nan(arb_midref(x));
}

ARB_INLINE int
arb_is_nonpositive(const arb_t x)
{
    return (arf_sgn(arb_midref(x)) <= 0) &&
        (arf_mag_cmpabs(arb_radref(x), arb_midref(x)) <= 0) &&
         !arf_is_nan(arb_midref(x));
}

ARB_INLINE int
arb_contains_negative(const arb_t x)
{
    return (arf_sgn(arb_midref(x)) < 0) ||
        (arf_mag_cmpabs(arb_radref(x), arb_midref(x)) > 0)
        || arf_is_nan(arb_midref(x));
}

ARB_INLINE int
arb_contains_nonpositive(const arb_t x)
{
    return (arf_sgn(arb_midref(x)) <= 0) ||
        (arf_mag_cmpabs(arb_radref(x), arb_midref(x)) >= 0)
        || arf_is_nan(arb_midref(x));
}

ARB_INLINE int
arb_contains_positive(const arb_t x)
{
    return (arf_sgn(arb_midref(x)) > 0) ||
        (arf_mag_cmpabs(arb_radref(x), arb_midref(x)) > 0)
        || arf_is_nan(arb_midref(x));
}

ARB_INLINE int
arb_contains_nonnegative(const arb_t x)
{
    return (arf_sgn(arb_midref(x)) >= 0) ||
        (arf_mag_cmpabs(arb_radref(x), arb_midref(x)) >= 0)
        || arf_is_nan(arb_midref(x));
}

void arb_get_mag_lower(mag_t z, const arb_t x);

void arb_get_mag_lower_nonnegative(mag_t z, const arb_t x);

ARB_INLINE void
arb_get_mag(mag_t z, const arb_t x)
{
    mag_t t;
    mag_init_set_arf(t, arb_midref(x));
    mag_add(z, t, arb_radref(x));
    mag_clear(t);
}

ARB_INLINE void
arb_get_mid_arb(arb_t z, const arb_t x)
{
    arf_set(arb_midref(z), arb_midref(x));
    mag_zero(arb_radref(z));
}

ARB_INLINE void
arb_get_rad_arb(arb_t z, const arb_t x)
{
    arf_set_mag(arb_midref(z), arb_radref(x));
    mag_zero(arb_radref(z));
}

ARB_INLINE void
arb_get_abs_ubound_arf(arf_t u, const arb_t x, slong prec)
{
    arf_t t;
    arf_init_set_mag_shallow(t, arb_radref(x));

    if (arf_sgn(arb_midref(x)) < 0)
        arf_sub(u, arb_midref(x), t, prec, ARF_RND_UP);
    else
        arf_add(u, arb_midref(x), t, prec, ARF_RND_UP);

    arf_abs(u, u);
}

ARB_INLINE void
arb_get_abs_lbound_arf(arf_t u, const arb_t x, slong prec)
{
    arf_t t;
    arf_init_set_mag_shallow(t, arb_radref(x));

    if (arf_sgn(arb_midref(x)) > 0)
    {
        arf_sub(u, arb_midref(x), t, prec, ARF_RND_UP);
    }
    else
    {
        arf_add(u, arb_midref(x), t, prec, ARF_RND_UP);
        arf_neg(u, u);
    }

    if (arf_sgn(u) < 0)
        arf_zero(u);
}

slong arb_rel_error_bits(const arb_t x);

ARB_INLINE slong
arb_rel_accuracy_bits(const arb_t x)
{
    return -arb_rel_error_bits(x);
}

ARB_INLINE slong
arb_bits(const arb_t x)
{
    return arf_bits(arb_midref(x));
}

void arb_randtest_exact(arb_t x, flint_rand_t state, slong prec, slong mag_bits);

void arb_randtest_wide(arb_t x, flint_rand_t state, slong prec, slong mag_bits);

void arb_randtest_precise(arb_t x, flint_rand_t state, slong prec, slong mag_bits);

void arb_randtest(arb_t x, flint_rand_t state, slong prec, slong mag_bits);

void arb_randtest_special(arb_t x, flint_rand_t state, slong prec, slong mag_bits);

void arb_add_error_arf(arb_t x, const arf_t err);

void arb_add_error_2exp_si(arb_t x, slong err);

void arb_add_error_2exp_fmpz(arb_t x, const fmpz_t err);

void arb_add_error(arb_t x, const arb_t error);

ARB_INLINE void
arb_add_error_mag(arb_t x, const mag_t err)
{
    mag_add(arb_radref(x), arb_radref(x), err);
}

int arb_contains_arf(const arb_t x, const arf_t y);

int arb_contains_fmpq(const arb_t x, const fmpq_t y);

int arb_contains_fmpz(const arb_t x, const fmpz_t y);

int arb_contains_si(const arb_t x, slong y);

int arb_contains_mpfr(const arb_t x, const mpfr_t y);

int arb_overlaps(const arb_t x, const arb_t y);

int arb_contains(const arb_t x, const arb_t y);

int arb_contains_int(const arb_t x);

void arb_get_interval_fmpz_2exp(fmpz_t a, fmpz_t b, fmpz_t exp, const arb_t x);
int arb_get_unique_fmpz(fmpz_t z, const arb_t x);

void arb_get_fmpz_mid_rad_10exp(fmpz_t mid, fmpz_t rad, fmpz_t exp, const arb_t x, slong n);

void arb_floor(arb_t z, const arb_t x, slong prec);
void arb_ceil(arb_t z, const arb_t x, slong prec);

void arb_set_interval_arf(arb_t x, const arf_t a, const arf_t b, slong prec);
void arb_set_interval_mpfr(arb_t x, const mpfr_t a, const mpfr_t b, slong prec);

void arb_get_interval_arf(arf_t a, arf_t b, const arb_t x, slong prec);
void arb_get_interval_mpfr(mpfr_t a, mpfr_t b, const arb_t x);

void arb_union(arb_t z, const arb_t x, const arb_t y, slong prec);
void arb_get_rand_fmpq(fmpq_t q, flint_rand_t state, const arb_t x, slong bits);

void arb_add(arb_t z, const arb_t x, const arb_t y, slong prec);
void arb_add_arf(arb_t z, const arb_t x, const arf_t y, slong prec);
void arb_add_ui(arb_t z, const arb_t x, ulong y, slong prec);
void arb_add_si(arb_t z, const arb_t x, slong y, slong prec);
void arb_add_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec);
void arb_add_fmpz_2exp(arb_t z, const arb_t x, const fmpz_t man, const fmpz_t exp, slong prec);

void arb_sub(arb_t z, const arb_t x, const arb_t y, slong prec);
void arb_sub_arf(arb_t z, const arb_t x, const arf_t y, slong prec);
void arb_sub_ui(arb_t z, const arb_t x, ulong y, slong prec);
void arb_sub_si(arb_t z, const arb_t x, slong y, slong prec);
void arb_sub_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec);

void arb_mul(arb_t z, const arb_t x, const arb_t y, slong prec);
void arb_mul_arf(arb_t z, const arb_t x, const arf_t y, slong prec);
void arb_mul_si(arb_t z, const arb_t x, slong y, slong prec);
void arb_mul_ui(arb_t z, const arb_t x, ulong y, slong prec);
void arb_mul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec);

void arb_addmul(arb_t z, const arb_t x, const arb_t y, slong prec);
void arb_addmul_arf(arb_t z, const arb_t x, const arf_t y, slong prec);
void arb_addmul_si(arb_t z, const arb_t x, slong y, slong prec);
void arb_addmul_ui(arb_t z, const arb_t x, ulong y, slong prec);
void arb_addmul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec);

void arb_submul(arb_t z, const arb_t x, const arb_t y, slong prec);
void arb_submul_arf(arb_t z, const arb_t x, const arf_t y, slong prec);
void arb_submul_si(arb_t z, const arb_t x, slong y, slong prec);
void arb_submul_ui(arb_t z, const arb_t x, ulong y, slong prec);
void arb_submul_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec);

void arb_div(arb_t z, const arb_t x, const arb_t y, slong prec);
void arb_div_arf(arb_t z, const arb_t x, const arf_t y, slong prec);
void arb_div_si(arb_t z, const arb_t x, slong y, slong prec);
void arb_div_ui(arb_t z, const arb_t x, ulong y, slong prec);
void arb_div_fmpz(arb_t z, const arb_t x, const fmpz_t y, slong prec);
void arb_fmpz_div_fmpz(arb_t z, const fmpz_t x, const fmpz_t y, slong prec);
void arb_ui_div(arb_t z, ulong x, const arb_t y, slong prec);

ARB_INLINE void
arb_inv(arb_t y, const arb_t x, slong prec)
{
    arb_ui_div(y, 1, x, prec);
}

ARB_INLINE void
arb_set_fmpq(arb_t y, const fmpq_t x, slong prec)
{
    arb_fmpz_div_fmpz(y, fmpq_numref(x), fmpq_denref(x), prec);
}

void arb_sqrt(arb_t z, const arb_t x, slong prec);
void arb_sqrt_arf(arb_t z, const arf_t x, slong prec);
void arb_sqrt_fmpz(arb_t z, const fmpz_t x, slong prec);
void arb_sqrt_ui(arb_t z, ulong x, slong prec);

void arb_sqrtpos(arb_t z, const arb_t x, slong prec);
void arb_hypot(arb_t z, const arb_t x, const arb_t y, slong prec);

void arb_rsqrt(arb_t z, const arb_t x, slong prec);
void arb_rsqrt_ui(arb_t z, ulong x, slong prec);
void arb_sqrt1pm1(arb_t r, const arb_t z, slong prec);

void arb_pow_fmpz_binexp(arb_t y, const arb_t b, const fmpz_t e, slong prec);
void arb_pow_fmpz(arb_t y, const arb_t b, const fmpz_t e, slong prec);
void arb_pow_ui(arb_t y, const arb_t b, ulong e, slong prec);
void arb_ui_pow_ui(arb_t y, ulong b, ulong e, slong prec);
void arb_si_pow_ui(arb_t y, slong b, ulong e, slong prec);
void arb_pow_fmpq(arb_t y, const arb_t x, const fmpq_t a, slong prec);

void arb_div_2expm1_ui(arb_t z, const arb_t x, ulong n, slong prec);
void arb_pow(arb_t z, const arb_t x, const arb_t y, slong prec);
void arb_root_ui(arb_t z, const arb_t x, ulong k, slong prec);
void arb_root(arb_t z, const arb_t x, ulong k, slong prec); /* back compat */
void arb_log(arb_t z, const arb_t x, slong prec);
void arb_log_arf(arb_t z, const arf_t x, slong prec);
void arb_log_ui(arb_t z, ulong x, slong prec);
void arb_log_fmpz(arb_t z, const fmpz_t x, slong prec);
void arb_log1p(arb_t r, const arb_t z, slong prec);
void arb_exp(arb_t z, const arb_t x, slong prec);
void arb_expm1(arb_t z, const arb_t x, slong prec);
void arb_exp_invexp(arb_t z, arb_t w, const arb_t x, slong prec);
void arb_sin(arb_t s, const arb_t x, slong prec);
void arb_cos(arb_t c, const arb_t x, slong prec);
void arb_sin_cos(arb_t s, arb_t c, const arb_t x, slong prec);
void arb_sin_pi(arb_t s, const arb_t x, slong prec);
void arb_cos_pi(arb_t c, const arb_t x, slong prec);
void arb_sin_cos_pi(arb_t s, arb_t c, const arb_t x, slong prec);
void arb_tan(arb_t y, const arb_t x, slong prec);
void arb_cot(arb_t y, const arb_t x, slong prec);
void arb_tan_pi(arb_t y, const arb_t x, slong prec);
void arb_cot_pi(arb_t y, const arb_t x, slong prec);
void _arb_sin_pi_fmpq_algebraic(arb_t s, ulong p, ulong q, slong prec);
void _arb_cos_pi_fmpq_algebraic(arb_t c, ulong p, ulong q, slong prec);
void _arb_sin_cos_pi_fmpq_algebraic(arb_t s, arb_t c, ulong p, ulong q, slong prec);
void arb_sin_cos_pi_fmpq(arb_t s, arb_t c, const fmpq_t x, slong prec);
void arb_sin_pi_fmpq(arb_t s, const fmpq_t x, slong prec);
void arb_cos_pi_fmpq(arb_t c, const fmpq_t x, slong prec);
void arb_sinc(arb_t z, const arb_t x, slong prec);
void arb_sinh(arb_t z, const arb_t x, slong prec);
void arb_cosh(arb_t z, const arb_t x, slong prec);
void arb_sinh_cosh(arb_t s, arb_t c, const arb_t x, slong prec);
void arb_tanh(arb_t y, const arb_t x, slong prec);
void arb_coth(arb_t y, const arb_t x, slong prec);
void arb_atan_arf(arb_t z, const arf_t x, slong prec);
void arb_atan(arb_t z, const arb_t x, slong prec);
void arb_atan2(arb_t z, const arb_t b, const arb_t a, slong prec);
void arb_asin(arb_t z, const arb_t x, slong prec);
void arb_acos(arb_t z, const arb_t x, slong prec);
void arb_atanh(arb_t z, const arb_t x, slong prec);
void arb_asinh(arb_t z, const arb_t x, slong prec);
void arb_acosh(arb_t z, const arb_t x, slong prec);
void arb_fac_ui(arb_t z, ulong n, slong prec);
void arb_doublefac_ui(arb_t z, ulong n, slong prec);
void arb_bin_ui(arb_t z, const arb_t n, ulong k, slong prec);
void arb_bin_uiui(arb_t z, ulong n, ulong k, slong prec);
void arb_fib_fmpz(arb_t z, const fmpz_t n, slong prec);
void arb_fib_ui(arb_t z, ulong n, slong prec);
void arb_const_pi(arb_t z, slong prec);
void arb_const_sqrt_pi(arb_t z, slong prec);
void arb_const_log_sqrt2pi(arb_t z, slong prec);
void arb_const_log2(arb_t z, slong prec);
void arb_const_log10(arb_t z, slong prec);
void arb_const_euler(arb_t z, slong prec);
void arb_const_catalan(arb_t z, slong prec);
void arb_const_e(arb_t z, slong prec);
void arb_const_khinchin(arb_t z, slong prec);
void arb_const_glaisher(arb_t z, slong prec);
void arb_agm(arb_t z, const arb_t x, const arb_t y, slong prec);
void arb_lgamma(arb_t z, const arb_t x, slong prec);
void arb_rgamma(arb_t z, const arb_t x, slong prec);
void arb_gamma(arb_t z, const arb_t x, slong prec);
void arb_gamma_fmpq(arb_t z, const fmpq_t x, slong prec);
void arb_gamma_fmpz(arb_t z, const fmpz_t x, slong prec);
void arb_digamma(arb_t y, const arb_t x, slong prec);
void arb_zeta(arb_t z, const arb_t s, slong prec);
void arb_hurwitz_zeta(arb_t z, const arb_t s, const arb_t a, slong prec);

void arb_rising_ui_bs(arb_t y, const arb_t x, ulong n, slong prec);
void arb_rising_ui_rs(arb_t y, const arb_t x, ulong n, ulong m, slong prec);
void arb_rising_ui_rec(arb_t y, const arb_t x, ulong n, slong prec);
void arb_rising_ui(arb_t z, const arb_t x, ulong n, slong prec);
void arb_rising_fmpq_ui(arb_t y, const fmpq_t x, ulong n, slong prec);
void arb_rising(arb_t z, const arb_t x, const arb_t n, slong prec);

void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, ulong n, ulong m, slong prec);
void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, ulong n, slong prec);
void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, ulong n, slong prec);

void arb_log_ui_from_prev(arb_t s, ulong k, arb_t log_prev, ulong prev, slong prec);

void arb_const_apery(arb_t s, slong prec);

void arb_zeta_ui_asymp(arb_t x, ulong s, slong prec);
void arb_zeta_ui_borwein_bsplit(arb_t x, ulong s, slong prec);
void arb_zeta_ui_euler_product(arb_t z, ulong s, slong prec);
void arb_zeta_ui_bernoulli(arb_t x, ulong n, slong prec);
void arb_zeta_ui_vec_borwein(arb_ptr z, ulong start, slong num, ulong step, slong prec);
void arb_zeta_ui(arb_t x, ulong n, slong prec);
void arb_zeta_ui_vec_even(arb_ptr x, ulong start, slong num, slong prec);
void arb_zeta_ui_vec_odd(arb_ptr x, ulong start, slong num, slong prec);
void arb_zeta_ui_vec(arb_ptr x, ulong start, slong num, slong prec);
void arb_bernoulli_ui(arb_t b, ulong n, slong prec);
void arb_bernoulli_ui_zeta(arb_t b, ulong n, slong prec);

void arb_polylog(arb_t w, const arb_t s, const arb_t z, slong prec);
void arb_polylog_si(arb_t w, slong s, const arb_t z, slong prec);

void arb_chebyshev_t_ui(arb_t a, ulong n, const arb_t x, slong prec);
void arb_chebyshev_t2_ui(arb_t a, arb_t b, ulong n, const arb_t x, slong prec);
void arb_chebyshev_u_ui(arb_t a, ulong n, const arb_t x, slong prec);
void arb_chebyshev_u2_ui(arb_t a, arb_t b, ulong n, const arb_t x, slong prec);

void arb_power_sum_vec(arb_ptr res, const arb_t a, const arb_t b, slong len, slong prec);
void arb_bell_sum_taylor(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, slong prec);
void arb_bell_sum_bsplit(arb_t res, const fmpz_t n, const fmpz_t a, const fmpz_t b, const fmpz_t mmag, slong prec);
void arb_bell_fmpz(arb_t res, const fmpz_t n, slong prec);

#define ARB_DEF_CACHED_CONSTANT(name, comp_func) \
    TLS_PREFIX slong name ## _cached_prec = 0; \
    TLS_PREFIX arb_t name ## _cached_value; \
    void name ## _cleanup(void) \
    { \
        arb_clear(name ## _cached_value); \
        name ## _cached_prec = 0; \
    } \
    void name(arb_t x, slong prec) \
    { \
        if (name ## _cached_prec < prec) \
        { \
            if (name ## _cached_prec == 0) \
            { \
                arb_init(name ## _cached_value); \
                flint_register_cleanup_function(name ## _cleanup); \
            } \
            comp_func(name ## _cached_value, prec + 32); \
            name ## _cached_prec = prec; \
        } \
        arb_set_round(x, name ## _cached_value, prec); \
    }

/* vector functions */

ARB_INLINE arb_ptr
_arb_vec_entry_ptr(arb_ptr vec, slong i)
{
    return vec + i;
}

ARB_INLINE void
_arb_vec_zero(arb_ptr A, slong n)
{
    slong i;
    for (i = 0; i < n; i++)
        arb_zero(A + i);
}

ARB_INLINE int
_arb_vec_is_zero(arb_srcptr vec, slong len)
{
    slong i;
    for (i = 0; i < len; i++)
        if (!arb_is_zero(vec + i))
            return 0;
    return 1;
}

ARB_INLINE int
_arb_vec_is_finite(arb_srcptr x, slong len)
{
    slong i;

    for (i = 0; i < len; i++)
        if (!arb_is_finite(x + i))
            return 0;

    return 1;
}

ARB_INLINE void
_arb_vec_set(arb_ptr res, arb_srcptr vec, slong len)
{
    slong i;
    for (i = 0; i < len; i++)
        arb_set(res + i, vec + i);
}

ARB_INLINE void
_arb_vec_set_round(arb_ptr res, arb_srcptr vec, slong len, slong prec)
{
    slong i;
    for (i = 0; i < len; i++)
        arb_set_round(res + i, vec + i, prec);
}

ARB_INLINE void
_arb_vec_swap(arb_ptr res, arb_ptr vec, slong len)
{
    slong i;
    for (i = 0; i < len; i++)
        arb_swap(res + i, vec + i);
}

ARB_INLINE void
_arb_vec_neg(arb_ptr B, arb_srcptr A, slong n)
{
    slong i;
    for (i = 0; i < n; i++)
        arb_neg(B + i, A + i);
}

ARB_INLINE void
_arb_vec_sub(arb_ptr C, arb_srcptr A,
    arb_srcptr B, slong n, slong prec)
{
    slong i;
    for (i = 0; i < n; i++)
        arb_sub(C + i, A + i, B + i, prec);
}

ARB_INLINE void
_arb_vec_add(arb_ptr C, arb_srcptr A,
    arb_srcptr B, slong n, slong prec)
{
    slong i;
    for (i = 0; i < n; i++)
        arb_add(C + i, A + i, B + i, prec);
}

ARB_INLINE void
_arb_vec_scalar_mul(arb_ptr res, arb_srcptr vec,
    slong len, const arb_t c, slong prec)
{
    slong i;
    for (i = 0; i < len; i++)
        arb_mul(res + i, vec + i, c, prec);
}

ARB_INLINE void
_arb_vec_scalar_div(arb_ptr res, arb_srcptr vec,
    slong len, const arb_t c, slong prec)
{
    slong i;
    for (i = 0; i < len; i++)
        arb_div(res + i, vec + i, c, prec);
}

ARB_INLINE void
_arb_vec_scalar_mul_fmpz(arb_ptr res, arb_srcptr vec,
    slong len, const fmpz_t c, slong prec)
{
    slong i;
    arf_t t;
    arf_init(t);
    arf_set_fmpz(t, c);
    for (i = 0; i < len; i++)
        arb_mul_arf(res + i, vec + i, t, prec);
    arf_clear(t);
}

ARB_INLINE void
_arb_vec_scalar_mul_2exp_si(arb_ptr res, arb_srcptr src, slong len, slong c)
{
    slong i;
    for (i = 0; i < len; i++)
        arb_mul_2exp_si(res + i, src + i, c);
}

ARB_INLINE void
_arb_vec_scalar_addmul(arb_ptr res, arb_srcptr vec,
    slong len, const arb_t c, slong prec)
{
    slong i;
    for (i = 0; i < len; i++)
        arb_addmul(res + i, vec + i, c, prec);
}

ARB_INLINE void
_arb_vec_dot(arb_t res, arb_srcptr vec1, arb_srcptr vec2, slong len2, slong prec)
{
    slong i;
    arb_zero(res);
    for (i = 0; i < len2; i++)
        arb_addmul(res, vec1 + i, vec2 + i, prec);
}

ARB_INLINE void
_arb_vec_norm(arb_t res, arb_srcptr vec, slong len, slong prec)
{
    slong i;
    arb_zero(res);
    for (i = 0; i < len; i++)
        arb_addmul(res, vec + i, vec + i, prec);
}

ARB_INLINE void
_arb_vec_get_mag(mag_t bound, arb_srcptr vec, slong len)
{
    if (len < 1)
    {
        mag_zero(bound);
    }
    else
    {
        mag_t t;
        slong i;
        arb_get_mag(bound, vec);
        mag_init(t);
        for (i = 1; i < len; i++)
        {
            arb_get_mag(t, vec + i);
            mag_max(bound, bound, t);
        }
        mag_clear(t);
    }
}

ARB_INLINE slong
_arb_vec_bits(arb_srcptr x, slong len)
{
    slong i, b, c;

    b = 0;
    for (i = 0; i < len; i++)
    {
        c = arb_bits(x + i);
        b = FLINT_MAX(b, c);
    }

    return b;
}

ARB_INLINE void
_arb_vec_set_powers(arb_ptr xs, const arb_t x, slong len, slong prec)
{
    slong i;

    for (i = 0; i < len; i++)
    {
        if (i == 0)
            arb_one(xs + i);
        else if (i == 1)
            arb_set_round(xs + i, x, prec);
        else if (i % 2 == 0)
            arb_mul(xs + i, xs + i / 2, xs + i / 2, prec);
        else
            arb_mul(xs + i, xs + i - 1, x, prec);
    }
}

ARB_INLINE void
_arb_vec_add_error_arf_vec(arb_ptr res, arf_srcptr err, slong len)
{
    slong i;
    for (i = 0; i < len; i++)
        arb_add_error_arf(res + i, err + i);
}

ARB_INLINE void
_arb_vec_add_error_mag_vec(arb_ptr res, mag_srcptr err, slong len)
{
    slong i;
    for (i = 0; i < len; i++)
        mag_add(arb_radref(res + i), arb_radref(res + i), err + i);
}

ARB_INLINE void
_arb_vec_indeterminate(arb_ptr vec, slong len)
{
    slong i;
    for (i = 0; i < len; i++)
        arb_indeterminate(vec + i);
}

ARB_INLINE void
_arb_vec_trim(arb_ptr res, arb_srcptr vec, slong len)
{
    slong i;
    for (i = 0; i < len; i++)
        arb_trim(res + i, vec + i);
}

ARB_INLINE int
_arb_vec_get_unique_fmpz_vec(fmpz * res,  arb_srcptr vec, slong len)
{
    slong i;
    for (i = 0; i < len; i++)
        if (!arb_get_unique_fmpz(res + i, vec + i))
            return 0;
    return 1;
}

/* arctangent implementation */

#define ARB_ATAN_TAB1_BITS 8
#define ARB_ATAN_TAB1_PREC 512
#define ARB_ATAN_TAB1_LIMBS (ARB_ATAN_TAB1_PREC / FLINT_BITS)

#define ARB_ATAN_TAB21_BITS 5
#define ARB_ATAN_TAB22_BITS 5
#define ARB_ATAN_TAB2_PREC 4608
#define ARB_ATAN_TAB2_LIMBS (ARB_ATAN_TAB2_PREC / FLINT_BITS)

extern const mp_limb_t arb_atan_tab1[1 << ARB_ATAN_TAB1_BITS][ARB_ATAN_TAB1_LIMBS];
extern const mp_limb_t arb_atan_tab21[1 << ARB_ATAN_TAB21_BITS][ARB_ATAN_TAB2_LIMBS];
extern const mp_limb_t arb_atan_tab22[1 << ARB_ATAN_TAB22_BITS][ARB_ATAN_TAB2_LIMBS];
extern const mp_limb_t arb_atan_pi2_minus_one[ARB_ATAN_TAB2_LIMBS];

void
_arb_atan_taylor_naive(mp_ptr y, mp_limb_t * error,
    mp_srcptr x, mp_size_t xn, ulong N, int alternating);

void _arb_atan_taylor_rs(mp_ptr y, mp_limb_t * error,
    mp_srcptr x, mp_size_t xn, ulong N, int alternating);

/* logarithm implementation */

#define ARB_LOG_TAB11_BITS 7
#define ARB_LOG_TAB12_BITS 7
#define ARB_LOG_TAB1_PREC 512
#define ARB_LOG_TAB1_LIMBS (ARB_LOG_TAB1_PREC / FLINT_BITS)

#define ARB_LOG_TAB21_BITS 5
#define ARB_LOG_TAB22_BITS 5
#define ARB_LOG_TAB2_PREC 4608
#define ARB_LOG_TAB2_LIMBS (ARB_LOG_TAB2_PREC / FLINT_BITS)

extern const mp_limb_t arb_log_tab11[1 << ARB_LOG_TAB11_BITS][ARB_LOG_TAB1_LIMBS];
extern const mp_limb_t arb_log_tab12[1 << ARB_LOG_TAB12_BITS][ARB_LOG_TAB1_LIMBS];
extern const mp_limb_t arb_log_tab21[1 << ARB_LOG_TAB21_BITS][ARB_LOG_TAB2_LIMBS];
extern const mp_limb_t arb_log_tab22[1 << ARB_LOG_TAB22_BITS][ARB_LOG_TAB2_LIMBS];
extern const mp_limb_t arb_log_log2_tab[ARB_LOG_TAB2_LIMBS];

/* exponential implementation */

/* only goes up to log(2) * 256 */
#define ARB_EXP_TAB1_NUM 178
#define ARB_EXP_TAB1_BITS 8
#define ARB_EXP_TAB1_PREC 512
#define ARB_EXP_TAB1_LIMBS (ARB_EXP_TAB1_PREC / FLINT_BITS)

/* only goes up to log(2) * 32 */
#define ARB_EXP_TAB21_NUM 23
#define ARB_EXP_TAB21_BITS 5
#define ARB_EXP_TAB22_NUM (1 << ARB_EXP_TAB22_BITS)
#define ARB_EXP_TAB22_BITS 5
#define ARB_EXP_TAB2_PREC 4608
#define ARB_EXP_TAB2_LIMBS (ARB_EXP_TAB2_PREC / FLINT_BITS)

extern const mp_limb_t arb_exp_tab1[ARB_EXP_TAB1_NUM][ARB_EXP_TAB1_LIMBS];
extern const mp_limb_t arb_exp_tab21[ARB_EXP_TAB21_NUM][ARB_EXP_TAB2_LIMBS];
extern const mp_limb_t arb_exp_tab22[ARB_EXP_TAB22_NUM][ARB_EXP_TAB2_LIMBS];

void _arb_exp_taylor_naive(mp_ptr y, mp_limb_t * error,
    mp_srcptr x, mp_size_t xn, ulong N);

void _arb_exp_taylor_rs(mp_ptr y, mp_limb_t * error,
    mp_srcptr x, mp_size_t xn, ulong N);

void arb_exp_arf_bb(arb_t z, const arf_t x, slong prec, int minus_one);

int _arb_get_mpn_fixed_mod_log2(mp_ptr w, fmpz_t q, mp_limb_t * error,
                                                const arf_t x, mp_size_t wn);

slong _arb_exp_taylor_bound(slong mag, slong prec);

void _arb_exp_sum_bs_powtab(fmpz_t T, fmpz_t Q, mp_bitcnt_t * Qexp,
    const fmpz_t x, mp_bitcnt_t r, slong N);

void _arb_exp_sum_bs_simple(fmpz_t T, fmpz_t Q, mp_bitcnt_t * Qexp,
    const fmpz_t x, mp_bitcnt_t r, slong N);

/* sin/cos implementation */

/* only goes up to (pi/4) * 256 */
#define ARB_SIN_COS_TAB1_NUM 203
#define ARB_SIN_COS_TAB1_BITS 8
#define ARB_SIN_COS_TAB1_PREC 512
#define ARB_SIN_COS_TAB1_LIMBS (ARB_SIN_COS_TAB1_PREC / FLINT_BITS)

/* only goes up to (pi/4) * 32 */
#define ARB_SIN_COS_TAB21_NUM 26
#define ARB_SIN_COS_TAB21_BITS 5
#define ARB_SIN_COS_TAB22_NUM (1 << ARB_SIN_COS_TAB22_BITS)
#define ARB_SIN_COS_TAB22_BITS 5
#define ARB_SIN_COS_TAB2_PREC 4608
#define ARB_SIN_COS_TAB2_LIMBS (ARB_SIN_COS_TAB2_PREC / FLINT_BITS)

extern const mp_limb_t arb_sin_cos_tab1[2 * ARB_SIN_COS_TAB1_NUM][ARB_SIN_COS_TAB1_LIMBS];
extern const mp_limb_t arb_sin_cos_tab21[2 * ARB_SIN_COS_TAB21_NUM][ARB_SIN_COS_TAB2_LIMBS];
extern const mp_limb_t arb_sin_cos_tab22[2 * ARB_SIN_COS_TAB22_NUM][ARB_SIN_COS_TAB2_LIMBS];

#define ARB_PI4_TAB_LIMBS (4608 / FLINT_BITS)
extern const mp_limb_t arb_pi4_tab[ARB_PI4_TAB_LIMBS];

void _arb_sin_cos_taylor_naive(mp_ptr ysin, mp_ptr ycos, mp_limb_t * error,
    mp_srcptr x, mp_size_t xn, ulong N);

void _arb_sin_cos_taylor_rs(mp_ptr ysin, mp_ptr ycos,
    mp_limb_t * error, mp_srcptr x, mp_size_t xn, ulong N,
    int sinonly, int alternating);

int _arb_get_mpn_fixed_mod_pi4(mp_ptr w, fmpz_t q, int * octant,
    mp_limb_t * error, const arf_t x, mp_size_t wn);

ARB_INLINE mp_bitcnt_t
_arb_mpn_leading_zeros(mp_srcptr d, mp_size_t n)
{
    mp_limb_t t;
    mp_size_t zero_limbs;
    mp_bitcnt_t bits;

    zero_limbs = 0;

    while (1)
    {
        t = d[n - zero_limbs - 1];

        if (t != 0)
        {
            count_leading_zeros(bits, t);
            return bits + FLINT_BITS * zero_limbs;
        }

        zero_limbs++;

        if (zero_limbs == n)
            return FLINT_BITS * zero_limbs;
    }
}

void _arb_atan_sum_bs_simple(fmpz_t T, fmpz_t Q, mp_bitcnt_t * Qexp,
    const fmpz_t x, mp_bitcnt_t r, slong N);

void _arb_atan_sum_bs_powtab(fmpz_t T, fmpz_t Q, mp_bitcnt_t * Qexp,
    const fmpz_t x, mp_bitcnt_t r, slong N);

void arb_atan_arf_bb(arb_t z, const arf_t x, slong prec);

#ifdef __cplusplus
}
#endif

#endif