Skip to content

Commit

Permalink
Prepare for merge from Brian.
Browse files Browse the repository at this point in the history
  • Loading branch information
wbhart committed Sep 28, 2018
1 parent 66019c2 commit 27cfbad
Show file tree
Hide file tree
Showing 8 changed files with 564 additions and 54 deletions.
390 changes: 341 additions & 49 deletions INSTALL

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ DISTCLEANFILES = $(BUILT_SOURCES) config.m4 fat.h @gmp_srclinks@
# Tell mpir.h it's building gmp, not an application, used by windows DLL stuff.
AM_CPPFLAGS=-D__GMP_WITHIN_GMP

MPF_OBJECTS = mpf/abs$U.lo mpf/add$U.lo mpf/add_ui$U.lo mpf/ceilfloor$U.lo mpf/clear$U.lo mpf/clears$U.lo mpf/cmp$U.lo mpf/cmp_d$U.lo mpf/cmp_si$U.lo mpf/cmp_ui$U.lo mpf/div$U.lo mpf/div_2exp$U.lo mpf/div_ui$U.lo mpf/dump$U.lo mpf/eq$U.lo mpf/fits_si$U.lo mpf/fits_sint$U.lo mpf/fits_slong$U.lo mpf/fits_sshort$U.lo mpf/fits_ui$U.lo mpf/fits_uint$U.lo mpf/fits_ulong$U.lo mpf/fits_ushort$U.lo mpf/get_d$U.lo mpf/get_d_2exp$U.lo mpf/get_dfl_prec$U.lo mpf/get_prc$U.lo mpf/get_si$U.lo mpf/get_str$U.lo mpf/get_ui$U.lo mpf/init$U.lo mpf/init2$U.lo mpf/inits$U.lo mpf/inp_str$U.lo mpf/int_p$U.lo mpf/iset$U.lo mpf/iset_d$U.lo mpf/iset_si$U.lo mpf/iset_str$U.lo mpf/iset_ui$U.lo mpf/mul$U.lo mpf/mul_2exp$U.lo mpf/mul_ui$U.lo mpf/neg$U.lo mpf/out_str$U.lo mpf/pow_ui$U.lo mpf/random2$U.lo mpf/reldiff$U.lo mpf/rrandomb$U.lo mpf/set$U.lo mpf/set_d$U.lo mpf/set_dfl_prec$U.lo mpf/set_prc$U.lo mpf/set_prc_raw$U.lo mpf/set_q$U.lo mpf/set_si$U.lo mpf/set_str$U.lo mpf/set_ui$U.lo mpf/set_z$U.lo mpf/size$U.lo mpf/sqrt$U.lo mpf/sqrt_ui$U.lo mpf/sub$U.lo mpf/sub_ui$U.lo mpf/swap$U.lo mpf/trunc$U.lo mpf/ui_div$U.lo mpf/ui_sub$U.lo mpf/urandomb$U.lo
MPF_OBJECTS = mpf/abs$U.lo mpf/add$U.lo mpf/add_ui$U.lo mpf/ceilfloor$U.lo mpf/clear$U.lo mpf/clears$U.lo mpf/cmp$U.lo mpf/cmp_d$U.lo mpf/cmp_si$U.lo mpf/cmp_ui$U.lo mpf/cmp_z$U.lo mpf/div$U.lo mpf/div_2exp$U.lo mpf/div_ui$U.lo mpf/dump$U.lo mpf/eq$U.lo mpf/fits_si$U.lo mpf/fits_sint$U.lo mpf/fits_slong$U.lo mpf/fits_sshort$U.lo mpf/fits_ui$U.lo mpf/fits_uint$U.lo mpf/fits_ulong$U.lo mpf/fits_ushort$U.lo mpf/get_d$U.lo mpf/get_d_2exp$U.lo mpf/get_dfl_prec$U.lo mpf/get_prc$U.lo mpf/get_si$U.lo mpf/get_str$U.lo mpf/get_ui$U.lo mpf/init$U.lo mpf/init2$U.lo mpf/inits$U.lo mpf/inp_str$U.lo mpf/int_p$U.lo mpf/iset$U.lo mpf/iset_d$U.lo mpf/iset_si$U.lo mpf/iset_str$U.lo mpf/iset_ui$U.lo mpf/mul$U.lo mpf/mul_2exp$U.lo mpf/mul_ui$U.lo mpf/neg$U.lo mpf/out_str$U.lo mpf/pow_ui$U.lo mpf/random2$U.lo mpf/reldiff$U.lo mpf/rrandomb$U.lo mpf/set$U.lo mpf/set_d$U.lo mpf/set_dfl_prec$U.lo mpf/set_prc$U.lo mpf/set_prc_raw$U.lo mpf/set_q$U.lo mpf/set_si$U.lo mpf/set_str$U.lo mpf/set_ui$U.lo mpf/set_z$U.lo mpf/size$U.lo mpf/sqrt$U.lo mpf/sqrt_ui$U.lo mpf/sub$U.lo mpf/sub_ui$U.lo mpf/swap$U.lo mpf/trunc$U.lo mpf/ui_div$U.lo mpf/ui_sub$U.lo mpf/urandomb$U.lo

