### Custom FLINT Configuration Example Source: https://github.com/flintlib/flint/blob/main/INSTALL.md An example of a custom configure command for FLINT, specifying build flags, library paths, and installation prefix. ```bash ./configure \ --enable-assert \ --disable-static \ --with-gmp-include=/home/user1/builds/includes/ \ --with-gmp-lib=/home/user1/builds/lib/ \ --with-mpfr=/usr \ --prefix=/home/user1/installations/ \ CC=clang \ CFLAGS="-Wall -O3 -march=alderlake" ``` -------------------------------- ### Build FLINT from Source Source: https://github.com/flintlib/flint/blob/main/README.md Commands to clone, bootstrap, configure, build, and optionally check, install, or generate examples for FLINT. Assumes GMP and MPFR are installed. ```bash apt install libgmp-dev libmpfr-dev make autoconf libtool-bin ``` ```bash git clone https://github.com/flintlib/flint.git && cd flint ./bootstrap.sh ./configure # ./configure --help for more options make make check # optional make install # optional make examples # optional cd doc && make html && cd .. # optional: documentation ``` -------------------------------- ### Simple Example of fmpq_poly Module Source: https://github.com/flintlib/flint/blob/main/doc/source/examples.md Presents a very simple example demonstrating the usage of the `fmpq_poly` module. ```bash build/examples/fmpq_poly ``` -------------------------------- ### Custom FLINT Build Configuration Source: https://github.com/flintlib/flint/blob/main/doc/source/building.md Example of a custom `configure` command with various options to enable assertions, specific CPU features, specify include/library paths for GMP/MPFR, set the installation prefix, and specify the compiler and flags. ```bash ./configure \ --enable-assert \ --enable-avx2 \ --with-gmp-include=/home/user1/builds/includes/ \ --with-gmp-lib=/home/user1/builds/lib/ \ --with-mpfr=/usr \ --prefix=/home/user1/installations/ \ CC=clang \ CFLAGS="-Wall -O3 -march=alderlake" ``` -------------------------------- ### Configure, Build, and Install FLINT Source: https://github.com/flintlib/flint/blob/main/INSTALL.md Standard procedure to configure, build, and install FLINT after dependencies are met. Running 'make check' is recommended before installation. ```bash ./configure make -j make install ``` -------------------------------- ### Install PkgConfig File Source: https://github.com/flintlib/flint/blob/main/CMakeLists.txt Installs the configured flint.pc file to the pkgconfig directory. ```cmake install(FILES ${CMAKE_CURRENT_BINARY_DIR}/flint.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) ``` -------------------------------- ### Simple Example of fmpz_poly_q Module Source: https://github.com/flintlib/flint/blob/main/doc/source/examples.md Presents a very simple example demonstrating the usage of the `fmpz_poly_q` module. ```bash build/examples/fmpz_poly_q ``` -------------------------------- ### Build FLINT Example Programs Source: https://github.com/flintlib/flint/blob/main/doc/source/examples.md Run this command to build all example programs included with FLINT. The executables will be placed in the `build/examples` directory. ```bash make examples ``` -------------------------------- ### Examples of p-adic Module Usage Source: https://github.com/flintlib/flint/blob/main/doc/source/examples.md Provides examples of how to use various functions within the p-adic module. ```bash build/examples/padic ``` -------------------------------- ### Configure, Build, and Install FLINT Source: https://github.com/flintlib/flint/blob/main/doc/source/building.md Standard procedure for building FLINT from a release using GNU Make. Ensure GMP and MPFR are installed or specify their paths during configuration. ```bash ./configure make -j N make install ``` -------------------------------- ### Install FLINT with CMake on Windows Source: https://github.com/flintlib/flint/blob/main/doc/source/building.md Use this command sequence to install FLINT on Windows using CMake. Ensure you are in a build directory. ```bash mkdir build && cd build cmake .. -DBUILD_SHARED_LIBS=ON cmake --build . --target install ``` -------------------------------- ### Install Autotools for Building from Scratch Source: https://github.com/flintlib/flint/blob/main/INSTALL.md Installs GNU Autotools and related tools required for generating the configuration script when building FLINT from source. ```bash apt install autoconf libtool-bin ``` -------------------------------- ### Add jet_poly example with total derivative Source: https://github.com/flintlib/flint/wiki/Workshop-2025-October Provides an example demonstrating the use of `jet_poly` with total derivatives. Jet polynomials are used in differential algebra and the study of differential equations. ```c #include "flint/jet_poly.h" // Example usage of jet_poly with total derivative // (Specific function call not provided in source, conceptual example) ``` -------------------------------- ### Start, Stop, and Get Clock Time using Cycle Counter Source: https://github.com/flintlib/flint/blob/main/doc/profiler.txt Utilize start_clock, stop_clock, and get_clock for timing based on the processor's cycle counter. Ensure FLINT_CLOCKSPEED is correctly defined in profiler.h. Initialize clocks before use. ```c init_all_clocks(); start_clock(n); // do something stop_clock(n); flint_printf("Time in seconds is %f.3\n", get_clock(n)); ``` -------------------------------- ### arb_zeta_ui_vec Source: https://github.com/flintlib/flint/blob/main/doc/source/arb.md Computes $\zeta(s)$ for *num* consecutive integers starting from *start*. ```APIDOC ## void arb_zeta_ui_vec([arb_ptr](#c.arb_ptr) x, [ulong](flint.md#c.ulong) start, [slong](flint.md#c.slong) num, [slong](flint.md#c.slong) prec) ### Description Computes $\zeta(s)$ at *num* consecutive integers beginning with $s = \mathrm{start} \ge 2$. ### Parameters * **x** ([arb_ptr]): Output array to store the computed zeta values. * **start** ([ulong]): The starting integer for the evaluation. * **num** ([slong]): The number of consecutive integers to evaluate. * **prec** ([slong]): The precision in bits for the computation. ``` -------------------------------- ### radix_add Source: https://github.com/flintlib/flint/blob/main/doc/source/radix.md Adds two natural numbers represented by 'xn' limbs starting at 'x' and 'yn' limbs starting at 'y', storing the result in 'n' limbs starting at 'res'. Returns the carry. ```APIDOC ## ulong radix_add(nn_ptr res, nn_srcptr x, slong xn, nn_srcptr y, slong yn, const radix_t radix) ### Description Adds two natural numbers represented by 'xn' limbs starting at 'x' and 'yn' limbs starting at 'y', storing the result in 'n' limbs starting at 'res'. Returns the carry. ### Parameters - **res** (nn_ptr) - Pointer to the array of limbs for the result. - **x** (nn_srcptr) - Pointer to the first array of limbs. - **xn** (slong) - The number of limbs in the first operand. - **y** (nn_srcptr) - Pointer to the second array of limbs. - **yn** (slong) - The number of limbs in the second operand. - **radix** (const radix_t) - The radix context. ### Returns - **ulong** - The carry value. ``` -------------------------------- ### Demonstrate Floating-Point Wrapper Source: https://github.com/flintlib/flint/blob/main/doc/source/examples_arb.md This program demonstrates calling the floating-point wrapper for arbitrary-precision calculations. It shows examples of computing zeta function values. ```text > build/examples/fpwrap zeta(2) = 1.644934066848226 zeta(0.5 + 123i) = 0.006252861175594465 + 0.08206030514520983i ``` -------------------------------- ### arb_zeta_ui_vec_odd Source: https://github.com/flintlib/flint/blob/main/doc/source/arb.md Computes $\zeta(s)$ for *num* consecutive odd integers starting from *start*. ```APIDOC ## void arb_zeta_ui_vec_odd([arb_ptr](#c.arb_ptr) x, [ulong](flint.md#c.ulong) start, [slong](flint.md#c.slong) num, [slong](flint.md#c.slong) prec) ### Description Computes $\zeta(s)$ at *num* consecutive odd integers beginning with $s = \mathrm{start} \ge 2$. ### Parameters * **x** ([arb_ptr]): Output array to store the computed zeta values. * **start** ([ulong]): The starting odd integer for the evaluation. * **num** ([slong]): The number of consecutive odd integers to evaluate. * **prec** ([slong]): The precision in bits for the computation. ``` -------------------------------- ### Configure PkgConfig File Source: https://github.com/flintlib/flint/blob/main/CMakeLists.txt Configures the flint.pc file using a template and sets installation paths for package management. ```cmake set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "${prefix}") set(includedir "${prefix}/include") set(libdir "${prefix}/${CMAKE_INSTALL_LIBDIR}") set(PACKAGE_NAME ${PROJECT_NAME}) set(PACKAGE_VERSION ${PROJECT_VERSION}) configure_file(flint.pc.in flint.pc @ONLY) ``` -------------------------------- ### arb_zeta_ui_vec_even Source: https://github.com/flintlib/flint/blob/main/doc/source/arb.md Computes $\zeta(s)$ for *num* consecutive even integers starting from *start*. ```APIDOC ## void arb_zeta_ui_vec_even([arb_ptr](#c.arb_ptr) x, [ulong](flint.md#c.ulong) start, [slong](flint.md#c.slong) num, [slong](flint.md#c.slong) prec) ### Description Computes $\zeta(s)$ at *num* consecutive even integers beginning with $s = \mathrm{start} \ge 2$. ### Parameters * **x** ([arb_ptr]): Output array to store the computed zeta values. * **start** ([ulong]): The starting even integer for the evaluation. * **num** ([slong]): The number of consecutive even integers to evaluate. * **prec** ([slong]): The precision in bits for the computation. ``` -------------------------------- ### GR Polynomial Get String Source: https://github.com/flintlib/flint/blob/main/doc/source/gr_poly.md Gets the string representation of a GR polynomial. ```APIDOC ## int gr_poly_get_str(char **res, const gr_poly_t f, const char *x, gr_ctx_t ctx) ### Description Converts the GR polynomial `f` into a string representation. The string `x` might specify the variable name. ### Parameters * **res** (char **) - Pointer to a character pointer that will store the resulting string. * **f** (const gr_poly_t) - The polynomial to convert. * **x** (const char *) - A string parameter, possibly for the variable name. * **ctx** (gr_ctx_t) - The context for the operation. ### Returns An integer indicating success or failure. The allocated string should be freed by the caller. ``` -------------------------------- ### View FLINT Configuration Options Source: https://github.com/flintlib/flint/blob/main/INSTALL.md Displays all available configuration options for the FLINT build process. ```bash ./configure --help ``` -------------------------------- ### Create, Compute, and Print Matrices Source: https://github.com/flintlib/flint/blob/main/doc/source/fmpz_mat.md This C example demonstrates how to initialize two fmpz matrices, populate one with values, compute the square of the first matrix into the second, and then print both matrices. Ensure fmpz and fmpz_mat headers are included. ```c #include "fmpz.h" #include "fmpz_mat.h" int main() { long i, j; fmpz_mat_t A; fmpz_mat_t B; fmpz_mat_init(A, 2, 2); fmpz_mat_init(B, 2, 2); for (i = 0; i < 2; i++) for (j = 0; j < 2; j++) fmpz_set_ui(fmpz_mat_entry(A, i, j), 2*i+j); fmpz_mat_mul(B, A, A); flint_printf("A = \n"); fmpz_mat_print_pretty(A); flint_printf("A^2 = \n"); fmpz_mat_print_pretty(B); fmpz_mat_clear(A); fmpz_mat_clear(B); } ``` -------------------------------- ### Demonstrate Discrete Fourier Transform (DFT) Source: https://github.com/flintlib/flint/blob/main/doc/source/examples_calcium.md Demonstrates the discrete Fourier transform (DFT) in exact arithmetic by verifying the identity x - DFT^-1(DFT(x)) = 0. The program uses a naive O(N^2) summation and precomputes roots of unity. It accepts parameters for vector length, verbosity, input sequence, timing method, and degree limit. ```text > build/examples/dft 4 -input 1 -verbose DFT benchmark, length N = 4 [x] = 1.41421 {a where a = 1.41421 [a^2-2=0]} 1.73205 {a where a = 1.73205 [a^2-3=0]} 2 2.23607 {a where a = 2.23607 [a^2-5=0]} DFT([x]) = 7.38233 {a+b+c+2 where a = 2.23607 [a^2-5=0], b = 1.73205 [b^2-3=0], c = 1.41421 [c^2-2=0]} -0.585786 + 0.504017*I {a*d-b*d+c-2 where a = 2.23607 [a^2-5=0], b = 1.73205 [b^2-3=0], c = 1.41421 [c^2-2=0], d = I [d^2+1=0]} -0.553905 {-a-b+c+2 where a = 2.23607 [a^2-5=0], b = 1.73205 [b^2-3=0], c = 1.41421 [c^2-2=0]} -0.585786 - 0.504017*I {-a*d+b*d+c-2 where a = 2.23607 [a^2-5=0], b = 1.73205 [b^2-3=0], c = 1.41421 [c^2-2=0], d = I [d^2+1=0]} IDFT(DFT([x])) = 1.41421 {c where a = 2.23607 [a^2-5=0], b = 1.73205 [b^2-3=0], c = 1.41421 [c^2-2=0], d = I [d^2+1=0]} 1.73205 {b where a = 2.23607 [a^2-5=0], b = 1.73205 [b^2-3=0], c = 1.41421 [c^2-2=0], d = I [d^2+1=0]} 2 2.23607 {a where a = 2.23607 [a^2-5=0], b = 1.73205 [b^2-3=0], c = 1.41421 [c^2-2=0], d = I [d^2+1=0]} [x] - IDFT(DFT([x])) = 0 (= 0 T_TRUE) 0 (= 0 T_TRUE) 0 (= 0 T_TRUE) 0 (= 0 T_TRUE) cpu/wall(s): 0.009 0.009 virt/peak/res/peak(MB): 36.28 36.28 9.14 9.14 ``` -------------------------------- ### GR Polynomial Get String (Internal) Source: https://github.com/flintlib/flint/blob/main/doc/source/gr_poly.md Internal function to get the string representation of a GR polynomial. ```APIDOC ## int _gr_poly_get_str(char **res, gr_srcptr f, slong len, const char *x, gr_ctx_t ctx) ### Description Internal function to convert a raw GR polynomial `f` of length `len` into a string representation. The string `x` might specify the variable name. ### Parameters * **res** (char **) - Pointer to a character pointer that will store the resulting string. * **f** (gr_srcptr) - Pointer to the raw polynomial data. * **len** (slong) - The length of the polynomial data. * **x** (const char *) - A string parameter, possibly for the variable name. * **ctx** (gr_ctx_t) - The context for the operation. ### Returns An integer indicating success or failure. The allocated string should be freed by the caller. ``` -------------------------------- ### Output of Modular Multiplication Example Source: https://github.com/flintlib/flint/blob/main/doc/source/ulong_extras.md This is the expected output for the modular multiplication example, showing the result of the computation. ```c 12345678*87654321 mod 111111111 is 23456790 ``` -------------------------------- ### Demonstrate Polynomial Factorization Source: https://github.com/flintlib/flint/blob/main/doc/source/examples.md Demonstrates the factorization of a small polynomial. The example uses a hard-coded polynomial but can be modified to read from a file. ```bash build/examples/fmpz_poly_factor_zassenhaus ``` -------------------------------- ### Example of using mag_add_ui and mag_div for bounds Source: https://github.com/flintlib/flint/blob/main/doc/source/mag.md Demonstrates computing an upper bound for (x+1)/(y+1) where x is an upper bound and y is a lower bound. Ensure correct bound types are used for arguments of decreasing functions. ```default mag_add_ui(tmp1, x, 1); mag_add_ui_lower(tmp2, y, 1); mag_div(res, tmp1, tmp2); ``` -------------------------------- ### Example Theta Values Output Source: https://github.com/flintlib/flint/blob/main/doc/source/acb_theta.md This is an example output of theta values computed using the acb_theta library. ```text (1.1803 + 0j) +/- (3.34e-3010, 2.34e-3010j), (0.99254 + 0j) +/- (3.28e-3010, 2.78e-3010j), (0.99254 + 0j) +/- (2.37e-3010, 1.87e-3010j), (0.83463 + 0j) +/- (2.73e-3010, 2.23e-3010j), (0.99254 + 0j) +/- (1.08e-3010, 5.79e-3011j), (0 + 0j) +/- (1.35e-3009, 1.35e-3009j), (0.83463 + 0j) +/- (9.64e-3011, 4.63e-3011j), (0 + 0j) +/- (1.13e-3009, 1.13e-3009j), (0.99254 + 0j) +/- (3.20e-3009, 3.15e-3009j), (0.83463 + 0j) +/- (3.79e-3009, 3.74e-3009j), (0 + 0j) +/- (4.04e-3011, 4.04e-3011j), (0 + 0j) +/- (4.80e-3011, 4.80e-3011j), (0.83463 + 0j) +/- (8.30e-3010, 7.80e-3010j), (0 + 0j) +/- (5.18e-3009, 5.18e-3009j), (0 + 0j) +/- (1.00e-3011, 1.00e-3011j), (-6.1135e-3020 + 0j) +/- (2.80e-3010, 2.80e-3010j) ``` -------------------------------- ### FMPZ Ring Implementation Example Source: https://github.com/flintlib/flint/blob/main/doc/source/gr_implementing.md An extract from `gr/fmpz.c` showing the implementation of addition for the FMPZ ring and the structure of its method table and context initializer. ```c /* Some methods */ ... int _gr_fmpz_add(fmpz_t res, const fmpz_t x, const fmpz_t y, const gr_ctx_t ctx) { fmpz_add(res, x, y); return GR_SUCCESS; } ... ``` ```c /* The method table */ int _fmpz_methods_initialized = 0; gr_static_method_table _fmpz_methods; gr_method_tab_input _fmpz_methods_input[] = { {GR_METHOD_CTX_IS_RING, (gr_funcptr) gr_generic_ctx_predicate_true}, ... {GR_METHOD_INIT, (gr_funcptr) _gr_fmpz_init}, {GR_METHOD_CLEAR, (gr_funcptr) _gr_fmpz_clear}, ... {GR_METHOD_ADD_FMPZ, (gr_funcptr) _gr_fmpz_add}, ... {0, (gr_funcptr) NULL}, }; /* Context object initializer */ void gr_ctx_init_fmpz(gr_ctx_t ctx) { ctx->which_ring = GR_CTX_FMPZ; ctx->sizeof_elem = sizeof(fmpz); ctx->size_limit = WORD_MAX; ctx->methods = _fmpz_methods; if (!_fmpz_methods_initialized) { gr_method_tab_init(_fmpz_methods, _fmpz_methods_input); _fmpz_methods_initialized = 1; } } ``` -------------------------------- ### Start and Stop Timer Source: https://github.com/flintlib/flint/blob/main/doc/source/profiler.md Starts and stops a timeit timer. Useful for measuring elapsed time for specific code blocks. ```default timeit_t t0; timeit_start(t0); // do stuff, take some time timeit_stop(t0); timeit_print(t0, 1); // only one repetition was done ``` -------------------------------- ### qsieve_init_poly_first Source: https://github.com/flintlib/flint/blob/main/doc/source/qsieve.md Initializes A = q0 * A0, where q0 is a non-factor base prime. It precomputes data for generating different B values using the grey code formula and combines data for A0 factors with q0 to obtain data for A factors. It also calculates sieve offsets for all factor base primes for the first polynomial. ```APIDOC ## qsieve_init_poly_first ### Description Initializes the value of A = q0 * A0, where q0 is a non-factor base prime. Precomputes the data necessary for generating different B values using the grey code formula. Combines the data calculated for the factors of A0 along with the parameter q0 to obtain data as for factors of A. It also calculates the sieve offset for all the factor base primes, for the first polynomial. ### Signature `void qsieve_init_poly_first(qs_t qs_inf)` ``` -------------------------------- ### Install FLINT Dependencies on Ubuntu Source: https://github.com/flintlib/flint/blob/main/INSTALL.md Installs the necessary development libraries for GMP, MPFR, and the GNU Make build system on Ubuntu. ```bash apt install libgmp-dev libmpfr-dev make ``` -------------------------------- ### Example of using mag_add_ui_lower and mag_div_lower for bounds Source: https://github.com/flintlib/flint/blob/main/doc/source/mag.md Demonstrates computing a lower bound for (x+1)/(y+1) where x is a lower bound and y is an upper bound. Ensure correct bound types are used for arguments of decreasing functions. ```default mag_add_ui_lower(tmp1, x, 1); mag_add_ui(tmp2, y, 1); mag_div_lower(res, tmp1, tmp2); ``` -------------------------------- ### Initialize Precomputation with Full Lookup Table Source: https://github.com/flintlib/flint/blob/main/doc/source/dlog.md Initializes precomputation by creating a complete lookup table of size $n$. If the modulus is small, an element-indexed array is used; otherwise, a sorted array with binary search is employed. This is suitable for small moduli or when $n$ is manageable. ```c void dlog_precomp_small_init(dlog_precomp_t pre, ulong a, ulong mod, ulong n, ulong num) ``` -------------------------------- ### Pretty polynomial examples Source: https://github.com/flintlib/flint/blob/main/doc/source/fmpz_poly.md Examples of the pretty string representation for polynomials. This format includes coefficients, variable names, and exponents for non-zero terms. ```default 5*x^3+7*x-4 x^2+3 -x^4+2*x-1 x+1 5 ``` -------------------------------- ### Initialize and Use nfloat Context Source: https://github.com/flintlib/flint/blob/main/doc/source/nfloat.md Demonstrates initializing an nfloat context with a specific precision, performing arithmetic operations, and printing the result. Ensure the precision matches the nfloat type used. Uses GR_MUST_SUCCEED for error checking. ```c gr_ctx_t ctx; nfloat256_t x, y; nfloat_ctx_init(ctx, 256, 0); /* precision must match the type */ gr_init(x, ctx); gr_init(y, ctx); gr_ctx_println(ctx); GR_MUST_SUCCEED(gr_set_ui(x, 5, ctx)); GR_MUST_SUCCEED(gr_set_ui(y, 7, ctx)); GR_MUST_SUCCEED(gr_div(x, x, y, ctx)); GR_MUST_SUCCEED(gr_println(x, ctx)); gr_clear(x, ctx); gr_clear(y, ctx); gr_ctx_clear(ctx); ``` -------------------------------- ### Basic FLINT Usage Example Source: https://github.com/flintlib/flint/blob/main/doc/source/building.md A simple C program demonstrating the initialization, computation of pi, printing, and clearing of an `arb_t` type using FLINT. Ensure necessary headers are included and linked. ```c #include "flint/flint.h" #include "flint/arb.h" int main() { arb_t x; arb_init(x); arb_const_pi(x, 50 * 3.33); arb_printn(x, 50, 0); flint_printf("\n"); flint_printf("Computed with FLINT-%s\n", flint_version); arb_clear(x); } ``` -------------------------------- ### Call Flint Functions from C Source: https://github.com/flintlib/flint/blob/main/doc/source/arb_fpwrap.md Example C program demonstrating the usage of `arb_fpwrap_double_zeta` and `arb_fpwrap_cdouble_zeta`. Note that this example does not include error handling based on return flags. ```c #include "arb_fpwrap.h" int main() { double x, y; complex_double cx, cy; int flags = 0; /* default options */ x = 2.0; cx.real = 0.5; cx.imag = 123.0; arb_fpwrap_double_zeta(&y, x, flags); arb_fpwrap_cdouble_zeta(&cy, cx, flags); printf("zeta(%g) = %.16g\n", x, y); printf("zeta(%g + %gi) = %.16g + %.16gi\n", cx.real, cx.imag, cy.real, cy.imag); flint_cleanup(); return 0; } ``` -------------------------------- ### radix_neg Source: https://github.com/flintlib/flint/blob/main/doc/source/radix.md Sets the 'n' limbs starting at 'res' to the B's complement negation of the 'n' limbs starting at 'x' (i.e., (-x) mod B^n), returning the borrow. ```APIDOC ## ulong radix_neg(nn_ptr res, nn_srcptr x, slong n, const radix_t radix) ### Description Sets *(res, n)* to the $B$:s complement negation of *(x, n)*, i.e., $(-x) mod B^n$, returning borrow. ### Parameters - **res** (nn_ptr) - Pointer to the array of limbs for the result. - **x** (nn_srcptr) - Pointer to the array of limbs to negate. - **n** (slong) - The number of limbs. - **radix** (const radix_t) - The radix context. ### Returns - **ulong** - The borrow value. ``` -------------------------------- ### Initialize fq_nmod context with minimal weight polynomial Source: https://github.com/flintlib/flint/blob/main/doc/source/fq_nmod.md Initializes the finite field context for prime p and extension degree d, specifically choosing a modulus polynomial with the minimum number of non-zero terms for optimized arithmetic. Assumes p is prime and var is a valid string. ```c void fq_nmod_ctx_init_minimal_weight_ui(fq_nmod_ctx_t ctx, ulong p, slong d, const char *var) ``` -------------------------------- ### Get read-only MPN representation of fmpz Source: https://github.com/flintlib/flint/blob/main/doc/source/fmpz_extras.md Macro to get a read-only pointer to the limbs (MPN representation) of an fmpz_t integer. Handles small values by copying to a temporary buffer. ```c #define FMPZ_GET_MPN_READONLY(zsign, zn, zptr, ztmp, zv) ``` -------------------------------- ### Example Output of Print Functions Source: https://github.com/flintlib/flint/blob/main/doc/source/qqbar.md Demonstrates the output format of qqbar_print, qqbar_printn, and qqbar_printnd for various special values and numbers. ```default deg 1 [0, 1] 0 deg 1 [-1, 1] 1.00000 deg 2 [1, 0, 1] 1.00000*I deg 2 [-1, -1, 1] [1.61803398874989484820458683436563811772 +/- 6.00e-39] deg 4 [25, 0, 2, 0, 1] [1.4142135623730950488016887242096980786 +/- 8.67e-38] + [-1.732050807568877293527446341505872367 +/- 1.10e-37]*I 0 1.00000 1.00000*I 1.61803 1.41421 - 1.73205*I 0 (deg 1) 1.00000 (deg 1) 1.00000*I (deg 2) 1.61803 (deg 2) 1.41421 - 1.73205*I (deg 4) ``` -------------------------------- ### Set and get fmpz_mod_mpoly Source: https://github.com/flintlib/flint/wiki/Workshop-2025-October Adds functions to set and get the internal representation of `fmpz_mod_mpoly` (multi-precision polynomials over FLINT's modular integers). These are utility functions for data manipulation. ```c #include "flint/fmpz_mod_mpoly.h" void fmpz_mod_mpoly_set_fmpz_mpoly(fmpz_mod_mpoly_t res, const fmpz_mod_mpoly_t poly); void fmpz_mod_mpoly_get_fmpz_mpoly(fmpz_mod_mpoly_t res, const fmpz_mod_mpoly_t poly); ``` -------------------------------- ### Run Full Test Suite Source: https://github.com/flintlib/flint/blob/main/doc/source/building.md Execute the complete FLINT test suite to verify library functionality. Use `make -j N` for parallel testing to speed up the process. ```bash make check ``` ```bash make -j check ``` -------------------------------- ### qadic_ctx_init Source: https://github.com/flintlib/flint/blob/main/doc/source/qadic.md Initializes a context for unramified extensions over p-adic numbers. It sets up the prime, extension degree, variable name, and printing mode. The defining polynomial is chosen as a Conway polynomial if possible, otherwise a random sparse polynomial. It also precomputes powers of p. ```APIDOC ## void qadic_ctx_init(qadic_ctx_t ctx, const fmpz_t p, slong d, slong min, slong max, const char *var, enum padic_print_mode mode) ### Description Initialises the context `ctx` with prime $p$, extension degree $d$, variable name `var` and printing mode `mode`. The defining polynomial is chosen as a Conway polynomial if possible and otherwise as a random sparse polynomial. Stores powers of $p$ with exponents between `min` (inclusive) and `max` exclusive. Assumes that `min` is at most `max`. Assumes that $p$ is a prime. Assumes that the string `var` is a null-terminated string of length at least one. Assumes that the printing mode is one of `PADIC_TERSE`, `PADIC_SERIES`, or `PADIC_VAL_UNIT`. This function also carries out some relevant precomputation for arithmetic in $\mathbf{Q}_p / (p^N)$ such as powers of $p$ close to $p^N$. ``` -------------------------------- ### Get the sign of an fmpz integer in an array Source: https://github.com/flintlib/flint/blob/main/doc/source/fmpz.md Get the sign of the third integer in the 'myarr' array. A pointer to an fmpz can be used in place of an fmpz_t, so 'myarr + 2' points to the third element. ```c int sign = fmpz_sgn(myarr + 2); ``` -------------------------------- ### arb_zeta_ui_vec_borwein Source: https://github.com/flintlib/flint/blob/main/doc/source/arb.md Evaluates the Riemann zeta function $\zeta(s)$ at multiple consecutive integers *s* starting from *start* with a given *step*. It utilizes Borwein's formula for efficient multi-evaluation and is suitable for large *s* up to the precision. ```APIDOC ## void arb_zeta_ui_vec_borwein([arb_ptr](#c.arb_ptr) z, [ulong](flint.md#c.ulong) start, [slong](flint.md#c.slong) num, [ulong](flint.md#c.ulong) step, [slong](flint.md#c.slong) prec) ### Description Evaluates $\zeta(s)$ at $\mathrm{num}$ consecutive integers *s* beginning with *start* and proceeding in increments of *step*. Uses Borwein’s formula, implemented to support fast multi-evaluation. Requires $\mathrm{start} \ge 2$. For efficiency, the largest *s* should be at most about as large as *prec*. Arguments approaching *LONG_MAX* will cause overflows. ### Parameters * **z** ([arb_ptr]): Output array to store the computed zeta values. * **start** ([ulong]): The starting integer for the evaluation. * **num** ([slong]): The number of consecutive integers to evaluate. * **step** ([ulong]): The increment between consecutive integers. * **prec** ([slong]): The precision in bits for the computation. ``` -------------------------------- ### Sample Output: Custom Parameters Source: https://github.com/flintlib/flint/blob/main/doc/source/examples_arb.md Demonstrates running the logistic map with custom initial values for x_0 (0.1), r (3.99), and a higher precision requirement (30 digits). The output shows the progression of precision attempts and the final result. ```text > build/examples/logistic 1234 0.1 3.99 30 Trying prec=64 bits...ran out of accuracy at step 0 Trying prec=128 bits...ran out of accuracy at step 10 Trying prec=256 bits...ran out of accuracy at step 76 Trying prec=512 bits...ran out of accuracy at step 205 Trying prec=1024 bits...ran out of accuracy at step 461 Trying prec=2048 bits...ran out of accuracy at step 974 Trying prec=4096 bits...success! cpu/wall(s): 0.009 0.009 x_1234 = [0.256445391958651410579677945635 +/- 3.92e-31] ``` -------------------------------- ### Serialize and Deserialize Vector Example Source: https://github.com/flintlib/flint/blob/main/doc/source/arb.md Demonstrates serializing a vector of arb_t values to a file and then deserializing them back. This example omits error handling for brevity. Ensure whitespace separation between values when writing. ```c fp = fopen("data.txt", "w"); for (i = 0; i < n; i++) { arb_dump_file(fp, vec + i); fprintf(fp, "\n"); // or any whitespace character } fclose(fp); fp = fopen("data.txt", "r"); for (i = 0; i < n; i++) { arb_load_file(vec + i, fp); } fclose(fp); ``` -------------------------------- ### Demonstrate Integer Chinese Remainder Code Source: https://github.com/flintlib/flint/blob/main/doc/source/examples.md Demonstrates the integer Chinese Remainder code. This example builds up a given integer from its value modulo various primes. ```bash build/examples/crt 10382788 ``` -------------------------------- ### fmpz_mpoly_get_term_coeff_si Source: https://github.com/flintlib/flint/blob/main/doc/source/fmpz_mpoly.md Gets the coefficient of a term as an slong. ```APIDOC ## fmpz_mpoly_get_term_coeff_si ### Description Returns the coefficient of the term at index `i` of polynomial `poly` as an slong. This function assumes the coefficient fits within an slong. ### Method `slong fmpz_mpoly_get_term_coeff_si(const fmpz_mpoly_t poly, slong i, const fmpz_mpoly_ctx_t ctx)` ### Parameters - **poly** (fmpz_mpoly_t) - The polynomial. - **i** (slong) - The index of the term. - **ctx** (fmpz_mpoly_ctx_t) - The polynomial context. ### Return Value The coefficient of the term at index `i` as an slong. ``` -------------------------------- ### Initialize Preconditioned Modular Polynomial Multiplication (Method) Source: https://github.com/flintlib/flint/blob/main/doc/source/nmod_poly.md Initializes precomputed data for modular polynomial multiplication using a specified method. The input polynomials 'a', 'd', and 'dinv' must remain valid as long as the precomputed structure is in use. ```c void nmod_poly_mulmod_precond_init_method(nmod_poly_mulmod_precond_t precond, const nmod_poly_t a, const nmod_poly_t d, const nmod_poly_t dinv, int method) ``` -------------------------------- ### fmpz_mpoly_get_term_coeff_ui Source: https://github.com/flintlib/flint/blob/main/doc/source/fmpz_mpoly.md Gets the coefficient of a term as a ulong. ```APIDOC ## fmpz_mpoly_get_term_coeff_ui ### Description Returns the coefficient of the term at index `i` of polynomial `A` as a ulong. This function assumes the coefficient fits within a ulong. ### Method `ulong fmpz_mpoly_get_term_coeff_ui(const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx)` ### Parameters - **A** (fmpz_mpoly_t) - The polynomial. - **i** (slong) - The index of the term. - **ctx** (fmpz_mpoly_ctx_t) - The polynomial context. ### Return Value The coefficient of the term at index `i` as a ulong. ``` -------------------------------- ### Compute Modular Multiplication with Precomputed Inverse Source: https://github.com/flintlib/flint/blob/main/doc/source/ulong_extras.md This example demonstrates how to compute (a * b) mod n using a precomputed inverse for efficiency. Ensure 'ulong_extras.h' is included and the inverse is precomputed using n_preinvert_limb. ```c #include #include "ulong_extras.h" int main() { ulong r, a, b, n, ninv; a = UWORD(12345678); b = UWORD(87654321); n = UWORD(111111111); ninv = n_preinvert_limb(n); r = n_mulmod2_preinv(a, b, n, ninv); flint_printf("%wu*%wu mod %wu is %wu\n", a, b, n, r); } ``` -------------------------------- ### gr_ctx_init_fq Source: https://github.com/flintlib/flint/blob/main/doc/source/gr_domains.md Initializes the context to the finite field Fq where q = p^d. ```APIDOC ## gr_ctx_init_fq ### Description Initializes the context to the finite field Fq where q = p^d. It is assumed (not checked) that p is prime. The variable name var can be NULL to use a default. ### Method void ### Parameters - **ctx** (gr_ctx_t) - The context to initialize. - **p** (fmpz_t) - The prime base of the field. - **d** (slong) - The exponent determining the size of the field. - **var** (const char *) - The variable name for the field elements. ``` -------------------------------- ### fmpz_mpoly_get_term_coeff_fmpz Source: https://github.com/flintlib/flint/blob/main/doc/source/fmpz_mpoly.md Gets the coefficient of a term as an fmpz. ```APIDOC ## fmpz_mpoly_get_term_coeff_fmpz ### Description Sets the fmpz `c` to the coefficient of the term at index `i` of polynomial `A`. ### Method `void fmpz_mpoly_get_term_coeff_fmpz(fmpz_t c, const fmpz_mpoly_t A, slong i, const fmpz_mpoly_ctx_t ctx)` ### Parameters - **c** (fmpz_t) - The output fmpz to store the coefficient. - **A** (fmpz_mpoly_t) - The polynomial. - **i** (slong) - The index of the term. - **ctx** (fmpz_mpoly_ctx_t) - The polynomial context. ``` -------------------------------- ### Initialize DFT precomputation scheme Source: https://github.com/flintlib/flint/blob/main/doc/source/acb_dft.md Initializes a fast DFT scheme of length len, automatically choosing algorithms based on len's factorization. The length len is stored as pre->n. ```c void acb_dft_precomp_init([acb_dft_pre_t](#c.acb_dft_pre_t) pre, [slong](flint.md#c.slong) len, [slong](flint.md#c.slong) prec) ``` -------------------------------- ### gr_ctx_gen_name Source: https://github.com/flintlib/flint/blob/main/doc/source/gr.md Gets the name of a generator at a specific index. ```APIDOC ## gr_ctx_gen_name ### Description Get the name of the generator of index *i*. The returned buffer must be freed with [`flint_free()`](flint.md#c.flint_free). ### Signature `int gr_ctx_gen_name(char **name, slong i, gr_ctx_t ctx)` ``` -------------------------------- ### gr_ctx_ngens Source: https://github.com/flintlib/flint/blob/main/doc/source/gr.md Gets the number of generators associated with the context. ```APIDOC ## gr_ctx_ngens ### Description Get the number of generators. ### Signature `int gr_ctx_ngens(slong *ngens, gr_ctx_t ctx)` ``` -------------------------------- ### Example Output for Square Computation Source: https://github.com/flintlib/flint/blob/main/doc/source/fmpz.md This snippet shows the expected output when the C code for computing the square of 7 is executed. ```text 7^2 = 49 ```