/usr/share/doc/libntl-dev/NTL/tools.txt is in libntl-dev 9.9.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | /**************************************************************************\
MODULE: tools
SUMMARY:
Some useful tools that are used throughout NTL.
\**************************************************************************/
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <NTL/config.h>
#include <NTL/mach_desc.h>
double GetTime();
// returns number of seconds of CPU time used by this process;
void PrintTime(ostream& s, double t);
// prints the time t (in seconds) to s in the format
// ss or mm:ss or hh:mm:ss,
// where the value t is first rounded to the nearest integer.
long IsWhiteSpace(long c);
// returns 1 if c is "white space" (as defined by isspace is the
// standard library...usually blanks, tabs, newlines), and 0 otherwise.
long SkipWhiteSpace(istream& s);
// skips white space (as defined by IsWhiteSpace).
// Return value is 0 if end-of-file is reached; otherwise,
// return value is 1.
long IsEOFChar(long c);
// test if c == EOF
long CharToIntVal(long c);
// returns the hexidecimal value of c if c is '0'..'9', 'A'..'F', or 'a'..'f';
// otherwise, the return value is -1.
char IntValToChar(long x);
// returns the hexadecimal digit '0'..'9', 'a'..'f' representing x;
// an error is raised if x < 0 or x > 15.
long IsFinite(double *p);
// Returns 1 if *p is a "finite" floating point number.
// A pointer is used to ensure that the number is in memory,
// which on some architectures (notably x86/Pentium) can make a difference.
// some min/max and swap routines:
int min(int a, int b);
int max(int a, int b);
long min(long a, long b);
long max(long a, long b);
long min(int a, long b);
long max(int a, long b);
long min(long a, int b);
long max(long a, int b);
unsigned int min(unsigned int a, unsigned int b);
unsigned int max(unsigned int a, unsigned int b);
unsigned long min(unsigned long a, unsigned long b);
unsigned long max(unsigned long a, unsigned long b);
unsigned long min(unsigned int a, unsigned long b);
unsigned long max(unsigned int a, unsigned long b);
unsigned long min(unsigned long a, unsigned int b);
unsigned long max(unsigned long a, unsigned int b);
void swap(long& a, long& b);
void swap(int& a, int& b);
// defined here are all the conversion routines among the types
// int, long, float, double. See conversions.txt for complete details.
// The following platform-dependent macros are defined:
#define NTL_BITS_PER_LONG (...) /* bits in a long */
#define NTL_MAX_LONG (...) /* max value of a long */
#define NTL_MIN_LONG (...) /* min value of a long */
#define NTL_BITS_PER_INT (...) /* bits in a int */
#define NTL_MAX_INT (...) /* max value of a int */
#define NTL_MIN_INT (...) /* min value of a int */
#define NTL_DOUBLE_PRECISION (...) /* # of bits of precision in a double */
#define NTL_FDOUBLE_PRECISION (...) /* the double value
2^{NTL_DOUBLE_PRECISION-1} */
#define NTL_ARITH_RIGHT_SHIFT (...) /* 1 if signed right-shift is
arithmetic; 0 otherwise */
#define NTL_EXT_DOUBLE (...) /* 1 if platform has "extended" doubles;
0 otherwise */
// ERROR HANDLING
void TerminalError(const char *s);
// print an error message and call abort
extern void (*ErrorMsgCallback)(const char *);
extern void (*ErrorCallback)();
// Pointers (initially NULL) to callback functions.
// Upon encountering an unrecoverable error with an error
// message s, the following happens:
//
// if (ErrorMsgCallback)
// (*ErrorMsgCallback)(s);
// else
// cerr << s << "\n";
//
// if (ErrorCallback) (*ErrorCallback)();
// abort();
//
// NOTE: if threads are enabled, these are actually thread_local variables.
// The following classes are defined even if exceptions are not
// enabled with NTL_EXCEPTIONS
class ErrorObject : public runtime_error {
public:
ErrorObject(const char *msg);
};
class LogicErrorObject : public ErrorObject {
public:
LogicErrorObject(const char *msg);
};
class ArithmeticErrorObject : public ErrorObject {
public:
ArithmeticErrorObject(const char *msg);
};
class ResourceErrorObject : public ErrorObject {
public:
ResourceErrorObject(const char *msg);
};
class FileErrorObject : public ErrorObject {
public:
FileErrorObject(const char *msg);
};
class InputErrorObject : public ErrorObject {
public:
InputErrorObject(const char *msg);
};
// The following functions throw the indicated exception if
// exceptions are enabled with NTL_EXCEPTIONS; otherwise,
// they simply invoke TerminalError.
void MemoryError();
// throws bad_alloc
void Error(const char *msg);
// throws ErrorObject
void LogicError(const char *msg);
// throws LogicErrorObject
void ArithmeticError(const char *msg);
// throws ArithmeticErrorObject
void ResourceError(const char *msg);
// throws ResourceErrorObject
void FileError(const char *msg);
// throws FileErrorObject
void InputError(const char *msg);
// throws InputErrorObject
|