FFT_OBJECTS = fft/adjust$U.lo fft/adjust_sqrt2$U.lo fft/butterfly_lshB$U.lo fft/butterfly_rshB$U.lo fft/combine_bits$U.lo fft/div_2expmod_2expp1$U.lo fft/fermat_to_mpz$U.lo fft/fft_mfa_trunc_sqrt2$U.lo fft/fft_mfa_trunc_sqrt2_inner$U.lo fft/fft_negacyclic$U.lo fft/fft_radix2$U.lo fft/fft_trunc$U.lo fft/fft_trunc_sqrt2$U.lo fft/ifft_mfa_trunc_sqrt2$U.lo fft/ifft_negacyclic$U.lo fft/ifft_radix2$U.lo fft/ifft_trunc$U.lo fft/ifft_trunc_sqrt2$U.lo fft/mul_2expmod_2expp1$U.lo fft/mul_fft_main$U.lo fft/mul_mfa_trunc_sqrt2$U.lo fft/mul_trunc_sqrt2$U.lo fft/mulmod_2expp1$U.lo fft/normmod_2expp1$U.lo fft/revbin$U.lo fft/split_bits$U.lo

Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2198,7 +2198,7 @@ gmp_mpn_functions="$extra_functions \
toom_eval_dgr3_pm1 toom_eval_dgr3_pm2 toom_eval_pm1 toom_eval_pm2 \
toom_eval_pm2exp toom_eval_pm2rexp toom_interpolate_16pts \
toom8_sqr_n toom8h_mul toom_couple_handling sb_bdiv_q sb_bdiv_qr \
dc_bdiv_q_n dc_bdiv_q dc_bdiv_qr dc_bdiv_qr_n divexact zero $gmp_mpn_functions_optional"
dc_bdiv_q_n dc_bdiv_q dc_bdiv_qr dc_bdiv_qr_n divexact zero zero_p $gmp_mpn_functions_optional"

