42 template <
class nr_type_t>
44 abov = belo = diag = offdiag = rhs = NULL;
50 template <
class nr_type_t>
62 template <
class nr_type_t>
63 const tridiag<nr_type_t>&
77 template <
class nr_type_t>
82 template <
class nr_type_t>
88 template <
class nr_type_t>
90 abov = belo = offdiag =
v;
94 template <
class nr_type_t>
100 template <
class nr_type_t>
106 template <
class nr_type_t>
116 template <
class nr_type_t>
124 solve_ns_cyc ();
break;
126 solve_s_cyc ();
break;
139 template <
class nr_type_t>
141 d = al = diag->getData ();
142 f = ga = abov->getData ();
143 e = belo->getData ();
144 b =
c =
x = rhs->getData ();
145 int i,
n = diag->getSize ();
149 ga[0] = f[0] / al[0];
150 for (i = 1; i < n - 1; i++) {
151 al[
i] =
d[
i] - e[
i] * ga[i-1];
152 ga[
i] = f[
i] / al[
i];
154 al[n-1] =
d[n-1] - e[n-1] * ga[n-2];
158 for (i = 1; i <
n; i++) {
159 c[
i] = (b[
i] - e[
i] *
c[i-1]) / al[i];
164 for (i = n - 2; i >= 0; i--) {
165 x[
i] =
c[
i] - ga[
i] *
x[i+1];
178 template <
class nr_type_t>
180 d = al = diag->getData ();
181 f = ga = abov->getData ();
182 e = be = belo->getData ();
183 b =
x =
c = rhs->getData ();
184 int i,
n = diag->getSize ();
185 de =
new nr_type_t[
n];
186 ep =
new nr_type_t[
n];
190 ga[0] = f[0] / al[0];
191 de[0] = e[0] / al[0];
192 for (i = 1; i < n - 2; i++) {
193 al[
i] =
d[
i] - e[
i] * ga[i-1];
194 ga[
i] = f[
i] / al[
i];
196 de[
i] = -be[
i] * de[i-1] / al[
i];
198 al[n-2] =
d[n-2] - e[n-2] * ga[n-3];
201 for (i = 3; i <
n; i++) {
202 ep[
i] = -ep[i-1] * ga[i-3];
204 ga[n-2] = (f[n-2] - be[n-2] * de[n-3]) / al[n-2];
205 be[n-1] = e[n-1] - ep[n-1] * ga[n-3];
206 al[n-1] =
d[n-1] - be[n-1] * ga[n-2];
207 for (i = 2; i <
n; i++) {
208 al[n-1] -= ep[
i] * de[i-2];
213 for (i = 1; i < n - 1; i++) {
214 c[
i] = (b[
i] -
c[i-1] * be[
i]) / al[i];
216 c[n-1] = b[n-1] - be[n-1] *
c[n-2];
217 for (i = 2; i <
n; i++) {
218 c[n-1] -= ep[
i] * c[i-2];
224 x[n-2] = c[n-2] - ga[n-2] *
x[n-1];
225 for (i = n - 3; i >= 0; i--) {
226 x[
i] = c[
i] - ga[
i] * x[i+1] - de[
i] * x[n-1];
242 template <
class nr_type_t>
244 d = al = diag->getData ();
245 f = ga = offdiag->getData ();
246 b = z =
x = b = rhs->getData ();
248 int i,
n = diag->getSize ();
249 de =
new nr_type_t[
n];
255 for (i = 1; i < n - 1; i++) {
256 al[
i] =
d[
i] - t * ga[i-1];
260 al[n-1] =
d[n-1] - t * ga[n-2];
264 for (i = 1; i <
n; i++) {
265 z[
i] = b[
i] - ga[i-1] * z[i-1];
267 for (i = 0; i <
n; i++) {
273 for (i = n-2; i >= 0; i--) {
274 x[
i] =
c[
i] - ga[
i] *
x[i+1];
289 template <
class nr_type_t>
291 d = al = diag->getData ();
292 f = ga = offdiag->getData ();
293 b =
c = z =
x = rhs->getData ();
295 int i,
n = diag->getSize ();
296 de =
new nr_type_t[
n];
302 de[0] = f[n-1] / al[0];
303 for (i = 1; i < n - 2; i++) {
304 al[
i] =
d[
i] - t * ga[i-1];
305 de[
i] = -de[i-1] * t / al[
i];
309 al[n-2] =
d[n-2] - t * ga[n-3];
310 ga[n-2] = (f[n-2] - t * de[n-3]) / al[n-2];
311 al[n-1] =
d[n-1] - al[n-2] * ga[n-2] * ga[n-2];
312 for (i = 0; i < n - 2; i++) {
313 al[n-1] -= al[
i] * de[
i] * de[
i];
318 for (i = 1; i < n - 1; i++) {
319 z[
i] = b[
i] - ga[i-1] * z[i-1];
321 z[n-1] = b[n-1] - ga[n-2] * z[n-2];
322 for (i = 0; i < n - 2; i++) {
323 z[n-1] -= de[
i] * z[
i];
325 for (i = 0; i <
n; i++) {
331 x[n-2] =
c[n-2] - ga[n-2] *
x[n-1];
332 for (i = n - 3; i >= 0; i--) {
333 x[
i] =
c[
i] - ga[
i] * x[i+1] - de[
i] * x[n-1];
void setDiagonal(tvector< nr_type_t > *)
tvector< nr_type_t > * diag
tvector< nr_type_t > * offdiag
tvector< nr_type_t > * abov
tvector< nr_type_t > * belo
tvector< nr_type_t > * rhs
void setOffDiagonal(tvector< nr_type_t > *)
void setB(tvector< nr_type_t > *)
const tridiag & operator=(const tridiag &)
void setRHS(tvector< nr_type_t > *)
void setA(tvector< nr_type_t > *)