From 11da511c784eca003deb90c23570f0873954e0de Mon Sep 17 00:00:00 2001 From: Duncan Wilkie Date: Sat, 18 Nov 2023 06:11:09 -0600 Subject: Initial commit. --- ic-reals-6.3/tests/Makefile | 170 +++++++++++++++++++++++++++++++++++++++ ic-reals-6.3/tests/README | 33 ++++++++ ic-reals-6.3/tests/abs_R.c | 48 +++++++++++ ic-reals-6.3/tests/acos_R.c | 41 ++++++++++ ic-reals-6.3/tests/acosh_R.c | 41 ++++++++++ ic-reals-6.3/tests/asin_R.c | 41 ++++++++++ ic-reals-6.3/tests/asinh_R.c | 41 ++++++++++ ic-reals-6.3/tests/atan_R.c | 42 ++++++++++ ic-reals-6.3/tests/atanh_R.c | 41 ++++++++++ ic-reals-6.3/tests/cos_Q.c | 30 +++++++ ic-reals-6.3/tests/cos_R.c | 41 ++++++++++ ic-reals-6.3/tests/cosh_R.c | 41 ++++++++++ ic-reals-6.3/tests/exp_QInt.c | 32 ++++++++ ic-reals-6.3/tests/exp_R.c | 41 ++++++++++ ic-reals-6.3/tests/iter.c | 60 ++++++++++++++ ic-reals-6.3/tests/iterate.c | 60 ++++++++++++++ ic-reals-6.3/tests/log_R.c | 39 +++++++++ ic-reals-6.3/tests/pi.c | 20 +++++ ic-reals-6.3/tests/pow_R_R.c | 41 ++++++++++ ic-reals-6.3/tests/sin_R.c | 41 ++++++++++ ic-reals-6.3/tests/sinh_R.c | 46 +++++++++++ ic-reals-6.3/tests/sqrt_QZ.c | 31 +++++++ ic-reals-6.3/tests/sqrt_R.c | 42 ++++++++++ ic-reals-6.3/tests/t0.c | 37 +++++++++ ic-reals-6.3/tests/t01.c | 67 +++++++++++++++ ic-reals-6.3/tests/t1.c | 53 ++++++++++++ ic-reals-6.3/tests/t2.c | 42 ++++++++++ ic-reals-6.3/tests/t3.c | 26 ++++++ ic-reals-6.3/tests/tan_QZ.c | 30 +++++++ ic-reals-6.3/tests/tan_R.c | 64 +++++++++++++++ ic-reals-6.3/tests/tan_R_digit.c | 55 +++++++++++++ ic-reals-6.3/tests/tanh_R.c | 41 ++++++++++ 32 files changed, 1478 insertions(+) create mode 100644 ic-reals-6.3/tests/Makefile create mode 100644 ic-reals-6.3/tests/README create mode 100644 ic-reals-6.3/tests/abs_R.c create mode 100644 ic-reals-6.3/tests/acos_R.c create mode 100644 ic-reals-6.3/tests/acosh_R.c create mode 100644 ic-reals-6.3/tests/asin_R.c create mode 100644 ic-reals-6.3/tests/asinh_R.c create mode 100644 ic-reals-6.3/tests/atan_R.c create mode 100644 ic-reals-6.3/tests/atanh_R.c create mode 100644 ic-reals-6.3/tests/cos_Q.c create mode 100644 ic-reals-6.3/tests/cos_R.c create mode 100644 ic-reals-6.3/tests/cosh_R.c create mode 100644 ic-reals-6.3/tests/exp_QInt.c create mode 100644 ic-reals-6.3/tests/exp_R.c create mode 100644 ic-reals-6.3/tests/iter.c create mode 100644 ic-reals-6.3/tests/iterate.c create mode 100644 ic-reals-6.3/tests/log_R.c create mode 100644 ic-reals-6.3/tests/pi.c create mode 100644 ic-reals-6.3/tests/pow_R_R.c create mode 100644 ic-reals-6.3/tests/sin_R.c create mode 100644 ic-reals-6.3/tests/sinh_R.c create mode 100644 ic-reals-6.3/tests/sqrt_QZ.c create mode 100644 ic-reals-6.3/tests/sqrt_R.c create mode 100644 ic-reals-6.3/tests/t0.c create mode 100644 ic-reals-6.3/tests/t01.c create mode 100644 ic-reals-6.3/tests/t1.c create mode 100644 ic-reals-6.3/tests/t2.c create mode 100644 ic-reals-6.3/tests/t3.c create mode 100644 ic-reals-6.3/tests/tan_QZ.c create mode 100644 ic-reals-6.3/tests/tan_R.c create mode 100644 ic-reals-6.3/tests/tan_R_digit.c create mode 100644 ic-reals-6.3/tests/tanh_R.c (limited to 'ic-reals-6.3/tests') diff --git a/ic-reals-6.3/tests/Makefile b/ic-reals-6.3/tests/Makefile new file mode 100644 index 0000000..fb22742 --- /dev/null +++ b/ic-reals-6.3/tests/Makefile @@ -0,0 +1,170 @@ +GMPDIR=$(HOME)/Desktop/gmp-4.3.1 + +LIB = \ + ../real.a \ + $(GMPDIR)/.libs/libgmp.a \ + -lm + +INCLUDE = \ + -I$(GMPDIR) \ + -I$(GMPDIR)/mpn \ + -I.. + +# CFLAGS = $(INCLUDE) -g -pg +CFLAGS = $(INCLUDE) -g +CC = gcc + +tan_R : tan_R.o $(LIB) + $(CC) tan_R.o $(LIB) -o tan_R + +tan_R_digit : tan_R_digit.o $(LIB) + $(CC) tan_R_digit.o $(LIB) -o tan_R_digit + +asin_R : asin_R.o $(LIB) + $(CC) asin_R.o $(LIB) -o asin_R + +acos_R : acos_R.o $(LIB) + $(CC) acos_R.o $(LIB) -o acos_R + +atan_R : atan_R.o $(LIB) + $(CC) atan_R.o $(LIB) -o atan_R + +atanh_R : atanh_R.o $(LIB) + $(CC) atanh_R.o $(LIB) -o atanh_R + +acosh_R : acosh_R.o $(LIB) + $(CC) acosh_R.o $(LIB) -o acosh_R + +asinh_R : asinh_R.o $(LIB) + $(CC) asinh_R.o $(LIB) -o asinh_R + +pow_R_R : pow_R_R.o $(LIB) + $(CC) pow_R_R.o $(LIB) -o pow_R_R + +tan_QZ : tan_QZ.o $(LIB) + $(CC) tan_QZ.o $(LIB) -o tan_QZ + +cos_Q : cos_Q.o $(LIB) + $(CC) cos_Q.o $(LIB) -o cos_Q + +tanh_R : tanh_R.o $(LIB) + $(CC) tanh_R.o $(LIB) -o tanh_R + +sinh_R : sinh_R.o $(LIB) + $(CC) sinh_R.o $(LIB) -o sinh_R + +cosh_R : cosh_R.o $(LIB) + $(CC) cosh_R.o $(LIB) -o cosh_R + +sqrt_R : sqrt_R.o $(LIB) + $(CC) sqrt_R.o $(LIB) -o sqrt_R + +sqrt_QZ : sqrt_QZ.o $(LIB) + $(CC) sqrt_QZ.o $(LIB) -o sqrt_QZ + +abs_R : abs_R.o $(LIB) + $(CC) abs_R.o $(LIB) -o abs_R + +log_R : log_R.o $(LIB) + $(CC) log_R.o $(LIB) -o log_R + +exp_R : exp_R.o $(LIB) + $(CC) exp_R.o $(LIB) -o exp_R + +exp_QInt : exp_QInt.o $(LIB) + $(CC) exp_QInt.o $(LIB) -o exp_QInt + +sin_R : sin_R.o $(LIB) + $(CC) sin_R.o $(LIB) -o sin_R + +cos_R : cos_R.o $(LIB) + $(CC) cos_R.o $(LIB) -o cos_R + +pi : pi.o $(LIB) + $(CC) pi.o $(LIB) -o pi + +iter : iter.o $(LIB) + $(CC) iter.o $(LIB) -o iter + +t01 : t01.o $(LIB) + $(CC) t01.o $(LIB) -o t01 + +t0 : t0.o $(LIB) + $(CC) t0.o $(LIB) -o t0 + +t1 : t1.o $(LIB) + $(CC) t1.o $(LIB) -o t1 + +t2 : t2.o $(LIB) + $(CC) t2.o $(LIB) -o t2 + +t3 : t3.o $(LIB) + $(CC) t3.o $(LIB) -o t3 + +iterate : iterate.o $(LIB) + $(CC) iterate.o $(LIB) -o iterate + +$(OBJS): ../real.h ../real-impl.h + +TARGETS=\ + abs_R \ + acosh_R \ + asinh_R \ + acos_R \ + asin_R \ + atan_R \ + atanh_R \ + cos_Q \ + cos_R \ + cosh_R \ + exp_R \ + log_R \ + pi \ + pow_R_R \ + sin_R \ + sinh_R \ + sqrt_QZ \ + sqrt_R \ + tan_QZ \ + tan_R \ + tan_R_digit \ + tanh_R \ + t01 \ + t0 \ + t1 \ + t2 \ + iter \ + iterate + +all : $(TARGETS) + +clean: + rm -f abs_R abs_R.o + rm -f acosh_R acosh_R.o + rm -f asinh_R asinh_R.o + rm -f atan_R atan_R.o + rm -f acos_R acos_R.o + rm -f asin_R asin_R.o + rm -f atanh_R atanh_R.o + rm -f cos_Q cos_Q.o + rm -f cos_R cos_R.o + rm -f cosh_R cosh_R.o + rm -f exp_R exp_R.o + rm -f log_R log_R.o + rm -f pi pi.o + rm -f pow_R_R pow_R_R.o + rm -f sin_R sin_R.o + rm -f sinh_R sinh_R.o + rm -f sqrt_QZ sqrt_QZ.o + rm -f sqrt_R sqrt_R.o + rm -f tan_QZ tan_QZ.o + rm -f tan_R tan_R.o + rm -f tan_R_digit tan_R_digit.o + rm -f tanh_R tanh_R.o + rm -f t01 t01.o + rm -f t0 t0.o + rm -f t1 t1.o + rm -f t2 t2.o + rm -f iterate iterate.o + rm -f iter iter.o + rm -f gmon.out diff --git a/ic-reals-6.3/tests/README b/ic-reals-6.3/tests/README new file mode 100644 index 0000000..992cead --- /dev/null +++ b/ic-reals-6.3/tests/README @@ -0,0 +1,33 @@ +Oct 22 1999 + +This is a collection of programs which exercise portions of the library. +They should not necessarily been viewed as examples of good programming +style. + +To compile any one of these tests you will need to change the +variable GMPDIR in Makefile. + +In many, though not all cases, the arguments to the functions are as +follows: + +tan_R + +where the first 5 arguments define a real number which is passed to +tan_R and is the number of (binary) digits to be forced and +printed (base 10) from the resulting real. + +The real is the followed by the list of digits coded as a +characteristic pair (where ) is a number of digits followed +by the vector continuation /. The characteristic pair denotes the +number base 2^. + +The argument is as follows: + +0 -> SZERO +1 -> SINF +2 -> SPOS +3 -> SNEG +4 -> SIGN_UNKN + +Lindsay + diff --git a/ic-reals-6.3/tests/abs_R.c b/ic-reals-6.3/tests/abs_R.c new file mode 100644 index 0000000..eda26ba --- /dev/null +++ b/ic-reals-6.3/tests/abs_R.c @@ -0,0 +1,48 @@ +#include +#include "real.h" +#include + +/* + * Tests the abs_R when applied to a rational a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = tan_R(y); + + y = abs_R(x); + + printf("tan x="); + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + + printf("abs (tan x)="); + print_R(y); + printf("\n"); + printf("tan(x)=%f\n", tan(f)); +} diff --git a/ic-reals-6.3/tests/acos_R.c b/ic-reals-6.3/tests/acos_R.c new file mode 100644 index 0000000..5059135 --- /dev/null +++ b/ic-reals-6.3/tests/acos_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests the acos_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = acos_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("acos(x)=%f\n", acos(f)); +} diff --git a/ic-reals-6.3/tests/acosh_R.c b/ic-reals-6.3/tests/acosh_R.c new file mode 100644 index 0000000..f5ff9eb --- /dev/null +++ b/ic-reals-6.3/tests/acosh_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests the arccosh_R when applied to a rational a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = acosh_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("acosh(x)=%f\n", acosh(f)); +} diff --git a/ic-reals-6.3/tests/asin_R.c b/ic-reals-6.3/tests/asin_R.c new file mode 100644 index 0000000..e980a84 --- /dev/null +++ b/ic-reals-6.3/tests/asin_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests the asin_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = asin_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("asin(x)=%f\n", asin(f)); +} diff --git a/ic-reals-6.3/tests/asinh_R.c b/ic-reals-6.3/tests/asinh_R.c new file mode 100644 index 0000000..859c61e --- /dev/null +++ b/ic-reals-6.3/tests/asinh_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests the asinh_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = asinh_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("asinh(x)=%f\n", asinh(f)); +} diff --git a/ic-reals-6.3/tests/atan_R.c b/ic-reals-6.3/tests/atan_R.c new file mode 100644 index 0000000..1d0dd09 --- /dev/null +++ b/ic-reals-6.3/tests/atan_R.c @@ -0,0 +1,42 @@ +#include +#include "real.h" +#include + +/* + * Tests the atan_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + debugTrace(1); + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = atan_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("atan(x)=%f\n", atan(f)); +} diff --git a/ic-reals-6.3/tests/atanh_R.c b/ic-reals-6.3/tests/atanh_R.c new file mode 100644 index 0000000..8261029 --- /dev/null +++ b/ic-reals-6.3/tests/atanh_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests atanh_R when applied a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = atanh_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("atanh(x)=%f\n", atanh(f)); +} diff --git a/ic-reals-6.3/tests/cos_Q.c b/ic-reals-6.3/tests/cos_Q.c new file mode 100644 index 0000000..99d13c7 --- /dev/null +++ b/ic-reals-6.3/tests/cos_Q.c @@ -0,0 +1,30 @@ +#include +#include "real.h" +#include + +/* + * Tests the cos_QZ when applied a rational + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + mpz_t a, b; + + MyName = argv[0]; + + if (argc != 4) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + mpz_init_set_str(a, argv[1], 10); + mpz_init_set_str(b, argv[2], 10); + + x = cos_QZ(a, b); + + print_R_Dec(x, atoi(argv[3])); + printf("\n"); +} diff --git a/ic-reals-6.3/tests/cos_R.c b/ic-reals-6.3/tests/cos_R.c new file mode 100644 index 0000000..f6b28e5 --- /dev/null +++ b/ic-reals-6.3/tests/cos_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests the cos_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = cos_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("cos(x)=%f\n", cos(f)); +} diff --git a/ic-reals-6.3/tests/cosh_R.c b/ic-reals-6.3/tests/cosh_R.c new file mode 100644 index 0000000..64dc1ba --- /dev/null +++ b/ic-reals-6.3/tests/cosh_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests the cosh_R when applied a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = cosh_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("cosh(x)=%f\n", cosh(f)); +} diff --git a/ic-reals-6.3/tests/exp_QInt.c b/ic-reals-6.3/tests/exp_QInt.c new file mode 100644 index 0000000..3424a99 --- /dev/null +++ b/ic-reals-6.3/tests/exp_QInt.c @@ -0,0 +1,32 @@ +#include +#include "real.h" +#include + +/* + * Tests the exp_QInt when applied to an int rational. + */ +main(int argc, char *argv[]) +{ + Real x, y; + int a, b; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 4) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + a = atoi(argv[1]); + b = atoi(argv[2]); + + x = exp_QInt(a, b); + + print_R_Dec(x, atoi(argv[3])); + printf("\n"); + printf("exp(x)=%f\n", exp(f)); +} diff --git a/ic-reals-6.3/tests/exp_R.c b/ic-reals-6.3/tests/exp_R.c new file mode 100644 index 0000000..2d9a469 --- /dev/null +++ b/ic-reals-6.3/tests/exp_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests the exp_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = exp_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("exp(x)=%f\n", exp(f)); +} diff --git a/ic-reals-6.3/tests/iter.c b/ic-reals-6.3/tests/iter.c new file mode 100644 index 0000000..2c4d295 --- /dev/null +++ b/ic-reals-6.3/tests/iter.c @@ -0,0 +1,60 @@ +#include +#include "real.h" +#include "real-impl.h" +#include + +/* + * Reinhold's iter example from the user manual. + */ +Real eps, eps2; +Real delay(Real (*)(Real), Real); + +main(int argc, char *argv[]) +{ + Real x, y, z; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + Real iter(Real); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + debugTrace(1); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + + eps = vector_Int(1, 100000000); + eps2 = vector_Int(1, 200000000); + + x = iter(y); + print_R_Dec(x, atoi(argv[6])); + printf("\n"); +} + +Real +iter(Real x) +{ + Real y, d; + static int doneInit = 0; + void delayCls(); + + y = div_R_Int(x, 2); + d = abs_R(sub_R_R(x, y)); + return realIf(2, + lt_R_R(d, eps), y, + gt_R_R(d, eps2), realDelay((Delay_Fun) iter, (Delay_Arg) y)); +} diff --git a/ic-reals-6.3/tests/iterate.c b/ic-reals-6.3/tests/iterate.c new file mode 100644 index 0000000..89c3f07 --- /dev/null +++ b/ic-reals-6.3/tests/iterate.c @@ -0,0 +1,60 @@ +#include +#include "real.h" +#include "real-impl.h" + +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + Real iterate(Real, int); + int niters; + + MyName = argv[0]; + + if (argc != 8) { + fprintf(stderr, "%s \n", + MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + niters = atoi(argv[6]); + + print_R_Dec(y, atoi(argv[7])); + printf("\n"); + + x = iterate(y, niters); + + print_R_Dec(x, atoi(argv[7])); + printf("\n"); +} + +/* + * Iterates the function f(x) = 4x(1-x) + */ +Real +iterate(Real x, int n) +{ + Real p, q, r; + + if (n > 0) { + r = iterate(x, n - 1); + p = mul_R_Int(r, 4); + q = sub_Int_R(1, r); + r = mul_R_R(p, q); + if (n > 15) + r = makeStream(r); + return r; + } + else + return x; +} diff --git a/ic-reals-6.3/tests/log_R.c b/ic-reals-6.3/tests/log_R.c new file mode 100644 index 0000000..5db96d9 --- /dev/null +++ b/ic-reals-6.3/tests/log_R.c @@ -0,0 +1,39 @@ +#include +#include "real.h" +#include + +/* + * Tests the log_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + f = realToDouble(y); + printf("\nx=%f\n",f); + + x = log_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\nlog(x)=%f\n", log(f)); +} diff --git a/ic-reals-6.3/tests/pi.c b/ic-reals-6.3/tests/pi.c new file mode 100644 index 0000000..655e35c --- /dev/null +++ b/ic-reals-6.3/tests/pi.c @@ -0,0 +1,20 @@ +#include +#include "real.h" + +/* + * Prints pi (in base 10) to the specified number of digits. + */ +main(int argc, char *argv[]) +{ + MyName = argv[0]; + + if (argc != 2) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + print_R_Dec(Pi, atoi(argv[1])); + printf("\n"); +} diff --git a/ic-reals-6.3/tests/pow_R_R.c b/ic-reals-6.3/tests/pow_R_R.c new file mode 100644 index 0000000..a702c83 --- /dev/null +++ b/ic-reals-6.3/tests/pow_R_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests the pow_R_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = pow_R_R(y, y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("pow(x,x)=%f\n", pow(f,f)); +} diff --git a/ic-reals-6.3/tests/sin_R.c b/ic-reals-6.3/tests/sin_R.c new file mode 100644 index 0000000..042784a --- /dev/null +++ b/ic-reals-6.3/tests/sin_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests the sin_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = sin_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("sin(x)=%f\n", sin(f)); +} diff --git a/ic-reals-6.3/tests/sinh_R.c b/ic-reals-6.3/tests/sinh_R.c new file mode 100644 index 0000000..36f0a42 --- /dev/null +++ b/ic-reals-6.3/tests/sinh_R.c @@ -0,0 +1,46 @@ +#include +#include "real.h" +#include + +/* + * Tests the sinh_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + +#ifdef LATER + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ +#endif + + y = vector_Int(atoi(argv[4]), atoi(argv[5])); + + print_R_Dec(y, atoi(argv[6])); + + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = sinh_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("sinh(x)=%f\n", sinh(f)); +} diff --git a/ic-reals-6.3/tests/sqrt_QZ.c b/ic-reals-6.3/tests/sqrt_QZ.c new file mode 100644 index 0000000..610d580 --- /dev/null +++ b/ic-reals-6.3/tests/sqrt_QZ.c @@ -0,0 +1,31 @@ +#include +#include "real.h" +#include + +/* + * Tests the sqrt_QZ when applied to a rational. + */ +main(int argc, char *argv[]) +{ + Real x, y; + Real sqrt_QZ(mpz_t, mpz_t); + double f; + mpz_t a, b; + + MyName = argv[0]; + + if (argc != 4) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + mpz_init_set_str(a, argv[1], 10); + mpz_init_set_str(b, argv[2], 10); + + x = sqrt_QZ(a, b); + + print_R_Dec(x, atoi(argv[3])); + printf("\n"); +} diff --git a/ic-reals-6.3/tests/sqrt_R.c b/ic-reals-6.3/tests/sqrt_R.c new file mode 100644 index 0000000..32361f8 --- /dev/null +++ b/ic-reals-6.3/tests/sqrt_R.c @@ -0,0 +1,42 @@ +#include +#include "real.h" +#include + +/* + * Tests the sqrt_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + debugTrace(1); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = sqrt_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("sqrt(x)=%f\n", sqrt(fabs(f))); +} diff --git a/ic-reals-6.3/tests/t0.c b/ic-reals-6.3/tests/t0.c new file mode 100644 index 0000000..4b1ca8b --- /dev/null +++ b/ic-reals-6.3/tests/t0.c @@ -0,0 +1,37 @@ +#include +#include "real.h" +#include + +/* + * Random test + */ +main(int argc, char *argv[]) +{ + Real x, y, z; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + + x = matrix_Int(y, 1, 2, 3, 4); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); +} diff --git a/ic-reals-6.3/tests/t01.c b/ic-reals-6.3/tests/t01.c new file mode 100644 index 0000000..e3cfd8e --- /dev/null +++ b/ic-reals-6.3/tests/t01.c @@ -0,0 +1,67 @@ +#include +#include "real.h" +#include + +/* + * Random test + */ +main(int argc, char *argv[]) +{ + Real u, v, w, x, y, z; + Bool a, b, c, d; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + +/* + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } +*/ + + if (argc != 4) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + +#ifdef JUNK + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ +#endif + + y = makeStream(vector_Int(atoi(argv[1]), atoi(argv[2]))); + print_R_Dec(y, atoi(argv[3])); + printf("\n"); + + y = makeStream(y); + + u = makeStream(vector_Int(-1, 2)); + u = makeStream(mul_R_Int(u, 1)); + v = makeStream(vector_Int(1, 3)); + v = makeStream(mul_R_Int(v, 1)); + w = makeStream(vector_Int(1, 4)); + w = makeStream(mul_R_Int(w, 1)); + x = makeStream(vector_Int(1, 5)); + + a = and_B_B(gt_R_QInt(y, 0, 5), lt_R_QInt(y, 2, 5)); + b = and_B_B(gt_R_QInt(y, 1, 5), lt_R_QInt(y, 3, 5)); + c = and_B_B(gt_R_QInt(y, 2, 5), lt_R_QInt(y, 4, 5)); + d = and_B_B(gt_R_QInt(y, 3, 5), lt_R_QInt(y, 5, 5)); + + z = realIf(4, a, u, b, v, c, w, d, x); + print_R_Dec(z, atoi(argv[3])); + printf("\n"); + + z = add_R_R(z, z); + + print_R_Dec(z, atoi(argv[3])); + printf("\n"); +} diff --git a/ic-reals-6.3/tests/t1.c b/ic-reals-6.3/tests/t1.c new file mode 100644 index 0000000..6652c7f --- /dev/null +++ b/ic-reals-6.3/tests/t1.c @@ -0,0 +1,53 @@ +#include +#include "real.h" +#include + +/* + * Tests the cos_R when applied to a rational a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y, z; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + +#ifdef NOT_NOW + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ +#endif + + y = vector_Int(atoi(argv[4]), atoi(argv[5])); + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + + f = realToDouble(y); + printf("x=%f\n",f); + + x = cos_R(y); + x = mul_R_R(x, x); + + z = sin_R(y); + z = mul_R_R(z, z); + + x = add_R_R(x, z); + x = sqrt_R(x); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("t1(x)=%f\n", sqrt(cos(f)*cos(f) + sin(f)*sin(f))); +} diff --git a/ic-reals-6.3/tests/t2.c b/ic-reals-6.3/tests/t2.c new file mode 100644 index 0000000..a41eed0 --- /dev/null +++ b/ic-reals-6.3/tests/t2.c @@ -0,0 +1,42 @@ +#include +#include "real.h" +#include + +/* + * computes log(exp(x)) + */ +main(int argc, char *argv[]) +{ + Real x, y, z; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + + f = realToDouble(y); + printf("x=%f\n",f); + + x = exp_R(y); + x = log_R(x); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("t2(x)=%f\n", log(exp(f))); +} diff --git a/ic-reals-6.3/tests/t3.c b/ic-reals-6.3/tests/t3.c new file mode 100644 index 0000000..9d5dd26 --- /dev/null +++ b/ic-reals-6.3/tests/t3.c @@ -0,0 +1,26 @@ +#include +#include "real.h" +#include + +main(int argc, char *argv[]) +{ + Real x, y, z; + int a, b; + double f; + + MyName = argv[0]; + + if (argc != 4) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + a = atoi(argv[1]); + b = atoi(argv[2]); + x = real_QInt(a, b); + y = mul_R_R(x, x); + print_R_Dec(y, atoi(argv[3])); + printf("\n"); +} diff --git a/ic-reals-6.3/tests/tan_QZ.c b/ic-reals-6.3/tests/tan_QZ.c new file mode 100644 index 0000000..4fb1e6c --- /dev/null +++ b/ic-reals-6.3/tests/tan_QZ.c @@ -0,0 +1,30 @@ +#include +#include "real.h" +#include + +/* + * Tests the tan_QZ when applied to a rational. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + mpz_t a, b; + + MyName = argv[0]; + + if (argc != 4) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + mpz_init_set_str(a, argv[1], 10); + mpz_init_set_str(b, argv[2], 10); + + x = tan_QZ(a, b); + + print_R_Dec(x, atoi(argv[3])); + printf("\n"); +} diff --git a/ic-reals-6.3/tests/tan_R.c b/ic-reals-6.3/tests/tan_R.c new file mode 100644 index 0000000..fbe3b8d --- /dev/null +++ b/ic-reals-6.3/tests/tan_R.c @@ -0,0 +1,64 @@ +#include +#include "real.h" +#include + +/* + * Tests the tan_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y, z; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + +/* + y = vector_Int(atoi(argv[4]), atoi(argv[5])); +*/ + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = tan_R(y); + printf("tan(x)="); + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + + z = atan_R(x); + printf("atan(tan(x))="); + print_R_Dec(z, atoi(argv[6])); + printf("\n"); + + z = div_R_R(y, z); + printf("x / atan(tan(x))="); + print_R_Dec(z, atoi(argv[6])); + printf("\n"); + + z = div_R_R(z, Pi); + printf("(x / atan(tan(x))) / Pi="); + print_R_Dec(z, atoi(argv[6])); + printf("\n"); + + printf("tan(x)=%f\n", tan(f)); + printf("atan(tan(x))=%f\nx / atan(tan(x))=%f\n(x / atan(tan(x)))/pi=%f\n", + atan(tan(f)), + f / atan(tan(f)), + (f / atan(tan(f))) / M_PI); +} diff --git a/ic-reals-6.3/tests/tan_R_digit.c b/ic-reals-6.3/tests/tan_R_digit.c new file mode 100644 index 0000000..18bdc2e --- /dev/null +++ b/ic-reals-6.3/tests/tan_R_digit.c @@ -0,0 +1,55 @@ +#include +#include "real.h" +#include + +/* + * This is the same as the tan_R test but shows how to retrieve digits + * from a real incrementally. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + mpz_t digits; + Sign sign; + Digit digit; + int count; + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = tan_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("tan(x)=%f\n", tan(f)); + + mpz_init(digits); + retrieveInfo(x, &sign, &count, digits); + + printf("%s ", signToString(sign)); + while (count > 0) { + digit = takeDigit(&count, digits); + printf("%s ", digitToString(digit)); + } + printf("\n"); +} diff --git a/ic-reals-6.3/tests/tanh_R.c b/ic-reals-6.3/tests/tanh_R.c new file mode 100644 index 0000000..370e5b6 --- /dev/null +++ b/ic-reals-6.3/tests/tanh_R.c @@ -0,0 +1,41 @@ +#include +#include "real.h" +#include + +/* + * Tests the tanh_R when applied to a real expressed + * by a sign, a characteristic pair and a vector. + */ +main(int argc, char *argv[]) +{ + Real x, y; + double f; + Real makeRealSignCNQInt(Sign, char *, int, int, int); + + MyName = argv[0]; + + if (argc != 7) { + fprintf(stderr, "%s \n", MyName); + exit(1); + } + + initReals(); + + y = makeRealSignCNQInt( + atoi(argv[1]), /* sign */ + argv[2], /* c */ + atoi(argv[3]), /* n */ + atoi(argv[4]), /* a */ + atoi(argv[5])); /* b */ + + print_R_Dec(y, atoi(argv[6])); + printf("\n"); + f = realToDouble(y); + printf("x=%f\n",f); + + x = tanh_R(y); + + print_R_Dec(x, atoi(argv[6])); + printf("\n"); + printf("tanh(x)=%f\n", tanh(f)); +} -- cgit v1.2.3