# should be able to remove the mulfunc below
define(GMP_MULFUNC_CHOICES,
Expand Down
8 changes: 6 additions & 2 deletions doc/mdate-sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh
# Get modification time of a file or directory and pretty-print it.

scriptversion=2010-08-21.06; # UTC
scriptversion=2015-04-09.19; # UTC

# Copyright (C) 1995-2013 Free Software Foundation, Inc.
# Copyright (C) 1995-2014 Free Software Foundation, Inc.
# written by Ulrich Drepper <[email protected]>, June 1995
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -74,6 +74,10 @@ export LC_ALL
LC_TIME=C
export LC_TIME

# Use UTC to get reproducible result
TZ=UTC
export TZ

# GNU ls changes its time format in response to the TIME_STYLE
# variable. Since we cannot assume 'unset' works, revert this
# variable to its documented default.
Expand Down
46 changes: 46 additions & 0 deletions mpf/cmp_z.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* mpf_cmp_z -- Compare a float with an integer.
Copyright 2015 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
The GNU MP Library is free software; you can redistribute it and/or modify
it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
The GNU MP Library 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 copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */

#include "mpir.h"
#include "gmp-impl.h"

int
mpf_cmp_z (mpf_srcptr u, mpz_srcptr v) __GMP_NOTHROW
{
mpf_t vf;
mp_size_t size;

SIZ (vf) = size = SIZ (v);
EXP (vf) = size = ABS (size);
/* PREC (vf) = size; */
PTR (vf) = PTR (v);

return mpf_cmp (u, vf);
}
34 changes: 34 additions & 0 deletions mpn/generic/zero_p.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* mpn_zero_p (x,xsize) -- Return 1 if X is zero, 0 if it is non-zero.
Copyright 2015 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
The GNU MP Library is free software; you can redistribute it and/or modify
it under the terms of either:
* the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your
option) any later version.
or
* the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any
later version.
or both in parallel, as here.
The GNU MP Library 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 copies of the GNU General Public License and the
GNU Lesser General Public License along with the GNU MP Library. If not,
see https://www.gnu.org/licenses/. */

#define __GMP_FORCE_mpn_zero_p 1

#include "mpir.h"
#include "gmp-impl.h"
2 changes: 1 addition & 1 deletion tests/mpn/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/tests
LDADD = $(top_builddir)/tests/libtests.la $(top_builddir)/libmpir.la

check_PROGRAMS = t-addadd_n t-addsub_n t-aors_1 t-asmtype t-dc_bdiv_q t-dc_bdiv_q_n t-dc_bdiv_qr t-dc_bdiv_qr_n t-dc_div_q t-dc_div_qr t-dc_div_qr_n t-dc_divappr_q t-divebyff t-divebyfobm1 t-divrem_1 t-fat t-gcdext t-get_d t-hgcd t-instrument t-inv_div_q t-inv_div_qr t-inv_div_qr_n t-inv_divappr_q t-inv_divappr_q_n t-invert t-iord_u t-lorrshift1 t-matrix22 t-mp_bases t-mullow_basecase t-mullowhigh t-mulmid t-mulmod_2expm1 t-mulmod_2expp1 t-neg t-perfsqr t-redc_1 t-sb_bdiv_q t-sb_bdiv_qr t-sb_div_q t-sb_div_qr t-sb_divappr_q t-scan t-sizeinbase t-subadd_n t-tdiv_q t-tdiv_qr
check_PROGRAMS = t-addadd_n t-addsub_n t-aors_1 t-asmtype t-dc_bdiv_q t-dc_bdiv_q_n t-dc_bdiv_qr t-dc_bdiv_qr_n t-dc_div_q t-dc_div_qr t-dc_div_qr_n t-dc_divappr_q t-divebyff t-divebyfobm1 t-divrem_1 t-fat t-gcdext t-get_d t-hgcd t-instrument t-inv_div_q t-inv_div_qr t-inv_div_qr_n t-inv_divappr_q t-inv_divappr_q_n t-invert t-iord_u t-logic t-lorrshift1 t-matrix22 t-mp_bases t-mullow_basecase t-mullowhigh t-mulmid t-mulmod_2expm1 t-mulmod_2expp1 t-neg t-perfsqr t-redc_1 t-sb_bdiv_q t-sb_bdiv_qr t-sb_div_q t-sb_div_qr t-sb_divappr_q t-scan t-sizeinbase t-subadd_n t-tdiv_q t-tdiv_qr

if ENABLE_STATIC
if ENABLE_SHARED
Expand Down
134 changes: 134 additions & 0 deletions tests/mpn/t-logic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/* Test mpn_and, mpn_ior, mpn_xor, mpn_andn, mpn_iorn, mpn_xnor, mpn_nand, and
mpn_nior.
Copyright 2011-2013 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/. */


#include <stdlib.h>
#include <stdio.h>

