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

 
Output of file : STPLRG.FOR contained in archive : FORTRN77.ZIP
SUBROUTINE STPLRG(M,X,Y,N,C,IFLAG,A)
C
C THIS SUBROUTINE WILL FOR A POLYNOMIAL OF DEGREE N
C TO M OBSERVATIONS, BY THE METHOD OF LEAST SQUARES.
C
DIMENSION X(1), Y(1), A(1), C(1)
N1 = N + 1
N2 = N1 + 1
NNPN = N*N1
N1PN1 = N1 + N1
N1N1 = NNPN + N1
C CLEAR 1ST ROW AND LAST TWO COLUMNS
I1J = 1
DO 30 J = 1,N
A(I1J) = 0.0
30 I1J = I1J + N1
L = NNPN + 1
DO 40 J = 1 + N1PN1
A(L) = 0.0
40 L = L + 1
C COMPUTE SUMS OF POWERS
DO 10 K = 1,M
XPWR = X(K)
I1J = N1 + 1
DO 20 J = 2,N1
JNP2 = N1N1 + J
A(I1J) = A(I1J) + XPWR
A(JNP2) = A(JNP2) + XPWR*Y(K)
XPWR = XPWR*X(K)
20 I1J = I1J + N1
DO 50 I = 2,N1
IN1 = NNPN + I
A(IN1) = A(IN1) + XPWR
50 XPWR = XPWR*X(K)
10 A(N1N1 + 1) = A(N1N1 + 1) + Y(K)
C FILL IN REST OF MATRIX A
A(1) = M
DO 60 I = 2,N1
IJ = I
DO 60 J = 1,N
IM1JP1 = IJ + N
A(IJ) = A(IM1JP1)
60 IJ = IJ + N1
C SOLVE EQUATIONS FOR COEFFICIENTS
NC = -N2
CALL MATINV(IFLAG,IFLAG,N1,NC,A,N1,I,XPWR)
K = N1N1 + N1
DO 70 I = 1,N1
C(I) = A(K)
70 K = K - 1
RETURN
END


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : FORTRN77.ZIP
Filename : STPLRG.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/