🕵️♂️
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "gr.h" | |
#include "arf.h" | |
#include "mpn_extras.h" | |
#include "crt_helpers.h" | |
typedef struct | |
{ | |
slong sign; | |
slong exp; | |
mp_limb_t d[4]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <math.h> | |
#include "longlong.h" | |
#include "ulong_extras.h" | |
#include "mpn_extras.h" | |
#include "arf.h" | |
#include "arb.h" | |
#include "profiler.h" | |
/* util: print fixed-point number given by n limbs where fracn limbs are fractional. */ | |
void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdint.h> | |
#include "profiler.h" | |
#include "mpn_extras.h" | |
#include "crt_helpers.h" | |
#include "ulong_extras.h" | |
FLINT_FORCE_INLINE mp_limb_t | |
flint_mpn_inline_addmul_1(mp_ptr res, mp_srcptr a, mp_size_t n, mp_limb_t c) | |
{ | |
mp_limb_t hi, lo, cy_limb; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <x86intrin.h> | |
#include "flint.h" | |
#include "longlong.h" | |
#include "ulong_extras.h" | |
#include "mpn_extras.h" | |
#include "profiler.h" | |
#define umul_ppmm_mulx(w1, w0, u, v) \ | |
__asm__ ("mulx\t%3, %q0, %q1" \ | |
: "=r" (w0), "=r" (w1) \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bits euclidean binary euclidean_improved | |
8 3.46e-07 5.05e-07 9.09e-08 | |
16 5.91e-07 7.61e-07 1.65e-07 | |
32 9.65e-07 1.55e-06 2.26e-07 | |
64 5.48e-06 3.89e-06 1.05e-06 | |
128 2.45e-05 1.4e-05 7.41e-06 | |
256 6.06e-05 3.57e-05 1.82e-05 | |
512 0.00015 4.11e-05 | |
1024 0.000459 0.000103 | |
2048 0.00176 0.000248 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from colorsys import hls_to_rgb, rgb_to_hls | |
import math | |
import cmath | |
CLAMP = lambda y: max(0.0, min(y, 1.0)) | |
BLEND = lambda x, y: 0.5*x + 0.5*y | |
DODGE = lambda a, b: a / (1.0 - b + 1/256.0) | |
# gimp color balance algorithm | |
def balance_channel(value, l, shadows, midtones, highlights): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Generic Flint-style rings using void pointers + context objects. | |
todo: write -> print | |
Principles/goals/benefits: | |
* Small code size, fast compilation. | |
* Possible to pack data efficiently (down to 1 byte / element). | |
* Plain C, similar interface to existing Flint code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "flint/nmod_poly.h" | |
#include "flint/profiler.h" | |
/* | |
Multiplication/squaring using Kronecker substitution at 2^b and -2^b. | |
*/ | |
void | |
_nmod_poly_mul_KS2B(mp_ptr res, mp_srcptr op1, slong n1, | |
mp_srcptr op2, slong n2, nmod_t mod) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
NewerOlder