annotate liboctave/CmplxDET.cc @ 7016:93c65f2a5668

[project @ 2007-10-12 06:40:56 by jwe]
author jwe
date Fri, 12 Oct 2007 06:41:26 +0000
parents bda649f500bd
children a1dbe9d80eee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
1 /*
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
2
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 1993
diff changeset
3 Copyright (C) 1996, 1997 John W. Eaton
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
4
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
6
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 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: 6018
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: 6018
diff changeset
10 option) any later version.
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
11
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
15 for more details.
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
16
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 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: 6018
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: 6018
diff changeset
19 <http://www.gnu.org/licenses/>.
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
20
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
21 */
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
22
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
1192
b6360f2d4fa6 [project @ 1995-03-30 21:38:35 by jwe]
jwe
parents: 1011
diff changeset
24 #include <config.h>
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
25 #endif
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
26
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
27 #include <cassert>
1367
9f9131a8d706 [project @ 1995-09-06 00:07:03 by jwe]
jwe
parents: 1315
diff changeset
28 #include <cfloat>
9f9131a8d706 [project @ 1995-09-06 00:07:03 by jwe]
jwe
parents: 1315
diff changeset
29 #include <cmath>
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
30
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
31 #include "CmplxDET.h"
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
32 #include "lo-mappers.h"
1650
23aa282707e8 [project @ 1995-12-20 06:53:12 by jwe]
jwe
parents: 1367
diff changeset
33 #include "oct-cmplx.h"
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
34
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
35 bool
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
36 ComplexDET::value_will_overflow (void) const
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
37 {
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
38 return base2
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5634
diff changeset
39 ? (e2 + 1 > xlog2 (DBL_MAX) ? 1 : 0)
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
40 : (e10 + 1 > log10 (DBL_MAX) ? 1 : 0);
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
41 }
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
42
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
43 bool
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
44 ComplexDET::value_will_underflow (void) const
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
45 {
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
46 return base2
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5634
diff changeset
47 ? (e2 - 1 < xlog2 (DBL_MIN) ? 1 : 0)
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
48 : (e10 - 1 < log10 (DBL_MIN) ? 1 : 0);
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
49 }
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
50
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
51 void
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
52 ComplexDET::initialize10 (void)
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
53 {
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
54 if (c2 != 0.0)
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
55 {
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5634
diff changeset
56 double etmp = e2 / xlog2 (10);
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5634
diff changeset
57 e10 = static_cast<int> (xround (etmp));
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
58 etmp -= e10;
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
59 c10 = c2 * pow (10.0, etmp);
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
60 }
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
61 }
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
62
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
63 void
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
64 ComplexDET::initialize2 (void)
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
65 {
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
66 if (c10 != 0.0)
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
67 {
6018
bda649f500bd [project @ 2006-10-02 17:23:18 by jwe]
jwe
parents: 5904
diff changeset
68 double etmp = e10 / log10 (2.0);
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5634
diff changeset
69 e2 = static_cast<int> (xround (etmp));
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
70 etmp -= e2;
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5634
diff changeset
71 c2 = c10 * xexp2 (etmp);
5634
4b45b2bcda89 [project @ 2006-03-02 03:40:00 by jwe]
jwe
parents: 5307
diff changeset
72 }
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
73 }
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
74
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
75 Complex
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
76 ComplexDET::value (void) const
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
77 {
5904
80d3933fb8b6 [project @ 2006-07-26 17:19:10 by jwe]
jwe
parents: 5634
diff changeset
78 return base2 ? c2 * xexp2 (e2) : c10 * pow (10.0, e10);
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
79 }
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
80
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
81 /*
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
82 ;;; Local Variables: ***
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
83 ;;; mode: C++ ***
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
84 ;;; End: ***
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
85 */