Mercurial > hg > octave-lyh
annotate liboctave/CollocWt.h @ 9417:5d46c4a894e8
fix bugs in sparse reductions
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Fri, 03 Jul 2009 12:21:12 +0200 |
parents | 16f53d29049f |
children | 4c0cdbe0acca |
rev | line source |
---|---|
3 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1993, 1994, 1995, 1996, 1997, 2000, 2002, 2003, 2004, |
9245 | 4 2005, 2006, 2007, 2009 John W. Eaton |
3 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
3 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
3 | 21 |
22 */ | |
23 | |
382 | 24 #if !defined (octave_CollocWt_h) |
25 #define octave_CollocWt_h 1 | |
26 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
27 #include <iosfwd> |
465 | 28 |
29 #include "dMatrix.h" | |
30 #include "dColVector.h" | |
384 | 31 |
1869 | 32 class |
6108 | 33 OCTAVE_API |
1869 | 34 CollocWt |
3 | 35 { |
36 public: | |
37 | |
4055 | 38 CollocWt (void) |
1869 | 39 : n (0), inc_left (0), inc_right (0), lb (0.0), rb (1.0), |
40 Alpha (0.0), Beta (0.0), r (), q (), A (), B (), initialized (0) { } | |
1528 | 41 |
5275 | 42 CollocWt (octave_idx_type nc, octave_idx_type il, octave_idx_type ir) |
1869 | 43 : n (nc), inc_left (il), inc_right (ir), lb (0.0), rb (1.0), |
44 Alpha (0.0), Beta (0.0), r (), q (), A (), B (), initialized (0) { } | |
1528 | 45 |
5275 | 46 CollocWt (octave_idx_type nc, octave_idx_type il, octave_idx_type ir, double l, double rr) |
4587 | 47 : n (nc), inc_left (il), inc_right (ir), lb (l), rb (rr), |
1869 | 48 Alpha (0.0), Beta (0.0), r (), q (), A (), B (), initialized (0) { } |
1528 | 49 |
5275 | 50 CollocWt (octave_idx_type nc, double a, double b, octave_idx_type il, octave_idx_type ir) |
1869 | 51 : n (nc), inc_left (il), inc_right (ir), lb (0.0), rb (1.0), |
52 Alpha (a), Beta (b), initialized (0) { } | |
1528 | 53 |
5275 | 54 CollocWt (octave_idx_type nc, double a, double b, octave_idx_type il, octave_idx_type ir, |
4587 | 55 double ll, double rr) |
56 : n (nc), inc_left (il), inc_right (ir), lb (ll), rb (rr), | |
1869 | 57 Alpha (a), Beta (b), r (), q (), A (), B (), initialized (0) { } |
3 | 58 |
4055 | 59 CollocWt (const CollocWt& a) |
1869 | 60 : n (a.n), inc_left (a.inc_left), inc_right (a.inc_right), |
61 lb (a.lb), rb (a.rb), Alpha (a.Alpha), Beta (a.Beta), | |
62 r (a.r), q (a.q), A (a.A), B (a.B), | |
63 initialized (a.initialized) { } | |
3 | 64 |
4055 | 65 CollocWt& operator = (const CollocWt& a) |
1528 | 66 { |
1869 | 67 if (this != &a) |
68 { | |
69 n = a.n; | |
70 inc_left = a.inc_left; | |
71 inc_right = a.inc_right; | |
72 lb = a.lb; | |
73 rb = a.rb; | |
74 r = a.r; | |
75 q = a.q; | |
76 A = a.A; | |
77 B = a.B; | |
78 initialized = a.initialized; | |
79 } | |
1528 | 80 return *this; |
81 } | |
3 | 82 |
1869 | 83 ~CollocWt (void) { } |
84 | |
5275 | 85 CollocWt& resize (octave_idx_type nc) |
1528 | 86 { |
4587 | 87 n = nc; |
1528 | 88 initialized = 0; |
89 return *this; | |
90 } | |
91 | |
92 CollocWt& add_left (void) | |
93 { | |
94 inc_left = 1; | |
95 initialized = 0; | |
96 return *this; | |
97 } | |
98 | |
99 CollocWt& delete_left (void) | |
100 { | |
101 inc_left = 0; | |
102 initialized = 0; | |
103 return *this; | |
104 } | |
105 | |
3 | 106 CollocWt& set_left (double val); |
107 | |
1528 | 108 CollocWt& add_right (void) |
109 { | |
110 inc_right = 1; | |
111 initialized = 0; | |
112 return *this; | |
113 } | |
114 | |
115 CollocWt& delete_right (void) | |
116 { | |
117 inc_right = 0; | |
118 initialized = 0; | |
119 return *this; | |
120 } | |
121 | |
3 | 122 CollocWt& set_right (double val); |
123 | |
1528 | 124 CollocWt& set_alpha (double val) |
125 { | |
126 Alpha = val; | |
127 initialized = 0; | |
128 return *this; | |
129 } | |
3 | 130 |
1528 | 131 CollocWt& set_beta (double val) |
132 { | |
133 Beta = val; | |
134 initialized = 0; | |
135 return *this; | |
136 } | |
137 | |
5275 | 138 octave_idx_type ncol (void) const { return n; } |
3 | 139 |
5275 | 140 octave_idx_type left_included (void) const { return inc_left; } |
141 octave_idx_type right_included (void) const { return inc_right; } | |
3 | 142 |
1528 | 143 double left (void) const { return lb; } |
144 double right (void) const { return rb; } | |
145 | |
146 double width (void) const { return rb - lb; } | |
3 | 147 |
1528 | 148 double alpha (void) const { return Alpha; } |
149 double beta (void) const { return Beta; } | |
150 | |
151 ColumnVector roots (void) { if (!initialized) init (); return r; } | |
152 ColumnVector quad (void) { if (!initialized) init (); return q; } | |
3 | 153 |
1528 | 154 ColumnVector quad_weights (void) { return quad (); } |
155 | |
156 Matrix first (void) { if (!initialized) init (); return A; } | |
157 | |
158 Matrix second (void) { if (!initialized) init (); return B; } | |
3 | 159 |
3504 | 160 friend std::ostream& operator << (std::ostream&, const CollocWt&); |
3 | 161 |
162 protected: | |
163 | |
5275 | 164 octave_idx_type n; |
3 | 165 |
5275 | 166 octave_idx_type inc_left; |
167 octave_idx_type inc_right; | |
3 | 168 |
169 double lb; | |
170 double rb; | |
171 | |
172 double Alpha; | |
173 double Beta; | |
174 | |
1528 | 175 ColumnVector r; |
176 ColumnVector q; | |
3 | 177 |
178 Matrix A; | |
179 Matrix B; | |
180 | |
181 int initialized; | |
182 | |
183 void init (void); | |
184 | |
185 void error (const char *msg); | |
186 }; | |
187 | |
188 #endif | |
189 | |
190 /* | |
191 ;;; Local Variables: *** | |
192 ;;; mode: C++ *** | |
193 ;;; End: *** | |
194 */ |