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

Go to the source code of this file.

Functions/Subroutines

subroutine tridiagonal_nrhs (a, b, n, m, nrhs)
 

Function/Subroutine Documentation

◆ tridiagonal_nrhs()

subroutine tridiagonal_nrhs ( real*8, dimension(3,n), intent(inout)  a,
real*8, dimension(nrhs,n), intent(inout)  b,
integer, intent(in)  n,
integer, intent(in)  m,
integer, intent(in)  nrhs 
)
20 !
21 ! solves a tridiagonal system of equations A*x=b with
22 ! n equations. The off-diagonals are in symmetric positions
23 ! about the main diagonal and m entries away; the matrix does
24 ! not have to be symmetric
25 !
26 ! the first line contains the elements A(1,1) and A(1,1+m)
27 ! the last line contains the elements A(n,n-m),A(n,n)
28 ! (assuming full storage mode)
29 !
30 ! tridiagonal storage:
31 ! left diagonal in a(1,*)
32 ! main diagonal in a(2,*)
33 ! right diagonal in a(3,*)
34 !
35 ! INPUT:
36 !
37 ! a tridiagonal matrix
38 ! b right hand side
39 ! n number of rows and columns of a
40 ! m shift of the off-diagonals compared
41 ! to the main diagonal
42 ! nrsh number of right hand sides
43 !
44 ! OUTPUT
45 !
46 ! b solution
47 !
48  implicit none
49 !
50  integer i,k,n,m,nrhs
51 !
52  real*8 a(3,n),b(nrhs,n),y
53 !
54  intent(in) n,m,nrhs
55 !
56  intent(inout) a,b
57 !
58 ! Gaussian elimination: all values below the
59 ! diagonal are set to zero, the diagonal values set to 1
60 !
61 ! only the unknown values a(3,*) and b(nrhs,*) are calculated
62 !
63  do k=1,m
64  a(3,k)=a(3,k)/a(2,k)
65  do i=1,nrhs
66  b(i,k)=b(i,k)/a(2,k)
67  enddo
68  enddo
69 !
70  do k=m+1,n-m
71  y=1.d0/(a(3,k-m)*a(1,k)-a(2,k))
72  a(3,k)=-a(3,k)*y
73  do i=1,nrhs
74  b(i,k)=(b(i,k-m)*a(1,k)-b(i,k))*y
75  enddo
76  enddo
77 !
78  do k=n-m+1,n
79  a(2,k)=a(3,k-m)*a(1,k)-a(2,k)
80  do i=1,nrhs
81  b(i,k)=(b(i,k-m)*a(1,k)-b(i,k))/a(2,k)
82  enddo
83  enddo
84 !
85 ! back substitution
86 !
87  do k=n-m,1,-1
88  do i=1,nrhs
89  b(i,k)=b(i,k)-a(3,k)*b(i,k+m)
90  enddo
91  enddo
92 !
93  return
Hosted by OpenAircraft.com, (Michigan UAV, LLC)