Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ check_c_source_compiles([[#include <gmp.h>
#endif
void main(){};]] LONG_LONG_LIMB)

if(LONG_LONG_LIMB)
set(ULONG "unsigned long long int")
set(SLONG "long long int")
else()
set(ULONG "unsigned long int")
set(SLONG "long int")
endif()

# Populate headers
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/CMake/cmake_config.h.in
Expand Down
11 changes: 9 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -926,8 +926,15 @@ fi
################################################################################

FLINT_CHECK_GMP_H(6,2,1)
FLINT_GMP_LONG_LONG_LIMB([gmpcompat_h_in="gmpcompat-longlong.h.in"],
[gmpcompat_h_in="gmpcompat.h.in"])
FLINT_GMP_LONG_LONG_LIMB([SLONG="long long int"
ULONG="unsigned long long int"
gmpcompat_h_in="gmpcompat-longlong.h.in"],
[SLONG="long int"
ULONG="unsigned long int"
gmpcompat_h_in="gmpcompat.h.in"])

AC_SUBST(SLONG)
AC_SUBST(ULONG)

AC_CONFIG_LINKS([src/gmpcompat.h:src/$gmpcompat_h_in],[],[gmpcompat_h_in="$gmpcompat_h_in"])
AC_SUBST(GMPCOMPAT_H_IN, $gmpcompat_h_in)
Expand Down
28 changes: 11 additions & 17 deletions doc/source/flint.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,31 +149,25 @@ Allocation Functions
Random Numbers
------------------

.. type:: flint_rand_s
.. type:: flint_rand_struct

A structure holding the state of a flint pseudo random number generator.
A structure holding the state of the FLINT pseudo random number generator.

.. type:: flint_rand_t

An array of length 1 of :type:`flint_rand_s`.
An array of length 1 of :type:`flint_rand_struct`.

.. function:: flint_rand_s * flint_rand_alloc(void)
.. function:: void flint_rand_init(flint_rand_t state)
void flint_rand_clear(flint_rand_t state)

Allocates a ``flint_rand_t`` object to be used like a heap-allocated
``flint_rand_t`` in external libraries.
The random state is not initialised.
Initialises or clears a :type:`flint_rand_t`:.

.. function:: void flint_rand_free(flint_rand_s * state)
.. function:: flint_rand_struct * flint_rand_alloc(void)
void flint_rand_free(flint_rand_s * state)

Frees a random state object as allocated using :func:`flint_rand_alloc`.

.. function:: void flint_randinit(flint_rand_t state)

Initialize a :type:`flint_rand_t`.

.. function:: void flint_randclear(flint_rand_t state)

Free all memory allocated by :func:`flint_rand_init`.
Allocates or frees a memory block to be used as a heap-allocated
:type:`flint_rand_t`:, such as use in external libraries. The random state
is not initialised, nor is it cleared.

Thread functions
-----------------------
Expand Down
2 changes: 1 addition & 1 deletion examples/radix.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int main(void)
flint_free(b);
fmpz_mod_ctx_clear(ctx);

flint_randclear(state);
FLINT_TEST_CLEANUP(state);

return 0;
}
2 changes: 1 addition & 1 deletion src/acb_dft/profile/p-convol.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int main(int argc, char *argv[])
if (out == CSV)
flint_printf("# %-12s, %7s, %7s, %7s\n","name", "prec", "len", "factor", "time");

flint_randinit(state);
flint_rand_init(state);

for (j = 0; j < nj; j++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/acb_dft/profile/p-dft.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int main(int argc, char *argv[])
if (out == CSV)
flint_printf("# %-12s, %7s, %7s, %7s\n","name", "prec", "len", "factor", "time");

flint_randinit(state);
flint_rand_init(state);

for (j = 0; j < nj; j++)
{
Expand Down
4 changes: 2 additions & 2 deletions src/acb_dirichlet/profile/p-vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int main(int argc, char *argv[])

nr = 20;

flint_randinit(state);
flint_rand_init(state);

rand = flint_malloc(nr * sizeof(ulong));

Expand Down Expand Up @@ -207,7 +207,7 @@ int main(int argc, char *argv[])
}

flint_free(rand);
flint_randclear(state);
flint_rand_clear(state);

flint_cleanup();
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/acb_theta/profile/p-ql_a0.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main(int argc, char * argv[])
pstep = atol(argv[2]);
pmax = atol(argv[3]);

flint_randinit(state);
flint_rand_init(state);

/* Profile with different number of steps on reduced input */
for (prec = pstep; prec <= pmax; prec += pstep)
Expand Down Expand Up @@ -114,7 +114,7 @@ int main(int argc, char * argv[])
arb_clear(test);
}

