CalculiX  2.13
A Free Software Three-Dimensional Structural Finite Element Program
rs.f File Reference

Go to the source code of this file.

Functions/Subroutines

real *8 function pythag (a, b)
 
subroutine rs (nm, n, a, w, matz, z, fv1, fv2, ierr)
 
subroutine tql1 (n, d, e, ierr)
 
subroutine tql2 (nm, n, d, e, z, ierr)
 
subroutine tred1 (nm, n, a, d, e, e2)
 
subroutine tred2 (nm, n, a, d, e, z)
 

Function/Subroutine Documentation

◆ pythag()

real*8 function pythag ( real*8  a,
real*8  b 
)
5  implicit none
6  real*8 a,b
7 c
8 c finds dsqrt(a**2+b**2) without overflow or destructive underflow
9 c
10  real*8 p,r,s,t,u
11  p = dmax1(dabs(a),dabs(b))
12  if (p .eq. 0.0d0) go to 20
13  r = (dmin1(dabs(a),dabs(b))/p)**2
14  10 continue
15  t = 4.0d0 + r
16  if (t .eq. 4.0d0) go to 20
17  s = r/t
18  u = 1.0d0 + 2.0d0*s
19  p = u*p
20  r = (s/u)**2 * r
21  go to 10
22  20 pythag = p
23  return
real *8 function pythag(a, b)
Definition: rs.f:5

◆ rs()

subroutine rs ( integer  nm,
integer  n,
real*8, dimension(nm,n)  a,
real*8, dimension(n)  w,
integer  matz,
real*8, dimension(nm,n)  z,
real*8, dimension(n)  fv1,
real*8, dimension(n)  fv2,
integer  ierr 
)
27 c
28  implicit none
29  integer n,nm,ierr,matz
30  real*8 a(nm,n),w(n),z(nm,n),fv1(n),fv2(n)
31 c
32 c this subroutine calls the recommended sequence of
33 c subroutines from the eigensystem subroutine package (eispack)
34 c to find the eigenvalues and eigenvectors (if desired)
35 c of a real symmetric matrix.
36 c
37 c on input
38 c
39 c nm must be set to the row dimension of the two-dimensional
40 c array parameters as declared in the calling program
41 c dimension statement.
42 c
43 c n is the order of the matrix a.
44 c
45 c a contains the real symmetric matrix.
46 c
47 c matz is an integer variable set equal to zero if
48 c only eigenvalues are desired. otherwise it is set to
49 c any non-zero integer for both eigenvalues and eigenvectors.
50 c
51 c on output
52 c
53 c w contains the eigenvalues in ascending order.
54 c
55 c z contains the eigenvectors if matz is not zero.
56 c
57 c ierr is an integer output variable set equal to an error
58 c completion code described in the documentation for tqlrat
59 c and tql2. the normal completion code is zero.
60 c
61 c fv1 and fv2 are temporary storage arrays.
62 c
63 c questions and comments should be directed to burton s. garbow,
64 c mathematics and computer science div, argonne national laboratory
65 c
66 c this version dated august 1983.
67 c
68 c ------------------------------------------------------------------
69 c
70  if (n .le. nm) go to 10
71  ierr = 10 * n
72  go to 50
73 c
74  10 if (matz .ne. 0) go to 20
75 c .......... find eigenvalues only ..........
76  call tred1(nm,n,a,w,fv1,fv2)
77 * tqlrat encounters catastrophic underflow on the Vax
78 * call tqlrat(n,w,fv2,ierr)
79  call tql1(n,w,fv1,ierr)
80  go to 50
81 c .......... find both eigenvalues and eigenvectors ..........
82  20 call tred2(nm,n,a,w,fv1,z)
83  call tql2(nm,n,w,fv1,z,ierr)
84  50 return
subroutine tql2(nm, n, d, e, z, ierr)
Definition: rs.f:225
subroutine tred1(nm, n, a, d, e, e2)
Definition: rs.f:397
subroutine tred2(nm, n, a, d, e, z)
Definition: rs.f:534
subroutine tql1(n, d, e, ierr)
Definition: rs.f:88

◆ tql1()

