annotate liboctave/lo-ieee.cc @ 14138:72c96de7a403 stable

maint: update copyright notices for 2012
author John W. Eaton <jwe@octave.org>
date Mon, 02 Jan 2012 14:25:41 -0500
parents fd0a3ac60b0e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
1 /*
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
2
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
3 Copyright (C) 1996-2012 John W. Eaton
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
4
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
6
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
10 option) any later version.
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
11
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
15 for more details.
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
16
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
19 <http://www.gnu.org/licenses/>.
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
20
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
21 */
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
22
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
25 #endif
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
26
9592
5828d64ca004 lo-ieee.cc: include cstdlib, update copyright date
John W. Eaton <jwe@octave.org>
parents: 9591
diff changeset
27 #include <cstdlib>
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
28
11234
2718e1fdf82f IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents: 11230
diff changeset
29 #include <limits>
2508
f8d5dbbbc50a [project @ 1996-11-13 17:21:07 by jwe]
jwe
parents: 1993
diff changeset
30
4698
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
31 #include "lo-error.h"
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
32 #include "lo-ieee.h"
4025
cfb762dc9259 [project @ 2002-08-09 06:32:15 by jwe]
jwe
parents: 3475
diff changeset
33 #include "mach-info.h"
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
34
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
35 void
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
36 octave_ieee_init (void)
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
37 {
4601
1ed6cfbc8ea4 [project @ 2003-11-12 18:30:29 by jwe]
jwe
parents: 4574
diff changeset
38 oct_mach_info::float_format ff = oct_mach_info::native_float_format ();
1ed6cfbc8ea4 [project @ 2003-11-12 18:30:29 by jwe]
jwe
parents: 4574
diff changeset
39
4698
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
40 switch (ff)
4601
1ed6cfbc8ea4 [project @ 2003-11-12 18:30:29 by jwe]
jwe
parents: 4574
diff changeset
41 {
4698
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
42 case oct_mach_info::flt_fmt_ieee_big_endian:
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
43 case oct_mach_info::flt_fmt_ieee_little_endian:
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
44 {
11234
2718e1fdf82f IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents: 11230
diff changeset
45 octave_NaN = std::numeric_limits<double>::quiet_NaN ();
2718e1fdf82f IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents: 11230
diff changeset
46 octave_Inf = std::numeric_limits<double>::infinity ();
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
47
11234
2718e1fdf82f IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents: 11230
diff changeset
48 octave_Float_NaN = std::numeric_limits<float>::quiet_NaN ();
2718e1fdf82f IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents: 11230
diff changeset
49 octave_Float_Inf = std::numeric_limits<float>::infinity ();
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
50
11234
2718e1fdf82f IEEE math initialization tweaks
John W. Eaton <jwe@octave.org>
parents: 11230
diff changeset
51 // The following is patterned after code in R.
4698
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
52
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
53 if (ff == oct_mach_info::flt_fmt_ieee_big_endian)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
54 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
55 lo_ieee_hw = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
56 lo_ieee_lw = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
57 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
58 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
59 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
60 lo_ieee_hw = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
61 lo_ieee_lw = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
62 }
4025
cfb762dc9259 [project @ 2002-08-09 06:32:15 by jwe]
jwe
parents: 3475
diff changeset
63
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
64 lo_ieee_double t;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
65 t.word[lo_ieee_hw] = LO_IEEE_NA_HW;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
66 t.word[lo_ieee_lw] = LO_IEEE_NA_LW;
4698
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
67
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
68 octave_NA = t.value;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7231
diff changeset
69
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
70 lo_ieee_float tf;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
71 tf.word = LO_IEEE_NA_FLOAT;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
72 octave_Float_NA = tf.value;
4698
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
73 }
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
74 break;
4025
cfb762dc9259 [project @ 2002-08-09 06:32:15 by jwe]
jwe
parents: 3475
diff changeset
75
4698
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
76 case oct_mach_info::flt_fmt_cray:
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
77 case oct_mach_info::flt_fmt_vax_d:
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
78 case oct_mach_info::flt_fmt_vax_g:
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
79 default:
737fd5c0ae06 [project @ 2004-01-19 19:25:26 by jwe]
jwe
parents: 4603
diff changeset
80 // If the format is unknown, then you will probably not have a
9805
bb70d16cca3b fail at configure time if IEEE floating point format is not detected
John W. Eaton <jwe@octave.org>
parents: 9592
diff changeset
81 // useful system, so we will abort here. Anyone wishing to
bb70d16cca3b fail at configure time if IEEE floating point format is not detected
John W. Eaton <jwe@octave.org>
parents: 9592
diff changeset
82 // experiment with building Octave on a system without IEEE
bb70d16cca3b fail at configure time if IEEE floating point format is not detected
John W. Eaton <jwe@octave.org>
parents: 9592
diff changeset
83 // floating point should be capable of removing this check and
bb70d16cca3b fail at configure time if IEEE floating point format is not detected
John W. Eaton <jwe@octave.org>
parents: 9592
diff changeset
84 // the configure test.
9591
264fb5520973 abort if floating point format is not recognized as IEEE
John W. Eaton <jwe@octave.org>
parents: 9441
diff changeset
85 (*current_liboctave_error_handler)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
86 ("lo_ieee_init: floating point format is not IEEE! Maybe DLAMCH is miscompiled, or you are using some strange system without IEEE floating point math?");
9591
264fb5520973 abort if floating point format is not recognized as IEEE
John W. Eaton <jwe@octave.org>
parents: 9441
diff changeset
87 abort ();
4601
1ed6cfbc8ea4 [project @ 2003-11-12 18:30:29 by jwe]
jwe
parents: 4574
diff changeset
88 }
1967
4cb6aaa0f2c7 [project @ 1996-02-17 02:54:24 by jwe]
jwe
parents:
diff changeset
89 }