acf.h
#include <flint/acf.h>An acf_t is a complex floating-point number a + bi whose real and imaginary parts are arf_t numbers, without error bounds. It is the complex counterpart of arf_t and is used where complex arithmetic is needed but error bounds are not: in approximate (non-rigorous) algorithms such as the floating-point stage of eigenvalue or root computations that are certified afterwards, and as the element type of the generic ring of complex floating-point numbers (gr_ctx_init_complex_float_acf).
Addition, subtraction and multiplication are correctly rounded in each part, like the arf operations; division, square root and dot products are only approximate. All functions allow aliasing of inputs and outputs.
Types#
An acf_struct has two arf_struct fields, the real and imaginary parts. acf_t is an array of one acf_struct, passed by reference; acf_ptr and acf_srcptr point to arrays.
Function versions of acf_realref and acf_imagref, for language bindings.
Memory management#
void _acf_vec_clear(acf_ptr v, slong n)Allocate a vector of n numbers initialised to zero, and free such a vector.
slong acf_allocated_bytes(const acf_t x)Returns the number of bytes allocated on the heap by x, excluding sizeof(acf_struct).
Basic operations#
Set z to x, respectively -x, exactly.
int acf_set_round(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd)int acf_neg_round(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd)Set res to x, respectively -x, with both parts rounded to prec bits in the direction rnd. Bit 0 of the return value is the inexact flag of the real part and bit 1 that of the imaginary part.
Returns whether x and y are equal (both parts equal in the sense of arf_equal).
void acf_get_mag(mag_t res, const acf_t x)Sets res to an upper bound for |x|.
void acf_printd(const acf_t x, slong n)Prints x as a + b*I with n significant decimal digits for each part (see arf_printd).
void acf_randtest(acf_t x, flint_rand_t state, slong bits, slong mag_bits)Sets both parts of x to random numbers as arf_randtest does.
Arithmetic#
Set res to x + y, x - y, respectively xy, with each part correctly rounded to prec bits in the direction rnd. Bit 0 of the return value is the inexact flag of the real part and bit 1 that of the imaginary part.
Approximate arithmetic#
The following functions are not correctly rounded: rnd is the direction of the final rounding, but the intermediate roundings are not specified and no error bound is given.
void acf_approx_inv(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd)Set res to an approximation of 1/x, respectively x/y. A real or purely imaginary divisor is handled by real divisions of the parts; otherwise 1/(a + bi) = (a - bi)/(a^2 + b^2) is used, with a^2 + b^2 computed by arf_sosq.
void acf_approx_sqrt(acf_t res, const acf_t x, slong prec, arf_rnd_t rnd)Sets res to an approximation of the principal square root of x.
void acf_approx_dot(acf_t res, const acf_t initial, int subtract, acf_srcptr x, slong xstep, acf_srcptr y, slong ystep, slong len, slong prec, arf_rnd_t rnd)Sets res to an approximation of s + (-1)^{\mathit{subtract}} \sum_{i=0}^{\mathit{len}-1} x_i y_i, where s is initial (0 if NULL), with the conventions of arb_dot, using a fixed-point accumulation like that of acb_approx_dot.
The FLINT team, “acf.h (module overview),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/acf/index.html (generated 2026-10-20).
@misc{flint-doc-acf-index,
author = {{The FLINT team}},
title = {{acf.h (module overview)}},
howpublished = {FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev},
year = {2026},
url = {https://flintlib.org/doc/acf/index.html},
note = {Generated 2026-10-20}
}