subroutine tql1 ( integer  n,
real*8, dimension(n)  d,
real*8, dimension(n)  e,
integer  ierr 
)
88 c
89  implicit none
90  integer i,j,l,m,n,ii,l1,l2,mml,ierr
91  real*8 d(n),e(n)
92  real*8 c,c2,c3,dl1,el1,f,g,h,p,r,s,s2,tst1,tst2,pythag
93 c
94 c this subroutine is a translation of the algol procedure tql1,
95 c num. math. 11, 293-306(1968) by bowdler, martin, reinsch, and
96 c wilkinson.
97 c handbook for auto. comp., vol.ii-linear algebra, 227-240(1971).
98 c
99 c this subroutine finds the eigenvalues of a symmetric
100 c tridiagonal matrix by the ql method.
101 c
102 c on input
103 c
104 c n is the order of the matrix.
105 c
106 c d contains the diagonal elements of the input matrix.
107 c
108 c e contains the subdiagonal elements of the input matrix
109 c in its last n-1 positions. e(1) is arbitrary.
110 c
111 c on output
112 c
113 c d contains the eigenvalues in ascending order. if an
114 c error exit is made, the eigenvalues are correct and
115 c ordered for indices 1,2,...ierr-1, but may not be
116 c the smallest eigenvalues.
117 c
118 c e has been destroyed.
119 c
120 c ierr is set to
121 c zero for normal return,
122 c j if the j-th eigenvalue has not been
123 c determined after 30 iterations.
124 c
125 c calls pythag for dsqrt(a*a + b*b) .
126 c
127 c questions and comments should be directed to burton s. garbow,
128 c mathematics and computer science div, argonne national laboratory
129 c
130 c this version dated august 1983.
131 c
132 c ------------------------------------------------------------------
133 c
134  ierr = 0
135  if (n .eq. 1) go to 1001
136 c
137  do 100 i = 2, n
138  100 e(i-1) = e(i)
139 c
140  f = 0.0d0
141  tst1 = 0.0d0
142  e(n) = 0.0d0
143 c
144  do 290 l = 1, n
145  j = 0
146  h = dabs(d(l)) + dabs(e(l))
147  if (tst1 .lt. h) tst1 = h
148 c .......... look for small sub-diagonal element ..........
149  do 110 m = l, n
150  tst2 = tst1 + dabs(e(m))
151  if (tst2 .eq. tst1) go to 120
152 c .......... e(n) is always zero, so there is no exit
153 c through the bottom of the loop ..........
154  110 continue
155 c
156  120 if (m .eq. l) go to 210
157  130 if (j .eq. 30) go to 1000
158  j = j + 1
159 c .......... form shift ..........
160  l1 = l + 1
161  l2 = l1 + 1
162  g = d(l)
163  p = (d(l1) - g) / (2.0d0 * e(l))
164  r = pythag(p,1.0d0)
165  d(l) = e(l) / (p + dsign(r,p))
166  d(l1) = e(l) * (p + dsign(r,p))
167  dl1 = d(l1)
168  h = g - d(l)
169  if (l2 .gt. n) go to 145
170 c
171  do 140 i = l2, n
172  140 d(i) = d(i) - h
173 c
174  145 f = f + h
175 c .......... ql transformation ..........
176  p = d(m)
177  c = 1.0d0
178  c2 = c
179  el1 = e(l1)
180  s = 0.0d0
181  mml = m - l
182 c .......... for i=m-1 step -1 until l do -- ..........
183  do 200 ii = 1, mml
184  c3 = c2
185  c2 = c
186  s2 = s
187  i = m - ii
188  g = c * e(i)
189  h = c * p
190  r = pythag(p,e(i))
191  e(i+1) = s * r
192  s = e(i) / r
193  c = p / r
194  p = c * d(i) - s * g
195  d(i+1) = h + s * (c * g + s * d(i))
196  200 continue
197 c
198  p = -s * s2 * c3 * el1 * e(l) / dl1
199  e(l) = s * p
200  d(l) = c * p
201  tst2 = tst1 + dabs(e(l))
202  if (tst2 .gt. tst1) go to 130
203  210 p = d(l) + f
204 c .......... order eigenvalues ..........
205  if (l .eq. 1) go to 250
206 c .......... for i=l step -1 until 2 do -- ..........
207  do 230 ii = 2, l
208  i = l + 2 - ii
209  if (p .ge. d(i-1)) go to 270
210  d(i) = d(i-1)
211  230 continue
212 c
213  250 i = 1
214  270 d(i) = p
215  290 continue
216 c
217  go to 1001
218 c .......... set error -- no convergence to an
219 c eigenvalue after 30 iterations ..........
220  1000 ierr = l
221  1001 return
real *8 function pythag(a, b)
Definition: rs.f:5

