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 |
|
32 DET |
457
|
33 { |
532
|
34 friend class Matrix; |
5164
|
35 friend class SparseMatrix; |
532
|
36 |
457
|
37 public: |
|
38 |
5634
|
39 DET (void) : c2 (0), c10 (0), e2 (0), e10 (0), base2 (false) { } |
1528
|
40 |
|
41 DET (const DET& a) |
5634
|
42 : c2 (a.c2), c10 (a.c10), e2 (a.e2), e10 (a.e10), base2 (a.base2) |
|
43 { } |
457
|
44 |
1528
|
45 DET& operator = (const DET& a) |
|
46 { |
1881
|
47 if (this != &a) |
|
48 { |
5634
|
49 c2 = a.c2; |
|
50 e2 = a.e2; |
|
51 |
|
52 c10 = a.c10; |
|
53 e10 = a.e10; |
|
54 |
|
55 base2 = a.base2; |
1881
|
56 } |
1528
|
57 return *this; |
|
58 } |
457
|
59 |
5634
|
60 bool value_will_overflow (void) const; |
|
61 bool value_will_underflow (void) const; |
|
62 |
|
63 // These two functions were originally defined in base 10, so we are |
|
64 // preserving that interface here. |
1528
|
65 |
5634
|
66 double coefficient (void) const { return coefficient10 (); } |
|
67 int exponent (void) const { return exponent10 (); } |
1528
|
68 |
5634
|
69 double coefficient10 (void) const { return c10; } |
|
70 int exponent10 (void) const { return e10; } |
|
71 |
|
72 double coefficient2 (void) const { return c2; } |
|
73 int exponent2 (void) const { return e2; } |
1528
|
74 |
457
|
75 double value (void) const; |
|
76 |
3504
|
77 friend std::ostream& operator << (std::ostream& os, const DET& a); |
457
|
78 |
|
79 private: |
|
80 |
5634
|
81 // Constructed this way, we assume base 2. |
|
82 |
|
83 DET (double c, int e) |
|
84 : c2 (c), c10 (0), e2 (e), e10 (0), base2 (true) |
1528
|
85 { |
5634
|
86 initialize10 (); |
1528
|
87 } |
457
|
88 |
5634
|
89 // Original interface had only this constructor and it was assumed |
|
90 // to be base 10, so we are preserving that interface here. |
|
91 |
|
92 DET (const double *d) |
|
93 : c2 (0), c10 (d[0]), e2 (0), e10 (static_cast<int> (d[1])), base2 (false) |
|
94 { |
|
95 initialize2 (); |
|
96 } |
|
97 |
|
98 void initialize2 (void); |
|
99 void initialize10 (void); |
|
100 |
|
101 double c2; |
|
102 double c10; |
|
103 |
|
104 int e2; |
|
105 int e10; |
|
106 |
|
107 // TRUE means the original values were provided in base 2. |
|
108 bool base2; |
457
|
109 }; |
|
110 |
|
111 #endif |
|
112 |
|
113 /* |
|
114 ;;; Local Variables: *** |
|
115 ;;; mode: C++ *** |
|
116 ;;; End: *** |
|
117 */ |