flint_randclear(state);
flint_rand_clear(state);
flint_cleanup();
return 0;
}
4 changes: 2 additions & 2 deletions src/acb_theta/profile/p-ql_a0_split.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, char * argv[])
cstep = atol(argv[3]);
cmax = atol(argv[4]);

flint_randinit(state);
flint_rand_init(state);

/* Profile with different splittings on reduced input */
for (c = cstep; c <= cmax; c += cstep)
Expand Down Expand Up @@ -143,7 +143,7 @@ int main(int argc, char * argv[])
arb_clear(test);
}

flint_randclear(state);
flint_rand_clear(state);
flint_cleanup();
return 0;
}
4 changes: 2 additions & 2 deletions src/acb_theta/profile/p-ql_a0_steps.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main(int argc, char * argv[])
pstep = atol(argv[2]);
pmax = atol(argv[3]);

flint_randinit(state);
flint_rand_init(state);

/* Profile with different number of steps on reduced input */
for (prec = pstep; prec <= pmax; prec += pstep)
Expand Down Expand Up @@ -127,7 +127,7 @@ int main(int argc, char * argv[])
arb_clear(test);
}

flint_randclear(state);
flint_rand_clear(state);
flint_cleanup();
return 0;
}
4 changes: 2 additions & 2 deletions src/acb_theta/profile/p-siegel_reduce.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int main(int argc, char * argv[])
dstep = atol(argv[4]);
dmax = atol(argv[5]);

flint_randinit(state);
flint_rand_init(state);
acb_mat_init(tau, g, g);
acb_mat_init(w, g, g);
arb_init(r);
Expand Down Expand Up @@ -76,7 +76,7 @@ int main(int argc, char * argv[])
}
}

flint_randclear(state);
flint_rand_clear(state);
acb_mat_clear(tau);
acb_mat_clear(w);
arb_clear(r);
Expand Down
8 changes: 4 additions & 4 deletions src/acb_theta/ql_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ acb_theta_ql_all_red(acb_ptr th, acb_srcptr z, const acb_mat_t tau, slong prec)
int hasz = !_acb_vec_is_zero(z, g);
int res;

flint_randinit(state);
flint_rand_init(state);
d = _arb_vec_init(n);
d0 = _arb_vec_init(n);
acb_mat_init(tau_mid, g, g);
Expand Down Expand Up @@ -219,7 +219,7 @@ acb_theta_ql_all_red(acb_ptr th, acb_srcptr z, const acb_mat_t tau, slong prec)
}
}

flint_randclear(state);
flint_rand_clear(state);
_arb_vec_clear(d, n);
_arb_vec_clear(d0, n);
acb_mat_clear(tau_mid);
Expand Down Expand Up @@ -247,7 +247,7 @@ acb_theta_ql_all_sqr_red(acb_ptr th2, acb_srcptr z, const acb_mat_t tau, slong p
slong j, k;
int res;

flint_randinit(state);
flint_rand_init(state);
acb_mat_init(w, g, g);
x = _acb_vec_init(g);
d = _arb_vec_init(n);
Expand Down Expand Up @@ -288,7 +288,7 @@ acb_theta_ql_all_sqr_red(acb_ptr th2, acb_srcptr z, const acb_mat_t tau, slong p
acb_theta_ql_dupl(th2, th, th, d0, d0, g, prec);
}

flint_randclear(state);
flint_rand_clear(state);
acb_mat_clear(w);
_acb_vec_clear(x, g);
_arb_vec_clear(d, n);
Expand Down
4 changes: 2 additions & 2 deletions src/acb_theta/transform_sqrtdet.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ acb_theta_transform_sqrtdet(acb_t res, const acb_mat_t tau, slong prec)
slong k, j, nb_neg, nb_pos;
int success = 0;

flint_randinit(state);
flint_rand_init(state);
acb_mat_init(A, g, g);
acb_mat_init(B, g, g);
acb_mat_init(C, g, g);
Expand Down Expand Up @@ -169,7 +169,7 @@ acb_theta_transform_sqrtdet(acb_t res, const acb_mat_t tau, slong prec)
acb_union(res, res, z, prec);
}