◆ tql2()

subroutine tql2 ( integer  nm,
integer  n,
real*8, dimension(n)  d,
real*8, dimension(n)  e,
real*8, dimension(nm,n)  z,
integer  ierr 
)
225 c
226  implicit none
227  integer i,j,k,l,m,n,ii,l1,l2,nm,mml,ierr
228  real*8 d(n),e(n),z(nm,n)
229  real*8 c,c2,c3,dl1,el1,f,g,h,p,r,s,s2,tst1,tst2,pythag
230 c
231 c this subroutine is a translation of the algol procedure tql2,
232 c num. math. 11, 293-306(1968) by bowdler, martin, reinsch, and
233 c wilkinson.
234 c handbook for auto. comp., vol.ii-linear algebra, 227-240(1971).
235 c
236 c this subroutine finds the eigenvalues and eigenvectors
237 c of a symmetric tridiagonal matrix by the ql method.
238 c the eigenvectors of a full symmetric matrix can also
239 c be found if tred2 has been used to reduce this
240 c full matrix to tridiagonal form.
241 c
242 c on input
243 c
244 c nm must be set to the row dimension of two-dimensional
245 c array parameters as declared in the calling program
246 c dimension statement.
247 c
248 c n is the order of the matrix.
249 c
250 c d contains the diagonal elements of the input matrix.
251 c
252 c e contains the subdiagonal elements of the input matrix
253 c in its last n-1 positions. e(1) is arbitrary.
254 c
255 c z contains the transformation matrix produced in the
256 c reduction by tred2, if performed. if the eigenvectors
257 c of the tridiagonal matrix are desired, z must contain
258 c the identity matrix.
259 c
260 c on output
261 c
262 c d contains the eigenvalues in ascending order. if an
263 c error exit is made, the eigenvalues are correct but
264 c unordered for indices 1,2,...,ierr-1.
265 c
266 c e has been destroyed.
267 c
268 c z contains orthonormal eigenvectors of the symmetric
269 c tridiagonal (or full) matrix. if an error exit is made,
270 c z contains the eigenvectors associated with the stored
271 c eigenvalues.
272 c
273 c ierr is set to
274 c zero for normal return,
275 c j if the j-th eigenvalue has not been
276 c determined after 30 iterations.
277 c
278 c calls pythag for dsqrt(a*a + b*b) .
279 c
280 c questions and comments should be directed to burton s. garbow,
281 c mathematics and computer science div, argonne national laboratory
282 c
283 c this version dated august 1983.
284 c
285 c ------------------------------------------------------------------
286 c
287  ierr = 0
288  if (n .eq. 1) go to 1001
289 c
290  do 100 i = 2, n
291  100 e(i-1) = e(i)
292 c
293  f = 0.0d0
294  tst1 = 0.0d0
295  e(n) = 0.0d0
296 c
297  do 240 l = 1, n
298  j = 0
299  h = dabs(d(l)) + dabs(e(l))
300  if (tst1 .lt. h) tst1 = h
301 c .......... look for small sub-diagonal element ..........
302  do 110 m = l, n
303  tst2 = tst1 + dabs(e(m))
304  if (tst2 .eq. tst1) go to 120
305 c .......... e(n) is always zero, so there is no exit
306 c through the bottom of the loop ..........
307  110 continue
308 c
309  120 if (m .eq. l) go to 220
310  130 if (j .eq. 30) go to 1000
311  j = j + 1
312 c .......... form shift ..........
313  l1 = l + 1
314  l2 = l1 + 1
315  g = d(l)
316  p = (d(l1) - g) / (2.0d0 * e(l))
317  r = pythag(p,1.0d0)
318  d(l) = e(l) / (p + dsign(r,p))
319  d(l1) = e(l) * (p + dsign(r,p))
320  dl1 = d(l1)
321  h = g - d(l)
322  if (l2 .gt. n) go to 145
323 c
324  do 140 i = l2, n
325  140 d(i) = d(i) - h
326 c
327  145 f = f + h
328 c .......... ql transformation ..........
329  p = d(m)
330  c = 1.0d0
331  c2 = c
332  el1 = e(l1)
333  s = 0.0d0
334  mml = m - l
335 c .......... for i=m-1 step -1 until l do -- ..........
336  do 200 ii = 1, mml
337  c3 = c2
338  c2 = c
339  s2 = s
340  i = m - ii
341  g = c * e(i)
342  h = c * p
343  r = pythag(p,e(i))
344  e(i+1) = s * r
345  s = e(i) / r
346  c = p / r
347  p = c * d(i) - s * g
348  d(i+1) = h + s * (c * g + s * d(i))
349 c .......... form vector ..........
350  do 180 k = 1, n
351  h = z(k,i+1)
352  z(k,i+1) = s * z(k,i) + c * h
353  z(k,i) = c * z(k,i) - s * h
354  180 continue
355 c
356  200 continue
357 c
358  p = -s * s2 * c3 * el1 * e(l) / dl1
359  e(l) = s * p
360  d(l) = c * p
361  tst2 = tst1 + dabs(e(l))
362  if (tst2 .gt. tst1) go to 130
363  220 d(l) = d(l) + f
364  240 continue
365 c .......... order eigenvalues and eigenvectors ..........
366  do 300 ii = 2, n
367  i = ii - 1
368  k = i
369  p = d(i)
370 c
371  do 260 j = ii, n
372  if (d(j) .ge. p) go to 260
373  k = j
374  p = d(j)
375  260 continue
376 c
377  if (k .eq. i) go to 300
378  d(k) = d(i)
379  d(i) = p
380 c
381  do 280 j = 1, n
382  p = z(j,i)
383  z(j,i) = z(j,k)
384  z(j,k) = p
385  280 continue
386 c
387  300 continue
388 c
389  go to 1001
390 c .......... set error -- no convergence to an
391 c eigenvalue after 30 iterations ..........
392  1000 ierr = l
393  1001 return
real *8 function pythag(a, b)
Definition: rs.f:5

◆ tred1()

subroutine tred1 ( integer  nm,
integer  n,
real*8, dimension(nm,n)  a,
real*8, dimension(n)  d,
real*8, dimension(n)  e,
real*8, dimension(n)  e2 
)
397 c
398  implicit none
399  integer i,j,k,l,n,ii,nm,jp1
400  real*8 a(nm,n),d(n),e(n),e2(n)
401  real*8 f,g,h,scale
402 c
403 c this subroutine is a translation of the algol procedure tred1,
404 c num. math. 11, 181-195(1968) by martin, reinsch, and wilkinson.
405 c handbook for auto. comp., vol.ii-linear algebra, 212-226(1971).
406 c
407 c this subroutine reduces a real symmetric matrix
408 c to a symmetric tridiagonal matrix using
409 c orthogonal similarity transformations.
410 c
411 c on input
412 c
413 c nm must be set to the row dimension of two-dimensional
414 c array parameters as declared in the calling program
415 c dimension statement.
416 c
417 c n is the order of the matrix.
418 c
419 c a contains the real symmetric input matrix. only the
420 c lower triangle of the matrix need be supplied.
421 c
422 c on output
423 c
424 c a contains information about the orthogonal trans-
425 c formations used in the reduction in its strict lower
426 c triangle. the full upper triangle of a is unaltered.
427 c
428 c d contains the diagonal elements of the tridiagonal matrix.
429 c
430 c e contains the subdiagonal elements of the tridiagonal
431 c matrix in its last n-1 positions. e(1) is set to zero.
432 c
433 c e2 contains the squares of the corresponding elements of e.
434 c e2 may coincide with e if the squares are not needed.
435 c
436 c questions and comments should be directed to burton s. garbow,
437 c mathematics and computer science div, argonne national laboratory
438 c
439 c this version dated august 1983.
440 c
441 c ------------------------------------------------------------------
442 c
443  do 100 i = 1, n
444  d(i) = a(n,i)
445  a(n,i) = a(i,i)
446  100 continue
447 c .......... for i=n step -1 until 1 do -- ..........
448  do 300 ii = 1, n
449  i = n + 1 - ii
450  l = i - 1
451  h = 0.0d0
452  scale = 0.0d0
453  if (l .lt. 1) go to 130
454 c .......... scale row (algol tol then not needed) ..........
455  do 120 k = 1, l
456  120 scale = scale + dabs(d(k))
457 c
458  if (scale .ne. 0.0d0) go to 140
459 c
460  do 125 j = 1, l
461  d(j) = a(l,j)
462  a(l,j) = a(i,j)
463  a(i,j) = 0.0d0
464  125 continue
465 c
466  130 e(i) = 0.0d0
467  e2(i) = 0.0d0
468  go to 300
469 c
470  140 do 150 k = 1, l
471  d(k) = d(k) / scale
472  h = h + d(k) * d(k)
473  150 continue
474 c
475  e2(i) = scale * scale * h
476  f = d(l)
477  g = -dsign(dsqrt(h),f)
478  e(i) = scale * g
479  h = h - f * g
480  d(l) = f - g
481  if (l .eq. 1) go to 285
482 c .......... form a*u ..........
483  do 170 j = 1, l
484  170 e(j) = 0.0d0
485 c
486  do 240 j = 1, l
487  f = d(j)
488  g = e(j) + a(j,j) * f
489  jp1 = j + 1
490  if (l .lt. jp1) go to 220
491 c
492  do 200 k = jp1, l
493  g = g + a(k,j) * d(k)
494  e(k) = e(k) + a(k,j) * f
495  200 continue
496 c
497  220 e(j) = g
498  240 continue
499 c .......... form p ..........
500  f = 0.0d0
501 c
502  do 245 j = 1, l
503  e(j) = e(j) / h
504  f = f + e(j) * d(j)
505  245 continue
506 c
507  h = f / (h + h)
508 c .......... form q ..........
509  do 250 j = 1, l
510  250 e(j) = e(j) - h * d(j)
511 c .......... form reduced a ..........
512  do 280 j = 1, l
513  f = d(j)
514  g = e(j)
515 c
516  do 260 k = j, l
517  260 a(k,j) = a(k,j) - f * e(k) - g * d(k)
518 c
519  280 continue
520 c
521  285 do 290 j = 1, l
522  f = d(j)
523  d(j) = a(l,j)
524  a(l,j) = a(i,j)
525  a(i,j) = f * scale
526  290 continue
527 c
528  300 continue
529 c
530  return

