1tclrep/machineparameters(n)         tclrep         tclrep/machineparameters(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       tclrep/machineparameters - Compute double precision machine parameters.
9

SYNOPSIS

11       package require Tcl  8.4
12
13       package require snit
14
15       package require math::machineparameters  0.1
16
17       machineparameters create objectname ?options...?
18
19       objectname configure ?options...?
20
21       objectname cget opt
22
23       objectname destroy
24
25       objectname compute
26
27       objectname get key
28
29       objectname tostring
30
31       objectname print
32
33______________________________________________________________________________
34

DESCRIPTION

36       The math::machineparameters package is the Tcl equivalent of the DLAMCH
37       LAPACK function.  In floating point systems, a floating point number is
38       represented by
39
40
41              x = +/- d1 d2 ... dt basis^e
42
43       where digits satisfy
44
45
46              0 <= di <= basis - 1, i = 1, t
47
48       with the convention :
49
50       ·      t is the size of the mantissa
51
52       ·      basis is the basis (the "radix")
53
54       The  compute  method  computes  all  machine parameters.  Then, the get
55       method can be used to get each parameter.  The print  method  prints  a
56       report on standard output.
57

EXAMPLE

59       In the following example, one compute the parameters of a desktop under
60       Linux with the following Tcl 8.4.19 properties :
61
62
63              % parray tcl_platform
64              tcl_platform(byteOrder) = littleEndian
65              tcl_platform(machine)   = i686
66              tcl_platform(os)        = Linux
67              tcl_platform(osVersion) = 2.6.24-19-generic
68              tcl_platform(platform)  = unix
69              tcl_platform(tip,268)   = 1
70              tcl_platform(tip,280)   = 1
71              tcl_platform(user)      = <username>
72              tcl_platform(wordSize)  = 4
73
74       The following example creates a machineparameters object, computes  the
75       properties and displays it.
76
77
78                   set pp [machineparameters create %AUTO%]
79                   $pp compute
80                   $pp print
81                   $pp destroy
82
83       This prints out :
84
85
86                   Machine parameters
87                   Epsilon : 1.11022302463e-16
88                   Beta : 2
89                   Rounding : proper
90                   Mantissa : 53
91                   Maximum exponent : 1024
92                   Minimum exponent : -1021
93                   Overflow threshold : 8.98846567431e+307
94                   Underflow threshold : 2.22507385851e-308
95
96       That compares well with the results produced by Lapack 3.1.1 :
97
98
99                   Epsilon                      =   1.11022302462515654E-016
100                   Safe minimum                 =   2.22507385850720138E-308
101                   Base                         =    2.0000000000000000
102                   Precision                    =   2.22044604925031308E-016
103                   Number of digits in mantissa =    53.000000000000000
104                   Rounding mode                =   1.00000000000000000
105                   Minimum exponent             =   -1021.0000000000000
106                   Underflow threshold          =   2.22507385850720138E-308
107                   Largest exponent             =    1024.0000000000000
108                   Overflow threshold           =   1.79769313486231571E+308
109                   Reciprocal of safe minimum   =   4.49423283715578977E+307
110
111       The  following example creates a machineparameters object, computes the
112       properties and gets the epsilon for the machine.
113
114
115                   set pp [machineparameters create %AUTO%]
116                   $pp compute
117                   set eps [$pp get -epsilon]
118                   $pp destroy
119
120

REFERENCES

122       ·      "Algorithms to Reveal Properties of Floating-Point  Arithmetic",
123              Michael  A.  Malcolm, Stanford University, Communications of the
124              ACM, Volume 15 ,  Issue 11  (November 1972), Pages: 949 - 951
125
126       ·      "More on Algorithms that Reveal Properties  of  Floating,  Point
127              Arithmetic  Units", W. Morven Gentleman, University of Waterloo,
128              Scott B. Marovich, Purdue University, Communications of the ACM,
129              Volume 17 ,  Issue 5  (May 1974), Pages: 276 - 277
130

CLASS API

132       machineparameters create objectname ?options...?
133              The  command  creates a new machineparameters object and returns
134              the fully qualified name of the object command as its result.
135
136              -verbose verbose
137                     Set this option to 1 to  enable  verbose  logging.   This
138                     option  is  mainly for debug purposes.  The default value
139                     of verbose is 0.
140

OBJECT API

142       objectname configure ?options...?
143              The command configure the options of the object objectname.  The
144              options are the same as the static method create.
145
146       objectname cget opt
147              Returns  the  value of the option which name is opt. The options
148              are the same as the method create and configure.
149
150       objectname destroy
151              Destroys the object objectname.
152
153       objectname compute
154              Computes the machine parameters.
155
156       objectname get key
157              Returns the value corresponding with given key.   The  following
158              is the list of available keys.
159
160              ·      -epsilon : smallest value so that 1+epsilon>1 is false
161
162              ·      -rounding  :  The rounding mode used on the machine.  The
163                     rounding occurs when more than t digits would be required
164                     to  represent  the  number.   Two modes can be determined
165                     with the current system : "chop" means than only t digits
166                     are  kept,  no  matter  the  value of the number "proper"
167                     means that another rounding mode is used, be it "round to
168                     nearest", "round up", "round down".
169
170              ·      -basis  : the basis of the floating-point representation.
171                     The basis is usually 2, i.e. binary  representation  (for
172                     example  IEEE  754  machines), but some machines (like HP
173                     calculators for example) uses 10, or 16, etc...
174
175              ·      -mantissa : the number of bits in the mantissa
176
177              ·      -exponentmax :   the  largest  positive  exponent  before
178                     overflow occurs
179
180              ·      -exponentmin  :  the  largest  negative  exponent  before
181                     (gradual) underflow occurs
182
183              ·      -vmax : largest positive value before overflow occurs
184
185              ·      -vmin : largest negative value before (gradual) underflow
186                     occurs
187
188       objectname tostring
189              Return a report for machine parameters.
190
191       objectname print
192              Print machine parameters on standard output.
193

BUGS, IDEAS, FEEDBACK

195       This  document,  and the package it describes, will undoubtedly contain
196       bugs and other problems.  Please report such in the  category  math  of
197       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
198       also report any ideas for enhancements you may have for either  package
199       and/or documentation.
200
201       When proposing code changes, please provide unified diffs, i.e the out‐
202       put of diff -u.
203
204       Note further that  attachments  are  strongly  preferred  over  inlined
205       patches.  Attachments  can  be  made  by  going to the Edit form of the
206       ticket immediately after its creation, and  then  using  the  left-most
207       button in the secondary navigation bar.
208
210       Copyright (c) 2008 Michael Baudin <michael.baudin@sourceforge.net>
211
212
213
214
215tcllib                                1.0          tclrep/machineparameters(n)
Impressum