flint_randclear(state);
flint_rand_clear(state);
acb_mat_clear(A);
acb_mat_clear(B);
acb_mat_clear(C);
Expand Down
4 changes: 2 additions & 2 deletions src/dlog/profile/p-precomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int main(int argc, char *argv[])
flint_abort();
}

flint_randinit(state);
flint_rand_init(state);
for (nbits = 10; nbits <= 40; nbits += 5)
{

Expand Down Expand Up @@ -170,7 +170,7 @@ int main(int argc, char *argv[])
}
}
}
flint_randclear(state);
flint_rand_clear(state);
flint_cleanup();
flint_printf("PASS\n");
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/dlog/profile/p-vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int argc, char *argv[])
p = flint_malloc(np * sizeof(nmod_t));
a = flint_malloc(np * sizeof(ulong));

flint_randinit(state);
flint_rand_init(state);

if (argc < 2)
out = LOG;
Expand Down Expand Up @@ -137,7 +137,7 @@ int main(int argc, char *argv[])

flint_free(p);
flint_free(a);
flint_randclear(state);
flint_rand_clear(state);
flint_cleanup();
flint_printf("PASS\n");
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/dlog/rho.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dlog_rho(const dlog_rho_t t, ulong b)
ulong x[2], e[2], f[2], g;
flint_rand_t state;

flint_randinit(state);
flint_rand_init(state);

do {

Expand Down Expand Up @@ -105,7 +105,7 @@ dlog_rho(const dlog_rho_t t, ulong b)

} while (e[0] == e[1] && f[0] == f[1]);

flint_randclear(state);
flint_rand_clear(state);

/* e = f * log(b) */
e[0] = nmod_sub(e[0], e[1], t->n);
Expand Down
2 changes: 1 addition & 1 deletion src/fft/profile/p-mul_mfa_truncate_sqrt2.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ main(void)
flint_free(i1);
}

flint_randclear(state);
flint_rand_clear(state);

flint_printf("done\n");
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/fft/profile/p-mul_truncate_sqrt2.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ main(void)
flint_free(i1);
}

flint_randclear(state);
flint_rand_clear(state);

flint_printf("done\n");
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/fft/tune/tune-fft.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ main(void)

flint_printf("#define FFT_MULMOD_2EXPP1_CUTOFF %wd\n\n", ((mp_limb_t) 1 << best_d)*best_w/(2*FLINT_BITS));

flint_randclear(state);
flint_rand_clear(state);

flint_printf("#endif\n");
return 0;
Expand Down
4 changes: 2 additions & 2 deletions src/fft_small/profile/p-nmod_poly_divrem.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int main(void)
ulong an, bn, n, i, nreps;
ulong nmax = 1000000;

flint_randinit(state);
flint_rand_init(state);
mpn_ctx_init(R, UWORD(0x0003f00000000001));

flint_set_num_threads(8);
Expand Down Expand Up @@ -224,7 +224,7 @@ int main(void)
}

mpn_ctx_clear(R);
flint_randclear(state);
flint_rand_clear(state);

return 0;
}
4 changes: 2 additions & 2 deletions src/fft_small/profile/p-nmod_poly_mul.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ int main(void)
ulong an, bn, zn, i, nreps;
ulong zn_max = 10000000;

flint_randinit(state);
flint_rand_init(state);
mpn_ctx_init(R, UWORD(0x0003f00000000001));

//flint_set_num_threads(8);
Expand Down Expand Up @@ -181,7 +181,7 @@ int main(void)
}

mpn_ctx_clear(R);
flint_randclear(state);
flint_rand_clear(state);

return 0;
}
Loading