Browse Source

* */*: Removed problematic stdin, stdout and stderr definitions.

Use std::cin, std::cout, std::cerr instead (obsoletes 2000-10-29).
master
Richard Kreckel 24 years ago
parent
commit
f57f23a99a
  1. 34
      benchmarks/timebench1.cc
  2. 12
      benchmarks/timebench2a.cc
  3. 4
      benchmarks/timebench2ap.cc
  4. 38
      benchmarks/timebench2b.cc
  5. 25
      doc/cln.tex
  6. 11
      examples/contfrac.cc
  7. 18
      examples/fibonacci.cc
  8. 11
      examples/legendre.cc
  9. 4
      examples/nextprime.cc
  10. 5
      include/cln/io.h
  11. 4
      include/cln/modinteger.h
  12. 2
      include/cln/object.h
  13. 6
      include/cln/timing.h
  14. 2
      src/base/cl_N_err_d0.cc
  15. 26
      src/base/cl_as_err.cc
  16. 2
      src/base/cl_debugout.cc
  17. 2
      src/base/cl_malloc.cc
  18. 12
      src/base/cl_notreached.cc
  19. 6
      src/base/digitseq/cl_DS_mul_fftc.h
  20. 6
      src/base/digitseq/cl_DS_mul_fftcs.h
  21. 6
      src/base/digitseq/cl_DS_mul_fftr.h
  22. 6
      src/base/input/cl_read_err_bad.cc
  23. 2
      src/base/input/cl_read_err_eof.cc
  24. 10
      src/base/input/cl_read_err_junk.cc
  25. 12
      src/base/input/cl_read_globals.cc
  26. 3
      src/base/output/cl_prin_globals.cc
  27. 12
      src/base/ring/cl_no_ring.cc
  28. 10
      src/complex/input/cl_N_read.cc
  29. 2
      src/float/base/cl_F_err_nan.cc
  30. 2
      src/float/base/cl_F_err_ov.cc
  31. 2
      src/float/base/cl_F_err_un.cc
  32. 6
      src/integer/algebraic/cl_I_sqrt.cc
  33. 6
      src/integer/bitwise/cl_I_asherr.cc
  34. 6
      src/integer/bitwise/cl_I_logbitp_I.cc
  35. 6
      src/integer/conv/cl_I_to_L.cc
  36. 6
      src/integer/conv/cl_I_to_Q.cc
  37. 6
      src/integer/conv/cl_I_to_UL.cc
  38. 6
      src/integer/conv/cl_I_to_UQ.cc
  39. 10
      src/integer/division/cl_I_exquoerr.cc
  40. 6
      src/integer/input/cl_I_read.cc
  41. 2
      src/modinteger/cl_MI_int.h
  42. 12
      src/polynomial/elem/cl_UP_no_ring.cc
  43. 6
      src/rational/input/cl_RA_read.cc
  44. 6
      src/real/format-output/cl_fmt_cardinal.cc
  45. 6
      src/real/format-output/cl_fmt_newroman.cc
  46. 6
      src/real/format-output/cl_fmt_oldroman.cc
  47. 10
      src/real/input/cl_R_read.cc
  48. 6
      src/real/random/cl_R_random.cc
  49. 12
      tests/exam.h
  50. 8
      tests/exam_I_gcd.cc
  51. 18
      tests/main.cc
  52. 30
      tests/test.h
  53. 12
      tests/timeMImisc5.cc
  54. 4
      tests/timeUPMImul.cc
  55. 4
      tests/timepi.cc
  56. 4
      tests/timesquare.cc

34
benchmarks/timebench1.cc

@ -61,13 +61,13 @@ int main (int argc, char * argv[])
if (argc < 1)
exit(1);
fprint(stderr, "Number of repetitions: ");
fprintdecimal(stderr, repetitions);
fprint(stderr, "\n");
fprint(std::cerr, "Number of repetitions: ");
fprintdecimal(std::cerr, repetitions);
fprint(std::cerr, "\n");
float_format_t prec = float_format(1000);
fprint(stderr, "pi\n");
fprint(std::cerr, "pi\n");
{ cl_F p;
{ CL_TIMING; p = pi(prec); }
{ CL_TIMING;
@ -77,7 +77,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "gamma\n");
fprint(std::cerr, "gamma\n");
{ cl_F p;
{ CL_TIMING; p = eulerconst(prec); }
{ CL_TIMING;
@ -87,7 +87,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "e\n");
fprint(std::cerr, "e\n");
{ cl_F p = exp1(prec);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -96,7 +96,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "sqrt(3)\n");
fprint(std::cerr, "sqrt(3)\n");
{ cl_R p = sqrt(cl_float(3,prec));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -105,7 +105,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "exp(log(2))\n");
fprint(std::cerr, "exp(log(2))\n");
{ cl_N p = exp(log(cl_float(2,prec)));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -114,7 +114,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "log(exp(2))\n");
fprint(std::cerr, "log(exp(2))\n");
{ cl_N p = log(exp(cl_float(2,prec)));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -123,7 +123,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "sin(pi/3)\n");
fprint(std::cerr, "sin(pi/3)\n");
{ cl_R p = sin(pi(prec)/3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -132,7 +132,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "cos(pi/3)\n");
fprint(std::cerr, "cos(pi/3)\n");
{ cl_R p = cos(pi(prec)/3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -141,7 +141,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "arcsin(sqrt(3)/2)\n");
fprint(std::cerr, "arcsin(sqrt(3)/2)\n");
{ cl_N p = asin(sqrt(cl_float(3,prec))/2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -150,7 +150,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "arccos(sqrt(3)/2)\n");
fprint(std::cerr, "arccos(sqrt(3)/2)\n");
{ cl_N p = acos(sqrt(cl_float(3,prec))/2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -159,7 +159,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "sinh(log(2))\n");
fprint(std::cerr, "sinh(log(2))\n");
{ cl_N p = sinh(log(cl_float(2,prec)));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -168,7 +168,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "cosh(log(2))\n");
fprint(std::cerr, "cosh(log(2))\n");
{ cl_N p = cosh(log(cl_float(2,prec)));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -177,7 +177,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "arsinh(pi)\n");
fprint(std::cerr, "arsinh(pi)\n");
{ cl_N p = asinh(pi(prec));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -186,7 +186,7 @@ int main (int argc, char * argv[])
cout << p << endl << endl;
}
fprint(stderr, "arcosh(pi)\n");
fprint(std::cerr, "arcosh(pi)\n");
{ cl_N p = acosh(pi(prec));
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)

12
benchmarks/timebench2a.cc

@ -31,8 +31,8 @@ int main (int argc, char * argv[])
if (argc < 1)
exit(1);
stderr << "Number of digits: " << digits << endl;
stderr << "Number of repetitions: " << repetitions << endl;
cerr << "Number of digits: " << digits << endl;
cerr << "Number of repetitions: " << repetitions << endl;
float_format_t prec = float_format(digits);
float_format_t prec2 = float_format(digits*2);
@ -41,7 +41,7 @@ int main (int argc, char * argv[])
cl_I x2 = floor1(sqrt(cl_float(3,prec)) * pow);
cl_I x3 = pow+1;
stderr << "multiplication" << endl;
cerr << "multiplication" << endl;
{ cl_I r = x1*x2;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -50,7 +50,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "division" << endl;
cerr << "division" << endl;
{ cl_I_div_t qr = floor2(x1,x2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -59,7 +59,7 @@ int main (int argc, char * argv[])
cout << qr.quotient << endl << qr.remainder << endl << endl;
}
stderr << "isqrt" << endl;
cerr << "isqrt" << endl;
{ cl_I r = isqrt(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -68,7 +68,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "gcd" << endl;
cerr << "gcd" << endl;
{ cl_I r = gcd(x1,x2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)

4
benchmarks/timebench2ap.cc

@ -28,8 +28,8 @@ int main (int argc, char * argv[])
if (argc < 1)
exit(1);
stderr << "Limit: " << limit << endl;
stderr << "Number of repetitions: " << repetitions << endl;
cerr << "Limit: " << limit << endl;
cerr << "Number of repetitions: " << repetitions << endl;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)

38
benchmarks/timebench2b.cc

@ -34,15 +34,15 @@ int main (int argc, char * argv[])
if (argc < 1)
exit(1);
stderr << "Number of digits: " << digits << endl;
stderr << "Number of repetitions (except for pi,euler,e): " << repetitions << endl;
cerr << "Number of digits: " << digits << endl;
cerr << "Number of repetitions (except for pi,euler,e): " << repetitions << endl;
float_format_t prec = float_format(digits);
cl_F x1 = sqrt(cl_float(2,prec));
cl_F x2 = sqrt(cl_float(3,prec));
cl_F x3 = The(cl_F)(log(cl_float(2,prec)));
stderr << "multiplication" << endl;
cerr << "multiplication" << endl;
{ cl_F r = x1*x2;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -51,7 +51,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "sqrt" << endl;
cerr << "sqrt" << endl;
{ cl_F r = sqrt(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -60,25 +60,25 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "pi" << endl;
cerr << "pi" << endl;
{ cl_F r;
{ CL_TIMING; r = pi(prec); }
cout << r << endl << endl;
}
stderr << "eulerconst" << endl;
cerr << "eulerconst" << endl;
{ cl_F r;
{ CL_TIMING; r = eulerconst(prec); }
cout << r << endl << endl;
}
stderr << "e" << endl;
cerr << "e" << endl;
{ cl_F r;
{ CL_TIMING; r = exp1(prec); }
cout << r << endl << endl;
}
stderr << "exp" << endl;
cerr << "exp" << endl;
{ cl_F r = exp(-x1);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -87,7 +87,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "log" << endl;
cerr << "log" << endl;
{ cl_N r = log(x2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -96,7 +96,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "sin" << endl;
cerr << "sin" << endl;
{ cl_R r = sin(5*x1);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -105,7 +105,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "cos" << endl;
cerr << "cos" << endl;
{ cl_R r = cos(5*x1);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -114,7 +114,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "asin" << endl;
cerr << "asin" << endl;
{ cl_N r = asin(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -123,7 +123,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "acos" << endl;
cerr << "acos" << endl;
{ cl_N r = acos(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -132,7 +132,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "atan" << endl;
cerr << "atan" << endl;
{ cl_F r = atan(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -141,7 +141,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "sinh" << endl;
cerr << "sinh" << endl;
{ cl_F r = sinh(x2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -150,7 +150,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "cosh" << endl;
cerr << "cosh" << endl;
{ cl_F r = cosh(x2);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -159,7 +159,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "asinh" << endl;
cerr << "asinh" << endl;
{ cl_N r = asinh(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -168,7 +168,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "acosh" << endl;
cerr << "acosh" << endl;
{ cl_N r = acosh(1+x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
@ -177,7 +177,7 @@ int main (int argc, char * argv[])
cout << r << endl << endl;
}
stderr << "atanh" << endl;
cerr << "atanh" << endl;
{ cl_N r = atanh(x3);
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)

25
doc/cln.tex

@ -553,7 +553,8 @@ Rational numbers are always normalized to the form
are coprime integers and the denominator is positive. If the resulting
denominator is @code{1}, the rational number is converted to an integer.
Small integers (typically in the range @code{-2^30}@dots{}@code{2^30-1},
@cindex immediate numbers
Small integers (typically in the range @code{-2^29}@dots{}@code{2^29-1},
for 32-bit machines) are especially efficient, because they consume no heap
allocation. Otherwise the distinction between these immediate integers
(called ``fixnums'') and heap allocated integers (called ``bignums'')
@ -2418,13 +2419,6 @@ Including @code{<cln/io.h>} defines a type @code{cl_istream}, which is
the type of the first argument to all input functions. @code{cl_istream}
is the same as @code{std::istream&}.
The variable
@itemize @asis
@item
@code{cl_istream stdin}
@end itemize
contains the standard input stream.
These are the simple input functions:
@table @code
@ -2524,20 +2518,6 @@ Including @code{<cln/io.h>} defines a type @code{cl_ostream}, which is
the type of the first argument to all output functions. @code{cl_ostream}
is the same as @code{std::ostream&}.
The variable
@itemize @asis
@item
@code{cl_ostream stdout}
@end itemize
contains the standard output stream.
The variable
@itemize @asis
@item
@code{cl_ostream stderr}
@end itemize
contains the standard error output stream.
These are the simple output functions:
@table @code
@ -3285,6 +3265,7 @@ Garbage collection: A reference counting mechanism makes sure that any
number object's storage is freed immediately when the last reference to the
object is gone.
@item
@cindex immediate numbers
Small integers are represented as immediate values instead of pointers
to heap allocated storage. This means that integers @code{> -2^29},
@code{< 2^29} don't consume heap memory, unless they were explicitly allocated

11
examples/contfrac.cc

@ -8,6 +8,7 @@
#include <cln/io.h>
#include <cln/integer_io.h>
using namespace std;
using namespace cln;
// Our private error handling: return to the main program.
@ -27,23 +28,23 @@ int main (int argc, char* argv[])
cl_R x = arg;
// Check sign.
if (minusp(x)) {
stdout << '-';
cout << '-';
x = -x;
}
fprint(stdout, "[");
cout << "[";
const char* separator = "; ";
for (;;) {
// Split x into integral and fractional part.
cl_R_div_t x_split = floor2(x);
stdout << x_split.quotient;
cout << x_split.quotient;
x = x_split.remainder;
if (zerop(x))
break;
stdout << separator;
cout << separator;
separator = ", ";
// Invert x.
x = recip(x);
}
stdout << ']' << std::endl;
cout << ']' << endl;
}
}

18
examples/fibonacci.cc

@ -125,11 +125,11 @@ const cl_I fibonacci_slow (int n)
int main (int argc, char* argv[])
{
if (argc != 2) {
stderr << "Usage: fibonacci n" << endl;
cerr << "Usage: fibonacci n" << endl;
return(1);
}
int n = atoi(argv[1]);
stdout << "fib(" << n << ") = " << fibonacci(n) << endl;
cout << "fib(" << n << ") = " << fibonacci(n) << endl;
return(0);
}
@ -143,27 +143,27 @@ int main (int argc, char* argv[])
argc -= 2; argv += 2;
}
if (argc != 2) {
stderr << "Usage: fibonacci n" << endl;
cerr << "Usage: fibonacci n" << endl;
return(1);
}
int n = atoi(argv[1]);
{ CL_TIMING;
stdout << "fib(" << n << ") = ";
cout << "fib(" << n << ") = ";
for (int rep = repetitions-1; rep > 0; rep--)
fibonacci(n);
stdout << fibonacci(n) << endl;
cout << fibonacci(n) << endl;
}
{ CL_TIMING;
stdout << "fib(" << n << ") = ";
cout << "fib(" << n << ") = ";
for (int rep = repetitions-1; rep > 0; rep--)
fibonacci_compact(n);
stdout << fibonacci_compact(n) << endl;
cout << fibonacci_compact(n) << endl;
}
{ CL_TIMING;
stdout << "fib(" << n << ") = ";
cout << "fib(" << n << ") = ";
for (int rep = repetitions-1; rep > 0; rep--)
fibonacci_slow(n);
stdout << fibonacci_slow(n) << endl;
cout << fibonacci_slow(n) << endl;
}
return(0);
}

11
examples/legendre.cc

@ -10,6 +10,7 @@
#include <cln/io.h>
#include <stdlib.h>
using namespace std;
using namespace cln;
// Computes the n-th Legendre polynomial in R[x], using the formula
@ -54,21 +55,21 @@ const cl_UP_MI legendre (const cl_modint_ring& R, int n)
int main (int argc, char* argv[])
{
if (!(argc == 2 || argc == 3)) {
fprint(stderr, "Usage: legendre n [m]\n");
cerr << "Usage: legendre n [m]" << endl;
exit(1);
}
int n = atoi(argv[1]);
if (!(n >= 0)) {
fprint(stderr, "Usage: legendre n [m] with n >= 0\n");
cerr << "Usage: legendre n [m] with n >= 0" << endl;
exit(1);
}
if (argc == 2) {
cl_UP p = legendre(cl_RA_ring,n);
fprint(stdout, p);
cout << p << endl;
} else {
cl_I m = argv[2];
cl_UP p = legendre(find_modint_ring(m),n);
fprint(stdout, p);
cout << p << endl;
}
fprint(stdout, "\n");
return 0;
}

4
examples/nextprime.cc

@ -15,11 +15,11 @@
int main (int argc, char* argv[])
{
if (argc != 2) {
cln::stderr << "Usage: nextprime x" << std::endl;
std::cerr << "Usage: nextprime x" << std::endl;
return(1);
}
cln::cl_R x = (cln::cl_R)argv[1];
cln::cl_I p = cln::nextprobprime(x);
cln::stdout << p << std::endl;
std::cout << p << std::endl;
return(0);
}

5
include/cln/io.h

@ -1,4 +1,4 @@
// I/O through <stdio.h> or <iostream>
// I/O through <iostream>
#ifndef _CL_IO_H
#define _CL_IO_H
@ -20,9 +20,6 @@ namespace cln {
typedef std::istream& cl_istream;
typedef std::ostream& cl_ostream;
extern cl_istream stdin;
extern cl_ostream stdout;
extern cl_ostream stderr;
extern std::ostream* cl_debugout_stream;
#define cl_debugout (*cl_debugout_stream)

4
include/cln/modinteger.h

@ -75,10 +75,10 @@ struct cl_composite_condition : public cl_condition {
// Constructors.
cl_composite_condition (const cl_I& _p)
: p (_p), factor (0)
{ print(stderr); }
{ print(std::cerr); }
cl_composite_condition (const cl_I& _p, const cl_I& _f)
: p (_p), factor (_f)
{ print(stderr); }
{ print(std::cerr); }
// Implement general condition methods.
const char * name () const;
void print (cl_ostream) const;

2
include/cln/object.h

@ -175,7 +175,7 @@ typedef void (*cl_heap_destructor_function) (cl_heap* pointer);
#define cl_class_flags_subclass_rational 8 // all instances belong to cl_RA
#define cl_class_flags_number_ring 16 // all instances are rings whose
// elements belong to cl_number
// Function to print an object for debugging, to stderr.
// Function to print an object for debugging, to cerr.
typedef void (*cl_heap_dprint_function) (cl_heap* pointer);
struct cl_class {

6
include/cln/timing.h

@ -52,8 +52,8 @@ extern void cl_timing_report (cl_ostream, const cl_time_consumption&);
struct cl_timing {
// Constructor, starts the time interval.
cl_timing (cl_time_consumption& accumulator);
cl_timing (cl_ostream destination = stderr);
cl_timing (const char *, cl_ostream destination = stderr);
cl_timing (cl_ostream destination = std::cerr);
cl_timing (const char *, cl_ostream destination = std::cerr);
// Destructor, closes the time interval and does a report.
~cl_timing ();
//private:
@ -67,7 +67,7 @@ struct cl_timing {
// Usage:
// { CL_TIMING; computation(); }
// or { CL_TIMING(accumulator); computation(); }
// or { CL_TIMING(stdout); computation(); }
// or { CL_TIMING(cout); computation(); }
// The timing interval starts immediately and ends at the closing brace.
#define CL_TIMING CL_TIMING1(__LINE__)
#define CL_TIMING1(line) CL_TIMING2(line)

2
src/base/cl_N_err_d0.cc

@ -16,7 +16,7 @@ namespace cln {
void cl_error_division_by_0 (void)
{
fprint(stderr, "Division by zero.\n");
fprint(std::cerr, "Division by zero.\n");
cl_abort();
}

26
src/base/cl_as_err.cc

@ -16,22 +16,22 @@ namespace cln {
void cl_as_error (const cl_number& obj, const char * typestring, const char * filename, int line)
{
fprint(stderr, "Type assertion failed: in file ");
fprint(stderr, filename);
fprint(stderr, ", line ");
fprintdecimal(stderr, line);
fprint(stderr, ", not ");
fprint(stderr, typestring);
fprint(stderr, ": ");
fprint(std::cerr, "Type assertion failed: in file ");
fprint(std::cerr, filename);
fprint(std::cerr, ", line ");
fprintdecimal(std::cerr, line);
fprint(std::cerr, ", not ");
fprint(std::cerr, typestring);
fprint(std::cerr, ": ");
#if 0 // This brings in a dependency from the complex and float printer and all the float stuff.
fprint(stderr, obj);
fprint(std::cerr, obj);
#else
fprint(stderr, "@0x");
fprinthexadecimal(stderr, (unsigned long)(void*)&obj);
fprint(stderr, ": 0x");
fprinthexadecimal(stderr, (unsigned long)obj.word);
fprint(std::cerr, "@0x");
fprinthexadecimal(std::cerr, (unsigned long)(void*)&obj);
fprint(std::cerr, ": 0x");
fprinthexadecimal(std::cerr, (unsigned long)obj.word);
#endif
fprint(stderr, "\n");
fprint(std::cerr, "\n");
cl_abort();
}

2
src/base/cl_debugout.cc

@ -10,7 +10,7 @@
// Implementation.
// Just assume that the debugger runs on /dev/tty, independently of
// stdin, stdout, stderr.
// cin, cout, cerr.
#include <fstream>

2
src/base/cl_malloc.cc

@ -28,7 +28,7 @@ static void* xmalloc (size_t size)
void* ptr = malloc(size);
if (ptr)
return ptr;
fprint(stderr, "Out of virtual memory.\n");
fprint(std::cerr, "Out of virtual memory.\n");
cl_abort();
}

12
src/base/cl_notreached.cc

@ -16,12 +16,12 @@ namespace cln {
void cl_notreached_abort (const char* filename, int lineno)
{
fprint(stderr, "Internal error: statement in file ");
fprint(stderr, filename);
fprint(stderr, ", line ");
fprintdecimal(stderr, lineno);
fprint(stderr, " has been reached!!\n");
fprint(stderr, "Please send the authors of the program a description how you produced this error!\n");
fprint(std::cerr, "Internal error: statement in file ");
fprint(std::cerr, filename);
fprint(std::cerr, ", line ");
fprintdecimal(std::cerr, lineno);
fprint(std::cerr, " has been reached!!\n");
fprint(std::cerr, "Please send the authors of the program a description how you produced this error!\n");
cl_abort();
}

6
src/base/digitseq/cl_DS_mul_fftc.h

@ -663,7 +663,7 @@ static void fill_factor (uintL N, fftc_complex* x, uintL l,
if (max_l(2) > intDsize && l > intDsize) {
// l > intDsize
if (max_l(2) > 64 && l > 64) {
fprint(stderr, "FFT problem: l > 64 not supported by pow2_table\n");
fprint(std::cerr, "FFT problem: l > 64 not supported by pow2_table\n");
cl_abort();
}
var fftc_real carry = 0;
@ -944,7 +944,7 @@ static inline void mulu_fftcomplex_nocheck (const uintD* sourceptr1, uintC len1,
for ( ; ; k++) {
if (k >= sizeof(max_l_table)/sizeof(max_l_table[0])
|| max_l_table[k] <= 0) {
fprint(stderr, "FFT problem: numbers too big, floating point precision not sufficient\n");
fprint(std::cerr, "FFT problem: numbers too big, floating point precision not sufficient\n");
cl_abort();
}
if (2*ceiling((uintL)len1*intDsize,max_l_table[k])-1 <= ((uintL)1 << k))
@ -1100,7 +1100,7 @@ static void mulu_fftcomplex (const uintD* sourceptr1, uintC len1,
var uintD checksum = multiply_checksum(checksum1,checksum2);
mulu_fftcomplex_nocheck(sourceptr1,len1,sourceptr2,len2,destptr);
if (!(checksum == compute_checksum(destptr,len1+len2))) {
fprint(stderr, "FFT problem: checksum error\n");
fprint(std::cerr, "FFT problem: checksum error\n");
cl_abort();
}
}

6
src/base/digitseq/cl_DS_mul_fftcs.h

@ -727,7 +727,7 @@ static void fill_factor (uintL N, fftcs_real* x, uintL l,
if (max_l(2) > intDsize && l > intDsize) {
// l > intDsize
if (max_l(2) > 64 && l > 64) {
fprint(stderr, "FFT problem: l > 64 not supported by pow2_table\n");
fprint(std::cerr, "FFT problem: l > 64 not supported by pow2_table\n");
cl_abort();
}
var fftcs_real carry = 0;
@ -1000,7 +1000,7 @@ static inline void mulu_fftcs_nocheck (const uintD* sourceptr1, uintC len1,
for ( ; ; k++) {
if (k >= sizeof(max_l_table)/sizeof(max_l_table[0])
|| max_l_table[k] <= 0) {
fprint(stderr, "FFT problem: numbers too big, floating point precision not sufficient\n");
fprint(std::cerr, "FFT problem: numbers too big, floating point precision not sufficient\n");
cl_abort();
}
if (2*ceiling((uintL)len1*intDsize,max_l_table[k])-1 <= ((uintL)1 << k))
@ -1150,7 +1150,7 @@ static void mulu_fftcs (const uintD* sourceptr1, uintC len1,
var uintD checksum = multiply_checksum(checksum1,checksum2);
mulu_fftcs_nocheck(sourceptr1,len1,sourceptr2,len2,destptr);
if (!(checksum == compute_checksum(destptr,len1+len2))) {
fprint(stderr, "FFT problem: checksum error\n");
fprint(std::cerr, "FFT problem: checksum error\n");
cl_abort();
}
}

6
src/base/digitseq/cl_DS_mul_fftr.h

@ -714,7 +714,7 @@ static void fill_factor (uintL N, fftr_real* x, uintL l,
if (max_l(2) > intDsize && l > intDsize) {
// l > intDsize
if (max_l(2) > 64 && l > 64) {
fprint(stderr, "FFT problem: l > 64 not supported by pow2_table\n");
fprint(std::cerr, "FFT problem: l > 64 not supported by pow2_table\n");
cl_abort();
}
var fftr_real carry = 0;
@ -987,7 +987,7 @@ static inline void mulu_fftr_nocheck (const uintD* sourceptr1, uintC len1,
for ( ; ; k++) {
if (k >= sizeof(max_l_table)/sizeof(max_l_table[0])
|| max_l_table[k] <= 0) {
fprint(stderr, "FFT problem: numbers too big, floating point precision not sufficient\n");
fprint(std::cerr, "FFT problem: numbers too big, floating point precision not sufficient\n");
cl_abort();
}
if (2*ceiling((uintL)len1*intDsize,max_l_table[k])-1 <= ((uintL)1 << k))
@ -1137,7 +1137,7 @@ static void mulu_fftr (const uintD* sourceptr1, uintC len1,
var uintD checksum = multiply_checksum(checksum1,checksum2);
mulu_fftr_nocheck(sourceptr1,len1,sourceptr2,len2,destptr);
if (!(checksum == compute_checksum(destptr,len1+len2))) {
fprint(stderr, "FFT problem: checksum error\n");
fprint(std::cerr, "FFT problem: checksum error\n");
cl_abort();
}
}

6
src/base/input/cl_read_err_bad.cc

@ -16,10 +16,10 @@ namespace cln {
void read_number_bad_syntax (const char * string, const char * string_limit)
{
fprint(stderr, "Illegal number syntax: \"");
fprint(std::cerr, "Illegal number syntax: \"");
for (const char * ptr = string; ptr != string_limit; ptr++)
fprintchar(stderr, *ptr);
fprint(stderr, "\"\n");
fprintchar(std::cerr, *ptr);
fprint(std::cerr, "\"\n");
cl_abort();
}

2
src/base/input/cl_read_err_eof.cc

@ -16,7 +16,7 @@ namespace cln {
void read_number_eof (void)
{
fprint(stderr, "read_number: end of stream encountered\n");
fprint(std::cerr, "read_number: end of stream encountered\n");
cl_abort();
}

10
src/base/input/cl_read_err_junk.cc

@ -16,15 +16,15 @@ namespace cln {
void read_number_junk (const char * string_rest, const char * string, const char * string_limit)
{
fprint(stderr, "Junk after number: ");
fprint(std::cerr, "Junk after number: ");
{ for (const char * ptr = string; ptr != string_rest; ptr++)
fprintchar(stderr, *ptr);
fprintchar(std::cerr, *ptr);
}
fprint(stderr, "\"");
fprint(std::cerr, "\"");
{ for (const char * ptr = string_rest; ptr != string_limit; ptr++)
fprintchar(stderr, *ptr);
fprintchar(std::cerr, *ptr);
}
fprint(stderr, "\"\n");
fprint(std::cerr, "\"\n");
cl_abort();
}

12
src/base/input/cl_read_globals.cc

@ -1,12 +0,0 @@
// Global variables in CLN
// Specification.
#include "cln/io.h"
// Implementation.
namespace cln {
cl_istream stdin = std::cin;
} // namespace cln

3
src/base/output/cl_prin_globals.cc

@ -13,9 +13,6 @@ CL_PROVIDE(cl_prin_globals)
namespace cln {
cl_ostream stdout = std::cout;
cl_ostream stderr = std::cerr;
cl_print_flags default_print_flags;
#if 0 // The default constructors already do this.
AT_INITIALIZATION(default_print_flags)

12
src/base/ring/cl_no_ring.cc

@ -19,18 +19,18 @@ namespace cln {
nonreturning_function(static, uninitialized_ring, (void));
static void uninitialized_ring ()
{
fprint(stderr, "Uninitialized ring operation called\n");
fprint(std::cerr, "Uninitialized ring operation called\n");
cl_abort();
}
nonreturning_function(static, uninitialized_error, (const _cl_ring_element&));
static void uninitialized_error (const _cl_ring_element& obj)
{
fprint(stderr, "Uninitialized ring element @0x");
fprinthexadecimal(stderr, (unsigned long)(void*)&obj);
fprint(stderr, ": 0x");
fprinthexadecimal(stderr, (unsigned long)obj.rep.word);
fprint(stderr, "\n");
fprint(std::cerr, "Uninitialized ring element @0x");
fprinthexadecimal(std::cerr, (unsigned long)(void*)&obj);
fprint(std::cerr, ": 0x");
fprinthexadecimal(std::cerr, (unsigned long)obj.rep.word);
fprint(std::cerr, "\n");
cl_abort();
}

10
src/complex/input/cl_N_read.cc

@ -24,10 +24,6 @@
#undef floor
#include <cmath>
#define floor cln_floor
// Ugh, some compilers #define stderr, confusing cln::stderr
#ifdef stderr
#undef stderr
#endif
namespace cln {
@ -96,9 +92,9 @@ const cl_N read_complex (const cl_read_flags& flags, const char * string, const
goto not_rational_syntax;
var cl_I base = read_integer(10,0,ptr,0,base_end_ptr-ptr);
if (!((base >= 2) && (base <= 36))) {
fprint(stderr, "Base must be an integer in the range from 2 to 36, not ");
fprint(stderr, base);
fprint(stderr, "\n");
fprint(std::cerr, "Base must be an integer in the range from 2 to 36, not ");
fprint(std::cerr, base);
fprint(std::cerr, "\n");
cl_abort();
}
rational_base = FN_to_UL(base); ptr = base_end_ptr;

2
src/float/base/cl_F_err_nan.cc

@ -16,7 +16,7 @@ namespace cln {
void cl_error_floating_point_nan (void)
{
fprint(stderr, "floating point NaN occurred.\n");
fprint(std::cerr, "floating point NaN occurred.\n");
cl_abort();
}

2
src/float/base/cl_F_err_ov.cc

@ -16,7 +16,7 @@ namespace cln {
void cl_error_floating_point_overflow (void)
{
fprint(stderr, "Floating point overflow.\n");
fprint(std::cerr, "Floating point overflow.\n");
cl_abort();
}

2
src/float/base/cl_F_err_un.cc

@ -16,7 +16,7 @@ namespace cln {
void cl_error_floating_point_underflow (void)
{
fprint(stderr, "Floating point underflow.\n");
fprint(std::cerr, "Floating point underflow.\n");
cl_abort();
}

6
src/integer/algebraic/cl_I_sqrt.cc

@ -21,9 +21,9 @@ namespace cln {
cl_boolean isqrt (const cl_I& x, cl_I* w)
{
if (minusp(x)) {
fprint(stderr, "isqrt: applied to negative number: ");
fprint(stderr, x);
fprint(stderr, "\n");
fprint(std::cerr, "isqrt: applied to negative number: ");
fprint(std::cerr, x);
fprint(std::cerr, "\n");
cl_abort();
}
CL_ALLOCA_STACK;

6
src/integer/bitwise/cl_I_asherr.cc

@ -18,9 +18,9 @@ namespace cln {
void cl_ash_error (const cl_I& badamount)
{
fprint(stderr, "ash: too large shift amount: ");
fprint(stderr, badamount);
fprint(stderr, "\n");
fprint(std::cerr, "ash: too large shift amount: ");
fprint(std::cerr, badamount);
fprint(std::cerr, "\n");
cl_abort();
}

6
src/integer/bitwise/cl_I_logbitp_I.cc

@ -44,9 +44,9 @@ cl_boolean logbitp (const cl_I& x, const cl_I& y)
}
else
// x<0
{ fprint(stderr, "logbitp: Index is negative: ");
fprint(stderr, x);
fprint(stderr, "\n");
{ fprint(std::cerr, "logbitp: Index is negative: ");
fprint(std::cerr, x);
fprint(std::cerr, "\n");
cl_abort();
}
}

6
src/integer/conv/cl_I_to_L.cc

@ -70,9 +70,9 @@ sint32 cl_I_to_L (const cl_I& obj)
#undef IF_LENGTH
}
bad: // unpassendes Objekt
fprint(stderr, "Not a 32-bit integer: ");
fprint(stderr, obj);
fprint(stderr, "\n");
fprint(std::cerr, "Not a 32-bit integer: ");
fprint(std::cerr, obj);
fprint(std::cerr, "\n");
cl_abort();
}
}

6
src/integer/conv/cl_I_to_Q.cc

@ -131,9 +131,9 @@ sint64 cl_I_to_Q (const cl_I& obj)
#undef IF_LENGTH
}
bad: // unpassendes Objekt
fprint(stderr, "Not a 64-bit integer: ");
fprint(stderr, obj);
fprint(stderr, "\n");
fprint(std::cerr, "Not a 64-bit integer: ");
fprint(std::cerr, obj);
fprint(std::cerr, "\n");
cl_abort();
}
}

6
src/integer/conv/cl_I_to_UL.cc

@ -54,9 +54,9 @@ uint32 cl_I_to_UL (const cl_I& obj)
#undef IF_LENGTH
}
bad: // unpassendes Objekt
fprint(stderr, "Not a 32-bit integer: ");
fprint(stderr, obj);
fprint(stderr, "\n");
fprint(std::cerr, "Not a 32-bit integer: ");
fprint(std::cerr, obj);
fprint(std::cerr, "\n");
cl_abort();
}

6
src/integer/conv/cl_I_to_UQ.cc

@ -91,9 +91,9 @@ uint64 cl_I_to_UQ (const cl_I& obj)
#undef IF_LENGTH
}
bad: // unpassendes Objekt
fprint(stderr, "Not a 64-bit integer: ");
fprint(stderr, obj);
fprint(stderr, "\n");
fprint(std::cerr, "Not a 64-bit integer: ");
fprint(std::cerr, obj);
fprint(std::cerr, "\n");
cl_abort();
}

10
src/integer/division/cl_I_exquoerr.cc

@ -17,11 +17,11 @@ namespace cln {
void cl_error_exquo (const cl_I& x, const cl_I& y)
{
fprint(stderr, "Quotient ");
fprint(stderr, x);
fprint(stderr, " / ");
fprint(stderr, y);
fprint(stderr, " is not an integer.\n");
fprint(std::cerr, "Quotient ");
fprint(std::cerr, x);
fprint(std::cerr, " / ");
fprint(std::cerr, y);
fprint(std::cerr, " is not an integer.\n");
cl_abort();
}

6
src/integer/input/cl_I_read.cc

@ -81,9 +81,9 @@ const cl_I read_integer (const cl_read_flags& flags, const char * string, const
goto not_integer_syntax;
var cl_I base = read_integer(10,0,ptr,0,base_end_ptr-ptr);
if (!((base >= 2) && (base <= 36))) {
fprint(stderr, "Base must be an integer in the range from 2 to 36, not ");
fprint(stderr, base);
fprint(stderr, "\n");
fprint(std::cerr, "Base must be an integer in the range from 2 to 36, not ");
fprint(std::cerr, base);
fprint(std::cerr, "\n");
cl_abort();
}
rational_base = FN_to_UL(base); ptr = base_end_ptr;

2
src/modinteger/cl_MI_int.h

@ -31,7 +31,7 @@ static const _cl_MI int_random (cl_heap_modint_ring* R, random_state& randomstat
{
unused R;
unused randomstate;
fprint(stderr, "Z / 0 Z not a finite set - no equidistributed random function.\n");
fprint(std::cerr, "Z / 0 Z not a finite set - no equidistributed random function.\n");
cl_abort();
#if ((defined(__sparc__) || defined(__sparc64__)) && !defined(__GNUC__)) // Sun CC wants a return value
return _cl_MI(R, 0);

12
src/polynomial/elem/cl_UP_no_ring.cc

@ -19,18 +19,18 @@ namespace cln {
nonreturning_function(static, uninitialized_ring, (void));
static void uninitialized_ring ()
{
fprint(stderr, "Uninitialized ring operation called\n");
fprint(std::cerr, "Uninitialized ring operation called\n");
cl_abort();
}
nonreturning_function(static, uninitialized_error, (const _cl_UP&));
static void uninitialized_error (const _cl_UP& obj)
{
fprint(stderr, "Uninitialized ring element @0x");
fprinthexadecimal(stderr, (unsigned long)(void*)&obj);
fprint(stderr, ": 0x");
fprinthexadecimal(stderr, (unsigned long)obj.rep.word);
fprint(stderr, "\n");
fprint(std::cerr, "Uninitialized ring element @0x");
fprinthexadecimal(std::cerr, (unsigned long)(void*)&obj);
fprint(std::cerr, ": 0x");
fprinthexadecimal(std::cerr, (unsigned long)obj.rep.word);
fprint(std::cerr, "\n");
cl_abort();
}

6
src/rational/input/cl_RA_read.cc

@ -83,9 +83,9 @@ const cl_RA read_rational (const cl_read_flags& flags, const char * string, cons
goto not_rational_syntax;
var cl_I base = read_integer(10,0,ptr,0,base_end_ptr-ptr);
if (!((base >= 2) && (base <= 36))) {
fprint(stderr, "Base must be an integer in the range from 2 to 36, not ");
fprint(stderr, base);
fprint(stderr, "\n");
fprint(std::cerr, "Base must be an integer in the range from 2 to 36, not ");
fprint(std::cerr, base);
fprint(std::cerr, "\n");
cl_abort();
}
rational_base = FN_to_UL(base); ptr = base_end_ptr;

6
src/real/format-output/cl_fmt_cardinal.cc

@ -107,9 +107,9 @@ void format_cardinal (cl_ostream stream, const cl_I& argument)
var uintL * small_piece_ptr = &small_pieces[0];
do {
if (*illion_ptr == NULL) {
fprint(stderr, "format_cardinal: argument too large: ");
fprint(stderr, argument);
fprint(stderr, "\n");
fprint(std::cerr, "format_cardinal: argument too large: ");
fprint(std::cerr, argument);
fprint(std::cerr, "\n");
cl_abort();
}
var cl_I_div_t div = floor2(arg,1000);

6
src/real/format-output/cl_fmt_newroman.cc

@ -18,9 +18,9 @@ namespace cln {
void format_new_roman (cl_ostream stream, const cl_I& arg)
{
if (!(0 < arg && arg < 4000)) {
fprint(stderr, "format_new_roman: argument should be in the range 1 - 3999, not ");
fprint(stderr, arg);
fprint(stderr, ".\n");
fprint(std::cerr, "format_new_roman: argument should be in the range 1 - 3999, not ");
fprint(std::cerr, arg);
fprint(std::cerr, ".\n");
cl_abort();
}
var uintL value = cl_I_to_UL(arg);

6
src/real/format-output/cl_fmt_oldroman.cc

@ -18,9 +18,9 @@ namespace cln {
void format_old_roman (cl_ostream stream, const cl_I& arg)
{
if (!(0 < arg && arg < 5000)) {
fprint(stderr, "format_old_roman: argument should be in the range 1 - 4999, not ");
fprint(stderr, arg);
fprint(stderr, ".\n");
fprint(std::cerr, "format_old_roman: argument should be in the range 1 - 4999, not ");
fprint(std::cerr, arg);
fprint(std::cerr, ".\n");
cl_abort();
}
var uintL value = cl_I_to_UL(arg);

10
src/real/input/cl_R_read.cc

@ -24,10 +24,6 @@
#undef floor
#include <cmath>
#define floor cln_floor
// Ugh, some compilers #define stderr, confusing cln::stderr
#ifdef stderr
#undef stderr
#endif
namespace cln {
@ -94,9 +90,9 @@ const cl_R read_real (const cl_read_flags& flags, const char * string, const cha
goto not_rational_syntax;
var cl_I base = read_integer(10,0,ptr,0,base_end_ptr-ptr);
if (!((base >= 2) && (base <= 36))) {
fprint(stderr, "Base must be an integer in the range from 2 to 36, not ");
fprint(stderr, base);
fprint(stderr, "\n");
fprint(std::cerr, "Base must be an integer in the range from 2 to 36, not ");
fprint(std::cerr, base);
fprint(std::cerr, "\n");
cl_abort();
}
rational_base = FN_to_UL(base); ptr = base_end_ptr;

6
src/real/random/cl_R_random.cc

@ -32,9 +32,9 @@ const cl_R random_R (random_state& r, const cl_R& n)
}
}
}
fprint(stderr, "random: argument should be positive and an integer or float: ");
fprint(stderr, n);
fprint(stderr, "\n");
fprint(std::cerr, "random: argument should be positive and an integer or float: ");
fprint(std::cerr, n);
fprint(std::cerr, "\n");
cl_abort();
}

12
tests/exam.h

@ -53,9 +53,9 @@ static int test_##typename##_##opname (void) \
rtype computed_result = arg1 op arg2; \
rtype result = rtype(test.result); \
if (computed_result != result) { \
stderr << "Error in " #typename "_" #opname "_tests[" << i << "] !" << endl; \
stderr << "Result should be: " << result << endl; \
stderr << "Result computed : " << computed_result << endl << endl; \
std::cerr << "Error in " #typename "_" #opname "_tests[" << i << "] !" << endl; \
std::cerr << "Result should be: " << result << endl; \
std::cerr << "Result computed : " << computed_result << endl << endl; \
error = 1; \
} \
} \
@ -74,9 +74,9 @@ static int test_##typename##_floor (void) \
cl_I result1 = cl_I(test.result1); \
type result2 = type(test.result2); \
if ((computed_result.quotient != result1) || (computed_result.remainder != result2)) { \
stderr << "Error in " #typename "_floor_tests[" << i << endl; \
stderr << "Results should be: " << result1 << ", " << result2 << endl; \
stderr << "Results computed : " << computed_result.quotient << ", " << computed_result.remainder << endl << endl; \
std::cerr << "Error in " #typename "_floor_tests[" << i << endl; \
std::cerr << "Results should be: " << result1 << ", " << result2 << endl; \
std::cerr << "Results computed : " << computed_result.quotient << ", " << computed_result.remainder << endl << endl; \
error = 1; \
} \
} \

8
tests/exam_I_gcd.cc

@ -7,7 +7,7 @@ using namespace cln;
#define ASSERT(expr) \
if (!(expr)) { \
stderr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
std::cerr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
error = 1; \
}
@ -31,9 +31,9 @@ static int test_##typename##_##opname (void) \
rtype computed_result = opname(arg1,arg2); \
rtype result = rtype(test.result); \
if (computed_result != result) { \
stderr << "Error in " #typename "_" #opname "_tests[" << i << "] !" << endl; \
stderr << "Result should be: " << result << endl; \
stderr << "Result computed : " << computed_result << endl << endl; \
std::cerr << "Error in " #typename "_" #opname "_tests[" << i << "] !" << endl; \
std::cerr << "Result should be: " << result << endl; \
std::cerr << "Result computed : " << computed_result << endl << endl; \
error = 1; \
} \
} \

18
tests/main.cc

@ -13,7 +13,7 @@
#include <cln/timing.h>
#define DUMP(expr) \
fprint(stdout, #expr" = "); fprint(stdout, expr); fprint(stdout, "\n");
fprint(cout, #expr" = "); fprint(cout, expr); fprint(cout, "\n");
int main (int argc, char* argv[])
{
@ -21,8 +21,8 @@ int main (int argc, char* argv[])
#if 0
cl_F archimedes = pi((float_format_t)10000);
fprint(stdout, archimedes);
fprint(stdout, "\n");
fprint(cout, archimedes);
fprint(cout, "\n");
#endif
#if 0
@ -30,11 +30,11 @@ int main (int argc, char* argv[])
cl_FF x1 = "-0.2173f0";
cl_FF x2 = "5.5084f9";
cl_FF y = "-1.19698f9";
fprint(stdout, "x1 = "); print_float_binary(stdout,x1); fprint(stdout, " = "); fprint(stdout,x1); fprint(stdout, "\n");
fprint(stdout, "x2 = "); print_float_binary(stdout,x2); fprint(stdout, " = "); fprint(stdout,x2); fprint(stdout, "\n");
fprint(stdout, "y = "); print_float_binary(stdout,y); fprint(stdout, " = "); fprint(stdout,y); fprint(stdout, "\n");
fprint(cout, "x1 = "); print_float_binary(cout,x1); fprint(cout, " = "); fprint(cout,x1); fprint(cout, "\n");
fprint(cout, "x2 = "); print_float_binary(cout,x2); fprint(cout, " = "); fprint(cout,x2); fprint(cout, "\n");
fprint(cout, "y = "); print_float_binary(cout,y); fprint(cout, " = "); fprint(cout,y); fprint(cout, "\n");
cl_FF x = x1*x2;
fprint(stdout, "x1*x2 = "); print_float_binary(stdout,x); fprint(stdout, " = "); fprint(stdout,x); fprint(stdout, "\n");
fprint(cout, "x1*x2 = "); print_float_binary(cout,x); fprint(cout, " = "); fprint(cout,x); fprint(cout, "\n");
#endif
#if 0
@ -42,8 +42,8 @@ int main (int argc, char* argv[])
cl_I y = ++x;
x *= 2;
x++;
fprint(stdout, "x = "); fprint(stdout, x); fprint(stdout, "\n");
fprint(stdout, "y = "); fprint(stdout, y); fprint(stdout, "\n");
fprint(cout, "x = "); fprint(cout, x); fprint(cout, "\n");
fprint(cout, "y = "); fprint(cout, y); fprint(cout, "\n");
#endif
#if 0

30
tests/test.h

@ -4,40 +4,40 @@ using namespace cln;
#define ASSERT(expr) \
if (!(expr)) { \
stderr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
std::cerr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
error = 1; \
}
#define ASSERT1(expr,a) \
if (!(expr)) { \
stderr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
stderr << #a" = " << a << endl; \
std::cerr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
std::cerr << #a" = " << a << endl; \
error = 1; \
}
#define ASSERT2(expr,a,b) \
if (!(expr)) { \
stderr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
stderr << #a" = " << a << endl; \
stderr << #b" = " << b << endl; \
std::cerr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
std::cerr << #a" = " << a << endl; \
std::cerr << #b" = " << b << endl; \
error = 1; \
}
#define ASSERT3(expr,a,b,c) \
if (!(expr)) { \
stderr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
stderr << #a" = " << a << endl; \
stderr << #b" = " << b << endl; \
stderr << #c" = " << c << endl; \
std::cerr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
std::cerr << #a" = " << a << endl; \
std::cerr << #b" = " << b << endl; \
std::cerr << #c" = " << c << endl; \
error = 1; \
}
#define ASSERT4(expr,a,b,c,d) \
if (!(expr)) { \
stderr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
stderr << #a" = " << a << endl; \
stderr << #b" = " << b << endl; \
stderr << #c" = " << c << endl; \
stderr << #d" = " << d << endl; \
std::cerr << "Assertion failed! File " << __FILE__ << ", line " << __LINE__ << endl; \
std::cerr << #a" = " << a << endl; \
std::cerr << #b" = " << b << endl; \
std::cerr << #c" = " << c << endl; \
std::cerr << #d" = " << d << endl; \
error = 1; \
}

12
tests/timeMImisc5.cc

@ -20,17 +20,17 @@ int main (int argc, char * argv[])
{
cl_MI a = R->canonhom("1111111111111111111111111111111111111111111111111");
cl_MI b = R->canonhom("777777777777777777777777777777777777777777777777");
stdout << "product modulo p" << endl;
cout << "product modulo p" << endl;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_MI c = R->mul(a,b); }
}
stdout << "square modulo p" << endl;
cout << "square modulo p" << endl;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_MI c = R->square(a); }
}
stdout << "quotient modulo p" << endl;
cout << "quotient modulo p" << endl;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_MI c = R->div(a,b); }
@ -39,17 +39,17 @@ int main (int argc, char * argv[])
{
cl_MI a = R->canonhom("1234567890123456789012345678901234567890123456789");
cl_MI b = R->canonhom("909090909090909090909090909090909090909090909090");
stdout << "product modulo p" << endl;
cout << "product modulo p" << endl;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_MI c = R->mul(a,b); }
}
stdout << "square modulo p" << endl;
cout << "square modulo p" << endl;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_MI c = R->square(a); }
}
stdout << "quotient modulo p" << endl;
cout << "quotient modulo p" << endl;
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_MI c = R->div(a,b); }

4
tests/timeUPMImul.cc

@ -28,7 +28,7 @@ int main (int argc, char * argv[])
p1.set_coeff(i, R1->canonhom((int)(1.618033989*i*i)));
p1.finalize();
stdout << p1 << endl;
cout << p1 << endl;
cl_UP sp1 = PR1->zero();
{ CL_TIMING;
@ -36,7 +36,7 @@ int main (int argc, char * argv[])
{ sp1 = square(p1); }
}
stdout << sp1 << endl;
cout << sp1 << endl;
}
// Time:

4
tests/timepi.cc

@ -52,9 +52,9 @@ int main (int argc, char * argv[])
int n = atoi(argv[1]);
float_format_t prec = float_format(n);
cl_F p;
stderr << "Computing pi" << endl;
cerr << "Computing pi" << endl;
{ CL_TIMING; p = pi(prec); }
stderr << "Converting pi to decimal" << endl;
cerr << "Converting pi to decimal" << endl;
{ CL_TIMING; cout << p << endl << endl; }
#endif
}

4
tests/timesquare.cc

@ -21,12 +21,12 @@ int main (int argc, char * argv[])
cl_I M2 = (cl_I)1 << (intDsize*m2);
cl_I a = random_I(M1);
cl_I b = random_I(M2);
fprint(stderr, "Squaring: ");
fprint(std::cerr, "Squaring: ");
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_I p = a * a; }
}
fprint(stderr, "Multiplication: ");
fprint(std::cerr, "Multiplication: ");
{ CL_TIMING;
for (int rep = repetitions; rep > 0; rep--)
{ cl_I p = a * b; }

Loading…
Cancel
Save