Skip to content

Instantly share code, notes, and snippets.

Deep into the code

Fredrik Johansson fredrik-johansson

Deep into the code
  • INRIA & Institut de Mathématiques de Bordeaux
  • Bordeaux, France
View GitHub Profile
View gr.c
Generic Flint-style rings using void pointers + context objects.
* Small code size, fast compilation.
* Possible to pack data efficiently (down to 1 byte / element).
* Plain C, similar interface to existing Flint code.
* Data layouts backwards compatible with most existing Flint types.
* Support all unusual cases in Flint/Arb/Calcium uniformly (error handling,
fredrik-johansson / nmul.c
Created Apr 5, 2021
Some new nmod_poly multiplication code
View nmul.c
#include "flint/nmod_poly.h"
#include "flint/profiler.h"
Multiplication/squaring using Kronecker substitution at 2^b and -2^b.
_nmod_poly_mul_KS2B(mp_ptr res, mp_srcptr op1, slong n1,
mp_srcptr op2, slong n2, nmod_t mod)
fredrik-johansson / matperf.c
Created Mar 22, 2021
Some old matrix profiling code
View matperf.c
#include "flint/fmpz_mat.h"
#include "flint/profiler.h"
#define TIMEIT_PRINT1(__var, __timer, __reps) \
__var = __timer->cpu*0.001/__reps;
#define TIMEIT_REPEAT1(__timer, __reps) \
do \
{ \
slong __timeit_k; \
fredrik-johansson /
Created Jul 28, 2020
Extended Rademacher series
from flint import fmpq, fmpz
from cmath import *
from mpmath import plot
def dedekind_sum(r, k, _cache={}):
key = (r << 24) | k
if key in _cache:
return _cache[key]
if fmpz(r).gcd(k) != 1:
v = None
View illinois.c
#include "acb_dirichlet.h"
/* todo: separate prec, eval_prec... */
acb_dirichlet_zeta_zero_refine_illinois(arb_t res, const arf_t ra, const arf_t rb, slong prec)
arf_t a, b, fa, fb, c, fc, t;
acb_t z;
slong k;
int asign, bsign, csign;
View Arbdemo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View stieltjes.c
Copyright (C) 2018 Fredrik Johansson
This file is part of Arb.
Arb is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License (LGPL) as published
by the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version. See <>.
View pearcey.c
#include <string.h>
#include "acb_calc.h"
#include "flint/profiler.h"
/* the integrand */
f_pearcey(acb_ptr res, const acb_t z, void * param, slong order, slong prec)
acb_t t, u;
fredrik-johansson / trapezoid.c
Created Sep 1, 2016
Trapezoidal integration with error bounds using Arb
View trapezoid.c
Naive implementation of the trapezoidal rule for integration.
(A non-naive implementation would provide adaptivity, etc.)
WARNING: I have not checked carefully that the code is correct.
Let me know if there is a bug.
#include "arb.h"
#include "arb_poly.h"
View arbmpfr.c
#include "arb.h"
#include "acb_hypgeom.h"
void arb_root_ui_algebraic(arb_t res, const arb_t x, ulong k, slong prec);
_arb_pow(arb_t res, const arb_t x, const arb_t y, slong prec)
slong rootlim;