Skip to content

Instantly share code, notes, and snippets.

View fredrik-johansson's full-sized avatar
🕵️‍♂️
Deep into the code

Fredrik Johansson fredrik-johansson

🕵️‍♂️
Deep into the code
View GitHub Profile
@fredrik-johansson
fredrik-johansson / gist:2907555
Created June 10, 2012 22:35
multiplication profiling
fastest algorithm:
0 = classical
1 = karatsuba
2 = KS
3 = SS
speedup = fastest algorithm compared to fmpz_poly_mul
len1 limbs1 len2 limbs2 algorithm speedup
2 2 2 2 0 0.88
struct
{
mp_limb_t p;
mp_limb_t i;
void * sieve;
}
n_primes_iter_t
static __inline__ void
n_primes_iter_init(n_primes_iter_t iter)
@fredrik-johansson
fredrik-johansson / gist:2953559
Created June 19, 2012 11:11
more gcd timings
n, bits, v1 (using norms), v2, (divisibility only)
balanced input, gcd half the length and bits
2 1 100 ns 100 ns
2 8 97 ns 100 ns
2 64 350 ns 350 ns
2 512 1200 ns 1200 ns
2 4096 17 us 17 us
4 1 7500 ns 6900 ns
@fredrik-johansson
fredrik-johansson / gist:2954110
Created June 19, 2012 13:18
even more gcd timings
iter | len(A) bits(A) | len(B) bits(B) | len(gcd) bits(gcd) | time(v1) time(v2)
0 | 2067 -400 | 22902 -476 | 1997 400 | .
1 | 219 -1168 | 200 -253 | 198 -244 | .
2 | 75 -11 | 856 -13 | 5 -7 | .
3 | 66 -65 | 393 -56 | 3 52 | .
4 | 8 -49 | 2 -23 | 1 21 | .
5 | 1 -1 | 5 -3 | 1 1 | .
6 | 897 -234 | 946 -127 | 855 -123 | .
7 | 2 39 | 369 -426 | 1 34 | .
@fredrik-johansson
fredrik-johansson / gist:6102977
Created July 29, 2013 08:38
zeta zero script
#include "fmprb_poly.h"
#include "fmpcb_poly.h"
#include "profiler.h"
/* theta(t) = im(loggamma((2it+1)/4)) - log(pi)/2 * t */
void
theta(fmprb_poly_t res, fmprb_poly_t t, long n, long prec)
{
fmpcb_poly_t s;
@fredrik-johansson
fredrik-johansson / gist:6102988
Created July 29, 2013 08:39
100000 digits of rho_1, components
6765452937407204613554650745954083504455111574058820232709201680655825134702756947759303065800068915637749728442582259594547263221851703323018723592605716264785283434557048000341007015473032283142112505978102150779599814604182774638897063109578138644526029207695354819634240175328787598508191895064487460047684403857270970582657479006701489836385982853696077967332366014037337860359145539785949912675227620416689310313976193203848951545566862338742497191561994169653099173380716673071292453840764824249328409797725358391155304633746043144351175084143953767392083293589773647424915533971828262426489289510574905982286833938424260202695217409456607476368762530528782433505026186687524980994486042161495735238372133012392886973862066166146989221216283296425390502076417012400961634831290565504222260911823786679450662995964255063167669876520079482943334894666562888518455258472704974054610335135309614313334535565037775668790423645156105234953317155624375749161322388524726766140870410927256392229907235884022229666600186055995
@fredrik-johansson
fredrik-johansson / gist:6102998
Created July 29, 2013 08:40
100000 digits of rho_1, decimal approximation
14.1347251417346937904572519835624702707842571156992431756855674601499634298092567649490103931715610127792029715487974367661426914698822545825053632394471377804133812372059705496219558658602005555667258360107737002054109826615075427805174425913062544819786510723049387256297383215774203952157256748093321400349904680343462673144209203773854871413783173563969953654281130796805314916885290678208229804926433866673462332007875876179200560486805435680144442465106559756866590322868651054485944432062407272703209427452221304874872092412385141835146054279015244783383542545334400448793680676169730081900073139385498373621501304516726968389200391762851232128542205239691334258322753351640601697635275637589695376749203361272092599917304270756830879511844534891800863008264831251691127106829105237596179774318151707135453167754951538289378490364747097270199484855322092535743579092261252477365955180169752334612139773160053541259267474557258778014726098308089786007125320875093959979666606753783812148919088649772775544206565320524
@fredrik-johansson
fredrik-johansson / numerical integration
Created October 3, 2013 13:27
example code for numerical integration
#include "fmpcb_calc.h"
#include "profiler.h"
int
sinx(fmpcb_ptr out, const fmpcb_t inp, void * params, long order, long prec)
{
int xlen = FLINT_MIN(2, order);
fmpcb_set(out, inp);
if (xlen > 1)
fmpcb_one(out + 1);
@fredrik-johansson
fredrik-johansson / gist:8198432
Created December 31, 2013 15:33
bsdnt exp(1) benchmark program
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include "nn.h"
#include "test.h"
#include "zz.h"
void
zz_bsplit(zz_t p, zz_t q, ulong a, ulong b)
@fredrik-johansson
fredrik-johansson / gist:8198480
Created December 31, 2013 15:36
mpir/gmp exp(1) benchmark
#include <stdio.h>
#include <math.h>
#include "gmp.h"
#include "time.h"
#define ulong unsigned long
void
mpz_bsplit(mpz_t p, mpz_t q, ulong a, ulong b)
{
if (b - a == 1)