Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    8

    Unanswered: help with fortran matrix

    hi...i jsut need a little help on a program i have been writing. it is for matrices and i keep getting errors in it, i have doen it in fortran but i dont know how to solve these errors and was just wondering if any of the more experienced programmers could help me with this...the program is relatively short so shouldnt be to much trouble...for the more experinced...ill attach the file..thanks in advance...byes
    Attached Files Attached Files
    Last edited by jauhar; 07-27-04 at 12:43.

  2. #2
    Join Date
    Apr 2004
    Posts
    8
    Incase u cant open the attachment

    Program requirements:

    a) read a 3x3 array of REAL NUMBERS
    b) calculate the inverse of the 3x3 matrix
    c) write out the answer and the original Matrix
    d) multiply two 3x3 matrices.

    Here it is…………….:

    DIMENSION A(3,3)
    DIMENSION B(3,3)
    DIMENSION C(3,3)
    CALL INPUTS(A)
    CALL OUTPUTS(A)
    CALL IN(B)
    CALL OUT(B)
    CALL ANSWERS(A,B,N,C)
    STOP
    END

    SUBROUTINE INPUTS(A)
    DIMENSION A(3,3)
    DO 100 IROW=1,3
    DO 100 ICOL=1,3
    WRITE(*,200) IROW, ICOL
    READ(*,*) A(IROW,ICOL)
    100 CONTINUE
    200 FORMAT('Enter elements of Matrix A (',I1,',',I1,') = ')
    RETURN
    END

    SUBROUTINE OUTPUTS(A)
    DIMENSION A(3,3)
    WRITE(*,*) 'Matrix A will be'
    DO 300 IROW=1,3
    WRITE(*,400) (A(IROW,ICOL),ICOL=1,3)
    300 CONTINUE
    400 FORMAT(3F7.1)
    RETURN
    END

    SUBROUTINE IN(B)
    DIMENSION B(3,3)
    DO 500 IROW=1,3
    DO 500 ICOL=1,3
    WRITE(*,600) IROW, ICOL
    READ(*,*) B(IROW,ICOL)
    500 CONTINUE
    600 FORMAT('Enter elements of Matrix B (',I1,',',I1,') = ')
    RETURN
    END

    SUBROUTINE OUT(B)
    DIMENSION B(3,3)
    WRITE(*,*) 'Matrix B will be'
    DO 700 IROW=1,3
    WRITE(*,800) (B(IROW,ICOL),ICOL=1,3)
    700 CONTINUE
    800 FORMAT(3F7.1)
    RETURN
    END

    SUBROUTINE CMAINE (N,A,E)
    COMPLEX A,E,F,R,DEL
    DIMENSION E(N,N),A(N,N),R(100),F(100)
    DO 900 I=1,N
    DO 900 J=1,N
    900 E(I,J)=0
    DO 1200 L=1,N
    DEL=A(L,L)
    DO 1100 I=1,L
    F(I)=0.
    R(I)=0.
    DO 1000 J=1,L
    F(I)=F(I)+E(I,J)*A(J,L)
    1000 R(I)=R(I)+A(L,J)*F(I)
    1100 DEL=DEL-A(L,I)*F(I)
    F(L)=-1.
    R(L)=-1.
    DO 1200 M=1,L
    F(I)=F(I)/DEL
    DO 1200 k=1,L
    1200 A(I,J)=E(I,J)+F(I)*R(J)
    RETURN
    END

    SUBROUTINE ANSWERS(a,b,n,c)
    DIMENSION a(n,n),b(n,n),c(n,n)
    C(1,1)= A(1,1)*B(1,1)+A(1,2)*B(2,1)+A(1,3)*B(3,1)
    C(1,2)= A(1,1)*B(1,2)+A(1,2)*B(2,2)+A(1,3)*B(3,2)
    C(1,3)= A(1,1)*B(1,3)+A(1,2)*B(2,3)+A(1,3)*B(3,3)
    C(2,1)= A(2,1)*B(1,1)+A(2,2)*B(2,1)+A(2,3)*B(3,1)
    C(2,2)= A(2,1)*B(1,2)+A(2,2)*B(2,2)+A(2,3)*B(3,2)
    C(2,3)= A(2,1)*B(1,3)+A(2,2)*B(2,3)+A(2,3)*B(3,3)
    C(3,1)= A(3,1)*B(1,1)+A(3,2)*B(2,1)+A(3,3)*B(3,1)
    C(3,2)= A(3,1)*B(1,2)+A(3,2)*B(2,2)+A(3,3)*B(3,2)
    C(3,3)= A(3,1)*B(1,3)+A(3,2)*B(2,3)+A(3,3)*B(3,3)


    WRITE(*,*) 'Matrix C is, the multiplication of matrices A & B'
    DO 1300 IROW=1,3
    WRITE(*,1400) (C(IROW,ICOL),ICOL=1,3)
    1300 CONTINUE
    1400 FORMAT(3F7.1)
    RETURN
    END

  3. #3
    Join Date
    Apr 2004
    Posts
    8

    Smile

    anyone please

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •