source: git/ntl/doc/tools.txt @ 26e030

spielwiese
Last change on this file since 26e030 was 26e030, checked in by Hans Schönemann <hannes@…>, 15 years ago
*hannes: update to 5.5.1 git-svn-id: file:///usr/local/Singular/svn/trunk@11949 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.4 KB
Line 
1
2/**************************************************************************\
3
4MODULE: tools
5
6SUMMARY:
7
8Some useful tools that are used throughout NTL.
9
10\**************************************************************************/
11
12#include <cstdlib>
13#include <cmath>
14#include <iostream>
15
16#include <NTL/config.h>
17#include <NTL/mach_desc.h>
18
19
20
21
22double GetTime();
23// returns number of seconds of CPU time used by this process;
24
25void PrintTime(ostream& s, double t);
26// prints the time t (in seconds) to s in the format
27//     ss  or  mm:ss  or  hh:mm:ss,
28// where the value t is first rounded to the nearest integer.
29
30void Error(const char *s);
31// print an error message and call abort
32
33extern void (*ErrorCallback)();
34// A pointer (initially NULL) to a callback function.
35// This function will be called by the Error function,
36// as well as other functions, before calling abort().
37// Note that the callback function is expected to have
38// C++ linkage, as it is called directly by a C++ function,
39// even though the latter function may be called from a
40// C function.
41
42long IsWhiteSpace(long c);
43// returns 1 if c is "wite space" (as defined by isspace is the
44// standard library...usually blanks, tabs, newlines), and 0 otherwise.
45
46long SkipWhiteSpace(istream& s);
47// skips white space (as defined by IsWhiteSpace).
48// Return value is 0 if end-of-file is reached; otherwise,
49// return value is 1.
50
51// This routine is useful in conjuction with input routines,
52// like NTL's, that raise an error if an input item is
53// ill-formed or missing. 
54
55long IsEOFChar(long c);
56// test if c == EOF
57
58
59long CharToIntVal(long c);
60// returns the hexidecimal value of c if c is '0'..'9', 'A'..'F', or 'a'..'f';
61// otherwise, the return value is -1.
62
63char IntValToChar(long x);
64// returns the hexadecimal digit '0'..'9', 'a'..'f' representing x;
65// an error is raised if x < 0 or x > 15.
66
67long IsFinite(double *p);
68// Returns 1 if *p is a "finite" floating point number.
69// A pointer is used to ensure that the number is in memory,
70// which on some architectures (notably x86/Pentium) can make a difference.
71
72// some min/max and swap routines:
73
74int min(int a, int b);
75int max(int a, int b);
76
77long min(long a, long b);
78long max(long a, long b);
79
80long min(int a, long b);
81long max(int a, long b);
82
83long min(long a, int b);
84long max(long a, int b);
85
86void swap(long& a, long& b);
87void swap(int& a, int& b);
88
89
90// defined here are all the conversion routines among the types
91// int, long, float, double.  See conversions.txt for complete details.
92
93
94// The following platform-dependent macros are defined:
95
96#define NTL_BITS_PER_LONG      (...)  /* bits in a long */
97#define NTL_MAX_LONG           (...)  /* max value of a long */
98#define NTL_MIN_LONG           (...)  /* min value of a long */
99
100#define NTL_BITS_PER_INT       (...)  /* bits in a int */
101#define NTL_MAX_INT            (...)  /* max value of a int */
102#define NTL_MIN_INT            (...)  /* min value of a int */
103
104#define NTL_DOUBLE_PRECISION   (...)  /* # of bits of precision in a double */
105#define NTL_FDOUBLE_PRECISION  (...)  /* the double value
106                                        2^{NTL_DOUBLE_PRECISION-1} */
107
108#define NTL_ARITH_RIGHT_SHIFT  (...)  /* 1 if signed right-shift is
109                                        arithmetic; 0 otherwise */
110
111#define NTL_EXT_DOUBLE         (...)  /* 1 if platform has "extended" doubles;
112                                        0 otherwise */
113
114
115
Note: See TracBrowser for help on using the repository browser.