457
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
457
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
457
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (octave_DET_h) |
|
25 #define octave_DET_h 1 |
|
26 |
3503
|
27 #include <iostream> |
457
|
28 |
5775
|
29 // FIXME -- we could use templates here; compare with CmplxDET.h |
5634
|
30 |
1881
|
31 class |
6108
|
32 OCTAVE_API |
1881
|
33 DET |
457
|
34 { |
532
|
35 friend class Matrix; |
5164
|
36 friend class SparseMatrix; |
532
|
37 |
457
|
38 public: |
|
39 |
5634
|
40 DET (void) : c2 (0), c10 (0), e2 (0), e10 (0), base2 (false) { } |
1528
|
41 |
|
42 DET (const DET& a) |
5634
|
43 : c2 (a.c2), c10 (a.c10), e2 (a.e2), e10 (a.e10), base2 (a.base2) |
|
44 { } |
457
|
45 |
1528
|
46 DET& operator = (const DET& a) |
|
47 { |
1881
|
48 if (this != &a) |
|
49 { |
5634
|
50 c2 = a.c2; |
|
51 e2 = a.e2; |
|
52 |
|
53 c10 = a.c10; |
|
54 e10 = a.e10; |
|
55 |
|
56 base2 = a.base2; |
1881
|
57 } |
1528
|
58 return *this; |
|
59 } |
457
|
60 |
5634
|
61 bool value_will_overflow (void) const; |
|
62 bool value_will_underflow (void) const; |
|
63 |
|
64 // These two functions were originally defined in base 10, so we are |
|
65 // preserving that interface here. |
1528
|
66 |
5634
|
67 double coefficient (void) const { return coefficient10 (); } |
|
68 int exponent (void) const { return exponent10 (); } |
1528
|
69 |
5634
|
70 double coefficient10 (void) const { return c10; } |
|
71 int exponent10 (void) const { return e10; } |
|
72 |
|
73 double coefficient2 (void) const { return c2; } |
|
74 int exponent2 (void) const { return e2; } |
1528
|
75 |
457
|
76 double value (void) const; |
|
77 |
3504
|
78 friend std::ostream& operator << (std::ostream& os, const DET& a); |
457
|
79 |
|
80 private: |
|
81 |
5634
|
82 // Constructed this way, we assume base 2. |
|
83 |
|
84 DET (double c, int e) |
|
85 : c2 (c), c10 (0), e2 (e), e10 (0), base2 (true) |
1528
|
86 { |
5634
|
87 initialize10 (); |
1528
|
88 } |
457
|
89 |
5634
|
90 // Original interface had only this constructor and it was assumed |
|
91 // to be base 10, so we are preserving that interface here. |
|
92 |
|
93 DET (const double *d) |
|
94 : c2 (0), c10 (d[0]), e2 (0), e10 (static_cast<int> (d[1])), base2 (false) |
|
95 { |
|
96 initialize2 (); |
|
97 } |
|
98 |
|
99 void initialize2 (void); |
|
100 void initialize10 (void); |
|
101 |
|
102 double c2; |
|
103 double c10; |
|
104 |
|
105 int e2; |
|
106 int e10; |
|
107 |
|
108 // TRUE means the original values were provided in base 2. |
|
109 bool base2; |
457
|
110 }; |
|
111 |
|
112 #endif |
|
113 |
|
114 /* |
|
115 ;;; Local Variables: *** |
|
116 ;;; mode: C++ *** |
|
117 ;;; End: *** |
|
118 */ |