/* Fake native prevalence of the tested operations, so that we actually test
the compiled functions, i.e., the ones which users will reach. The inlined
variants will be tested through tests/mpz/logic.c. */
#define HAVE_NATIVE_mpn_com_n 1
#define HAVE_NATIVE_mpn_and_n 1
#define HAVE_NATIVE_mpn_andn_n 1
#define HAVE_NATIVE_mpn_nand_n 1
#define HAVE_NATIVE_mpn_ior_n 1
#define HAVE_NATIVE_mpn_iorn_n 1
#define HAVE_NATIVE_mpn_nior_n 1
#define HAVE_NATIVE_mpn_xor_n 1
#define HAVE_NATIVE_mpn_xnor_n 1

#include "mpir.h"
#include "gmp-impl.h"
#include "tests.h"


void
check_one (mp_srcptr refp, mp_srcptr rp, mp_srcptr ap, mp_srcptr bp, mp_size_t n, const char *funcname)
{
if (mpn_cmp (refp, rp, n))
{
printf ("ERROR in mpn_%s\n", funcname);
printf ("a: "); mpn_dump (ap, n);
printf ("b: "); mpn_dump (bp, n);
printf ("r: "); mpn_dump (rp, n);
printf ("ref: "); mpn_dump (refp, n);
abort();
}
}

int
main (int argc, char **argv)
{
mpz_t a, b;
mp_ptr ap, bp, rp, refp;
mp_size_t max_n, n, i;
gmp_randstate_ptr rands;
long test, reps = 1000;
TMP_DECL;
TMP_MARK;

tests_start ();
/* TESTS_REPS (reps, argv, argc); */

mpz_inits (a, b, NULL);

rands = RANDS; /* FIXME: not used */

max_n = 100;

rp = TMP_ALLOC_LIMBS (1 + max_n * 8 / GMP_LIMB_BITS);
refp = TMP_ALLOC_LIMBS (1 + max_n * 8 / GMP_LIMB_BITS);

for (test = 0; test < reps; test++)
{
for (i = 1; i <= max_n; i++)
{
mpz_rrandomb (a, rands, i * 8);
mpz_rrandomb (b, rands, i * 8);
mpz_setbit (a, i * 8 - 1);
mpz_setbit (b, i * 8 - 1);
ap = PTR(a);
bp = PTR(b);
n = SIZ(a);

refmpn_and_n (refp, ap, bp, n);
mpn_and_n (rp, ap, bp, n);
check_one (refp, rp, ap, bp, n, "and_n");

refmpn_ior_n (refp, ap, bp, n);
mpn_ior_n (rp, ap, bp, n);
check_one (refp, rp, ap, bp, n, "ior_n");

refmpn_xor_n (refp, ap, bp, n);
mpn_xor_n (rp, ap, bp, n);
check_one (refp, rp, ap, bp, n, "xor_n");

refmpn_andn_n (refp, ap, bp, n);
mpn_andn_n (rp, ap, bp, n);
check_one (refp, rp, ap, bp, n, "andn_n");

refmpn_iorn_n (refp, ap, bp, n);
mpn_iorn_n (rp, ap, bp, n);
check_one (refp, rp, ap, bp, n, "iorn_n");

refmpn_nand_n (refp, ap, bp, n);
mpn_nand_n (rp, ap, bp, n);
check_one (refp, rp, ap, bp, n, "nand_n");

refmpn_nior_n (refp, ap, bp, n);
mpn_nior_n (rp, ap, bp, n);
check_one (refp, rp, ap, bp, n, "nior_n");

refmpn_xnor_n (refp, ap, bp, n);
mpn_xnor_n (rp, ap, bp, n);
check_one (refp, rp, ap, bp, n, "xnor_n");

refmpn_com_n (refp, ap, n);
mpn_com_n (rp, ap, n);
check_one (refp, rp, ap, bp, n, "com");
}
}

TMP_FREE;
mpz_clears (a, b, NULL);
tests_end ();
return 0;
}

0 comments on commit 27cfbad

Please sign in to comment.