0% found this document useful (0 votes)
625 views

FORTRAN77 Subroutine To Calculate Matrix Determinant

This subroutine calculates the determinant of a square matrix. It takes in the dimension N of the square matrix, the matrix A, and returns the determinant in DET. It copies the matrix A into a working array B, calculates the determinant by multiplying elements along the main and off diagonals, and returns the difference of these products as the determinant of the original matrix A.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
625 views

FORTRAN77 Subroutine To Calculate Matrix Determinant

This subroutine calculates the determinant of a square matrix. It takes in the dimension N of the square matrix, the matrix A, and returns the determinant in DET. It copies the matrix A into a working array B, calculates the determinant by multiplying elements along the main and off diagonals, and returns the difference of these products as the determinant of the original matrix A.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

E:\MATDET.

F Monday, January 03, 2011 12:36 PM

C **********************************************************************
SUBROUTINE MATDET(N,A,DET)
C DOWNLOAD URL: http://wp.me/p61TQ-zb
C LAST MODIFIED: 2011/01/03
C A GENERAL PURPOSE SUBROUTINE TO CALCULATE DETERMINANT OF A SQUARE MATRIX
C a b c
C A = d e f
C g h i
C det A = aei+bfg+cdh-afh-bdi-ceg
C EXPLANATION OF PASSED PARAMETERS:
C N: DIMENSION OF SQUARE MATRIX
C A: A SQUARE MATRIX
C DET: DETERMINANT OF MATRIX A[N,N]
IMPLICIT REAL*8 (A-H,O-Z)
DIMENSION A(N,N),B(N,2*N-1)

DO I=1,N
DO J=1,N
B(I,J)=A(I,J)
END DO
END DO

DO I=1,N
DO J=1,N-1
B(I,J+N)=A(I,J)
END DO
END DO

IQ=0
XX1=1.0D0
XX2=0.0D0
DO I=1,N
XX1=1.0D0
DO J=1,N
XX1=XX1*B(J,J+IQ)
END DO
XX2=XX2+XX1
IQ=IQ+1
END DO

IQ=0
YY1=1.0D0
YY2=0.0D0
DO I=1,N
YY1=1.0D0
IQ=I+N-1
DO J=1,N
YY1=YY1*B(J,IQ)
IQ=IQ-1
END DO
YY2=YY2+YY1
END DO

DET=XX2-YY2
RETURN
END
C **********************************************************************

-1-

You might also like