Sie sind auf Seite 1von 5

FORTRAN 90

Lecturer : Rafel Hekmat Hameed University of Babylon

Subject : Fortran 90 College of Engineering

Year : Second B.Sc. Mechanical Engineering Dep.

S
Sppeecciiaall FFoorrm
mss ooff M
Maattrriicceess

 A square matrix is said to be upper triangular when all the elements below
the diagonal are zero. The matrix below is an upper triangular matrix.

In an upper triangular matrix, not all elements above the diagonal need to be
non-zero.
 A square matrix is said to be lower triangular, when all the elements above
the diagonal are zero. The matrix below is a lower triangular matrix.

In a lower triangular matrix, not all elements below the diagonal need to be
non-zero.
 A square matrix is said to be diagonal, if all elements are zero, except those
in the diagonal. The matrix below is a diagonal matrix.

ϭ
 A diagonal matrix is called a scalar matrix, if a11 = a22 = a33 = … = ann = k
where k is a scalar.. The matrix D below is a scalar matrix with k=4.
k

A scalar matrix with k=1 , is called an identity matrix . Shown below are
2 2, 33 , and 44
4 identity matrices.

 The transpose of a matrix A, denoted as AT, is the matrix that is obtained


when the rows and columns of matrix A are interchanged.

 A symmetric matrix A , is one such that AT=A , that is, the transpose of a
matrix A is the same as A . An example of a symmetric matrix is shown
below.

Determina
annts
Every square matrix has a value called a determinant,
determinant and only square
matrices
ices have defined determinants.

The determinant of a 2x2


2 square matrix is the difference of the products of the
diagonals.

Ϯ
The "down"" diagonal is in red and the "up"" " diagonal is in blue. The up
diagonals are always subtracted from the down diagonals. Matrices that are larger
than a 2 x 2 matrix become a little more complicated when finding the
determinant but the same rules apply. Let's find

When finding the determinant of a 3 x 3 matrix it is helpful to write the first two
columns to the right side of the matrix like so

A fortran 90 program to find the determinant of 33 matrix.


matrix
Program determinant ; implicit none

Integer, parameter::n
n=3, m=5

Integer, dimension (n,m):: a ; Integer:: i, j, det1, det2,


det det

Read(*,*) ((a(I,j),j=1,n)),i=1,n)

Do i=1,n ; do j=1,n-1
j

a(i,n+j)=a(I,j) ; enddo ; enddo

do i=1,n ;det1=1
1 ; det2=1

do j=1,n

det1=det1*a(j,i+j-1) ; det2=det2*a(j,2*n-j-i+1) ;enddo

det=det+det1-det2 ; enddo

write(*,6) "determinant
determinant=", det ;6 format(2x,a,2x,i8); end

ϯ
If the matrix has more than three columns, then the determinant be
determined, as illustrated by example below

3 6 8 6
4 7 7 7
A= 3 1 5 2
5 2 4 3

͵ ͸ ͵ ͺ ͵ ͸
ቚ ቚ ቚ ቚ ቚ ቚ
Ͷ ͹ Ͷ ͹ Ͷ ͹ െ͵ െͳͳ െ͵
ተ͵ ͸ ͵ ͺ ͵ ͸ተ
Det A = ቚ ቚ ቚ ቚ ቚ ቚ ֜ อെͳͷ െͻ െͳʹอ ֜
ተ͵ ͳ ͵ ͷ ͵ ʹተ
െʹͶ െʹͺ െʹͳ
͵ ͸ ͵ ͺ ͵ ͸
ቚ ቚ ቚ ቚ ቚ ቚ
ͷ ʹ ͷ Ͷ ͷ ͵
െ͵ െͳͳ െ͵ െ͵
ቚ ቚ ቚ ቚ
ቮ െͳͷ െͻ െͳͷ െͳʹ ቮ  ֜  ቚെͳ͵ͺ െͻቚ  ֜
െ͵ െͳͳ െ͵ െ͵ െͳͺͲ െͻ
ቚ ቚ ቚ ቚ
െʹͶ െʹͺ െʹͶ െʹͳ

Det A= (-138*-9) – ( -180*-9) = -378

‫ܣ‬ ‫ܣ‬ଵଶ ‫ܣ‬ ‫ܣ‬ଵଷ ‫ܣ‬ ‫ܣ‬ଵସ


ฬ ଵଵ ฬ ฬ ଵଵ ฬ ฬ ଵଵ ฬ
‫ܣ‬ଶଵ ‫ܣ‬ଶଶ ‫ܣ‬ଶଵ ‫ܣ‬ଶଷ ‫ܣ‬ଶଵ ‫ܣ‬ଶସ
ተ‫ܣ‬ ‫ܣ‬ଵଶ ‫ܣ‬ ‫ܣ‬ଵଷ ‫ܣ‬ ‫ܣ‬ଵସ ተ
ฬ ଵଵ ฬ ฬ ଵଵ ฬ ฬ ଵଵ ฬ
‫ܣ‬ ‫ܣ‬ଷଶ ‫ܣ‬ଷଵ ‫ܣ‬ଷଷ ‫ܣ‬ଷଵ ‫ܣ‬ଷସ
ተ ଷଵ ተ
‫ܣ‬ ‫ܣ‬ଵଶ ‫ܣ‬ ‫ܣ‬ଵଷ ‫ܣ‬ ‫ܣ‬ଵସ
ฬ ଵଵ ฬ ฬ ଵଵ ฬ ฬ ଵଵ ฬ
‫ܣ‬ସଵ ‫ܣ‬ସଶ ‫ܣ‬ସଵ ‫ܣ‬ସଷ ‫ܣ‬ସଵ ‫ܣ‬ସସ
IMPLICIT NONE

INTEGER ,DIMENSION (4,4)::A

INTEGER,DIMENSION (1:3,1:3)::B

INTEGER::I, J, N

DATA A/3,4,3,5,6,7,1,2,8,7,5,4,6,7,2,3/

DO N=4, 2 ,-1

DO I=1, N-1

DO J=1,N-1

B(I,J)=A(1,1)*A(I+1,J+1)-A(1,J+1)*A(I+1,1)

ENDDO ; ENDDO
ϰ
DO I=1,N-1

DO J=1,N-1

A(I,J)=B(I,J)

ENDDO;ENDDO

DO I=1,N-1

PRINT*,(B(I,J),J=1,N-1)

ENDDO

PRINT *, ' ******************************************* '

ENDDO

END

Das könnte Ihnen auch gefallen