home *** CD-ROM | disk | FTP | other *** search
- !!! PROGRAM Gauss
- INCLUDE 'stdhdr.for'
-
-
- REAL x(0:maxc, 0:maxc),inv(0:maxc, 0:maxc)
- REAL y(0:maxc),solution(0:maxc)
- REAL matdet
- INTEGER numvar, i
-
-
-
- CALL Getdata(x,y,numvar)
- PRINT *
-
- CALL GaussJordan(x, y, numvar, solution, inv, matdet)
-
- PRINT *,'The solution is: '
- PRINT *
- DO i = 0, numvar - 1
- PRINT 70, i, solution(i)
- 70 FORMAT (' x', I2,' = ', F7.2 )
- END DO
- PRINT *
- PRINT 80, matdet
- 80 FORMAT (' Matrix determinant = ',F7.2)
-
-
- END
-
-
-
- SUBROUTINE Getdata(x,y,numvar)
- INCLUDE 'stdhdr.for'
-
- REAL x(0:maxc, 0:maxc), y(0:maxc)
- INTEGER numvar
-
- INTEGER i, j, answer
- CHARACTER * 2 sign
-
- answer = 0
- DO WHILE (answer .eq. 0)
- PRINT *, 'Enter number of equations'
- PRINT 10
- 10 FORMAT (' Must equal number of variables: '\)
- READ *, numvar
- DO i = 0, numvar - 1
- PRINT 15, I
- 15 FORMAT (' Equation # ',I2)
- DO j = 0, numvar - 1
- PRINT 20 , j
- 20 FORMAT (3X, ' Coefficient # ',I2,' = ' \)
- READ *,x(i, j)
- END DO
-
- PRINT 30
- 30 FORMAT ( 5X,' Constant = '\)
- READ *, y(i)
- PRINT *
- END DO
- PRINT *, ' The following system of equations was entered:'
- PRINT *
- DO i = 0 ,numvar - 1
- DO j = 0 , numvar - 1
- IF (x(i, j) .LT. 0 ) THEN
- sign = '-'
- ELSE
- sign = '+'
- END IF
- PRINT 40, sign, ABS(x(i,j)), j
- 40 FORMAT (2x,A,F6.2,'x',I2\)
- END DO
- PRINT 50, y(i)
- 50 FORMAT (' = ',F6.2)
- END DO
- PRINT 60
- 60 FORMAT (' Is this right 1-yes 0-no ? ' \ )
- READ *, Answer
- END DO
-
- END !Getdata
-