/* Copyright 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU MP Library test suite.
The GNU MP Library test suite is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
The GNU MP Library test suite is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
the GNU MP Library test suite. If not, see https://www.gnu.org/licenses/. */
int
main (int argc, char *argv[])
{ staticchar usage[] = "\
usage: t-rand [function nbits]\n\
function is one of z, f\n\
nbits is number of bits\n\ ";
gmp_randstate_t rstate;
mpz_t z, rz;
mpf_t f, rf; enum { Z, F } func = Z; int nbits = 1; int verify_mode_flag = 1; int i; struct rt *a;
if (argc > 1)
{ if (argc < 3)
{
fputs (usage, stderr); exit (1);
}
verify_mode_flag = 0; if (*argv[1] == 'z')
func = Z; if (*argv[1] == 'f')
func = F;
nbits = atoi (argv[2]);
}
mpz_init (rz);
if (verify_mode_flag)
{ #ifdef VERBOSE
printf ("%s: verifying random numbers: ", argv[0]); #endif
/* Test z. */
mpz_init (z); for (a = zarr; a->s != NULL; a++)
{
gmp_randinit (rstate, GMP_RAND_ALG_LC, a->nbits); if (gmp_errno != GMP_ERROR_NONE) exit (1);
gmp_randseed_ui (rstate, SEED);
for (i = 0; i < ENTS; i++)
{
mpz_urandomb (rz, rstate, a->nbits);
mpz_set_str (z, a->s[i], BASE); if (mpz_cmp (z, rz) != 0)
{
printf ("z%d: ", a->nbits);
mpz_out_str (stdout, BASE, rz);
printf (" should be ");
mpz_out_str (stdout, BASE, z);
puts (""); exit (1);
}
} #ifdef VERBOSE
printf ("z%d ", a->nbits); #endif
gmp_randclear (rstate);
}
mpz_clear (z);
/* Test f. */ for (a = farr; a->s != NULL; a++)
{
gmp_randinit (rstate, GMP_RAND_ALG_LC, a->nbits); if (gmp_errno != GMP_ERROR_NONE) exit (1);
gmp_randseed_ui (rstate, SEED);
switch (func)
{ case Z:
printf ("char *z%d[ENTS] = {", nbits); for (i = 0; i < ENTS; i++)
{
mpz_urandomb (rz, rstate, nbits);
printf ("\"");
mpz_out_str (stdout, BASE, rz);
printf ("\""); if (i != ENTS - 1)
printf (", ");
}
printf ("};\n");
printf (" {z%d, %d},\n", nbits, nbits); break;
case F:
printf ("char *f%d[ENTS] = {", nbits);
mpf_init2 (rf, nbits); for (i = 0; i < ENTS; i++)
{
mpf_urandomb (rf, rstate, nbits);
printf ("\"");
mpf_out_str (stdout, BASE, nbits, rf);
printf ("\""); if (i != ENTS - 1)
printf (", ");
}
printf ("};\n");
printf (" {f%d, %d},\n", nbits, nbits);
mpf_clear (rf); break;
default: exit (1);
}
gmp_randclear (rstate);
}
mpz_clear (rz);
return 0;
}
Messung V0.5 in Prozent
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.13Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-04-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.