Category : Miscellaneous Language Source Code
Archive   : FORTRN77.ZIP
Filename : NABAIR.FOR

 
Output of file : NABAIR.FOR contained in archive : FORTRN77.ZIP
SUBROUTINE NABAIR(P1,Q1,A,ITAG,N,EPS,ROOT,B,C)
C
C BAIRSTOW'S METHOD FOR FINDING ROOTS OF NTH DEGREE POLYNOMIAL
C WITH REAL COEFFICIENTS. POLYNOMIAL IS OF THE FORM
C A(1)X**N + A(2)X**(N - 1) + A(3)X**(N-2) + ... + A(N)X + A(N+1).
C
DIMENSION A(1), B(1), C(1), ROOT(1)
IITAG = ITAG
ITAG = 0
D = A(1)
DO 10 I = 1,N
10 A(I) = A(I + 1)/D
40 IF(N.GT.1) GO TO 43
ITAG = ITAG + 1
L = ITAG + ITAG
ROOT(L) = 0.
ROOT(L-1) = -A(1)
N = ITAG
ITAG = 4
RETURN
43 IF(N.GT.2) GO TO 46
P = A(1)
Q = A(2)
GO TO 8
46 P = P1
Q = Q1
M = 1
51 B(1) = A(1) - P
B(2) = A(2) - P*B(1) - Q
L = N - 1
C(1) = B(1) - P
C(2) = B(2) - P*C(1) - Q
IF(L.EQ.2) L = 3
DO 7 J = 3,L
B(J) = A(J) - P*B(J-1) - Q*B(J-2)
7 C(J) = B(J) - P*C(J-1) - Q*C(J-2)
L = N - 1
CBARL = C(L) - B(L)
DEN = -CBARL
IF(N.NE.3) DEN = DEN*C(N-3)
DEN = DEN + C(N-2)*C(N-2)
IF(DEN.NE.0.0) GO TO 1
N = ITAG
ITAG = 1
RETURN
1 B(N) = A(N) - P*B(N-1) - Q*B(N-2)
DELTP = -B(N)
IF(N.NE.3) DELTP = DELTP*C(N-3)
DELTP = (B(N-1)*C(N-2) + DELTP)/DEN
DELTQ = (B(N)*C(N-2) - B(N-1)*CBARL)/DEN
P = P + DELTP
Q = Q + DELTQ
SUM = ABS(DELTP) + ABS(DELTQ)
IF(M.EQ.1) SUM1 = SUM
IF(M.NE.5.OR.SUM.LE.SUM1) GO TO 11
N = ITAG
ITAG = 2
RETURN
11 IF(SUM.LE.EPS) GO TO 8
IF(M.LT.IITAG) GO TO 2
N = ITAG
ITAG = 3
RETURN
2 M = M + 1
GO TO 51
8 D = -P*0.5
ITAG = ITAG + 2
F = Q - D*D
E = SQRT(ABS(F))
L = ITAG + ITAG
IF(F.GT.0.0) GO TO 31
ROOT(L) = 0.0
ROOT(L - 1) = D-E
ROOT(L-2) = 0.0
ROOT(L-3) = D + E
GO TO 32
31 ROOT(L) = -E
ROOT(L - 1) = D
ROOT(L - 2) = E
ROOT(L - 3) = D
32 N = N - 2
IF(N.GT.0) GO TO 81
N = ITAG
ITAG = 4
RETURN
81 DO 82 I = 1,N
82 A(I) = B(I)
GO TO 40
RETURN
END


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : FORTRN77.ZIP
Filename : NABAIR.FOR

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/