◆ tred2()

subroutine tred2 ( integer  nm,
integer  n,
real*8, dimension(nm,n)  a,
real*8, dimension(n)  d,
real*8, dimension(n)  e,
real*8, dimension(nm,n)  z 
)
534 c
535  implicit none
536  integer i,j,k,l,n,ii,nm,jp1
537  real*8 a(nm,n),d(n),e(n),z(nm,n)
538  real*8 f,g,h,hh,scale
539 c
540 c this subroutine is a translation of the algol procedure tred2,
541 c num. math. 11, 181-195(1968) by martin, reinsch, and wilkinson.
542 c handbook for auto. comp., vol.ii-linear algebra, 212-226(1971).
543 c
544 c this subroutine reduces a real symmetric matrix to a
545 c symmetric tridiagonal matrix using and accumulating
546 c orthogonal similarity transformations.
547 c
548 c on input
549 c
550 c nm must be set to the row dimension of two-dimensional
551 c array parameters as declared in the calling program
552 c dimension statement.
553 c
554 c n is the order of the matrix.
555 c
556 c a contains the real symmetric input matrix. only the
557 c lower triangle of the matrix need be supplied.
558 c
559 c on output
560 c
561 c d contains the diagonal elements of the tridiagonal matrix.
562 c
563 c e contains the subdiagonal elements of the tridiagonal
564 c matrix in its last n-1 positions. e(1) is set to zero.
565 c
566 c z contains the orthogonal transformation matrix
567 c produced in the reduction.
568 c
569 c a and z may coincide. if distinct, a is unaltered.
570 c
571 c questions and comments should be directed to burton s. garbow,
572 c mathematics and computer science div, argonne national laboratory
573 c
574 c this version dated august 1983.
575 c
576 c ------------------------------------------------------------------
577 c
578  do 100 i = 1, n
579 c
580  do 80 j = i, n
581  80 z(j,i) = a(j,i)
582 c
583  d(i) = a(n,i)
584  100 continue
585 c
586  if (n .eq. 1) go to 510
587 c .......... for i=n step -1 until 2 do -- ..........
588  do 300 ii = 2, n
589  i = n + 2 - ii
590  l = i - 1
591  h = 0.0d0
592  scale = 0.0d0
593  if (l .lt. 2) go to 130
594 c .......... scale row (algol tol then not needed) ..........
595  do 120 k = 1, l
596  120 scale = scale + dabs(d(k))
597 c
598  if (scale .ne. 0.0d0) go to 140
599  130 e(i) = d(l)
600 c
601  do 135 j = 1, l
602  d(j) = z(l,j)
603  z(i,j) = 0.0d0
604  z(j,i) = 0.0d0
605  135 continue
606 c
607  go to 290
608 c
609  140 do 150 k = 1, l
610  d(k) = d(k) / scale
611  h = h + d(k) * d(k)
612  150 continue
613 c
614  f = d(l)
615  g = -dsign(dsqrt(h),f)
616  e(i) = scale * g
617  h = h - f * g
618  d(l) = f - g
619 c .......... form a*u ..........
620  do 170 j = 1, l
621  170 e(j) = 0.0d0
622 c
623  do 240 j = 1, l
624  f = d(j)
625  z(j,i) = f
626  g = e(j) + z(j,j) * f
627  jp1 = j + 1
628  if (l .lt. jp1) go to 220
629 c
630  do 200 k = jp1, l
631  g = g + z(k,j) * d(k)
632  e(k) = e(k) + z(k,j) * f
633  200 continue
634 c
635  220 e(j) = g
636  240 continue
637 c .......... form p ..........
638  f = 0.0d0
639 c
640  do 245 j = 1, l
641  e(j) = e(j) / h
642  f = f + e(j) * d(j)
643  245 continue
644 c
645  hh = f / (h + h)
646 c .......... form q ..........
647  do 250 j = 1, l
648  250 e(j) = e(j) - hh * d(j)
649 c .......... form reduced a ..........
650  do 280 j = 1, l
651  f = d(j)
652  g = e(j)
653 c
654  do 260 k = j, l
655  260 z(k,j) = z(k,j) - f * e(k) - g * d(k)
656 c
657  d(j) = z(l,j)
658  z(i,j) = 0.0d0
659  280 continue
660 c
661  290 d(i) = h
662  300 continue
663 c .......... accumulation of transformation matrices ..........
664  do 500 i = 2, n
665  l = i - 1
666  z(n,l) = z(l,l)
667  z(l,l) = 1.0d0
668  h = d(i)
669  if (h .eq. 0.0d0) go to 380
670 c
671  do 330 k = 1, l
672  330 d(k) = z(k,i) / h
673 c
674  do 360 j = 1, l
675  g = 0.0d0
676 c
677  do 340 k = 1, l
678  340 g = g + z(k,i) * z(k,j)
679 c
680  do 360 k = 1, l
681  z(k,j) = z(k,j) - g * d(k)
682  360 continue
683 c
684  380 do 400 k = 1, l
685  400 z(k,i) = 0.0d0
686 c
687  500 continue
688 c
689  510 do 520 i = 1, n
690  d(i) = z(n,i)
691  z(n,i) = 0.0d0
692  520 continue
693 c
694  z(n,n) = 1.0d0
695  e(1) = 0.0d0
696  return
Hosted by OpenAircraft.com, (Michigan UAV, LLC)