PROGRAM BT5_2 PARAMETER (NMAX=100,MMAX=6) DIMENSION X(NMAX*MMAX) DIMENSION R(MMAX*MMAX),RC(MMAX*MMAX) CHARACTER VARNAME(6)*2 DATA VARNAME /'X1','X2','X3','Y1','Y2','Y3'/ OPEN(1,FILE='C:\MASTER\G_TR\BAITAP~1\NEW\BANG2.TXT') READ(1,*) READ(1,*) READ(1,*) N,M DO I=1,N L=(M-1)*N+I READ(1,*) TMP, (X(J),J=I,L,N) ENDDO CALL CORRE(X,N,M,R) WRITE(*,*)' HE SO TUONG QUAN GUA CAC BIEN' WRITE(*,'(5X,6A10)') (VARNAME(J),J=1,M) DO J=1,M K=(J-1)*M+1 WRITE(*,300) VARNAME(J),(R(I),I=K,K+M-1) ENDDO 300 FORMAT(A3,2X,6F10.4) END !++++++++++++++++++++++ SUBROUTINE CORRE(X,N,M,R) ! CHUONG TRINH NAY TINH MA TRAN TUONG QUAN CHUAN HOA ! CUA TAP M BIEN TU SO LIEU BAN DAU CO DUNG LUONG N ! INPUT: + X MANG MOT CHIEU KICH THUOC N*M LUU TRU SO ! LIEU BAN DAU DANG MA TRAN N HANG M COT ! (X(1,1), X(2,1),...,X(N,1),X(1,2),...) ! + N DUNG LUONG MAU ! + M SO BIEN ! OUTPUT: + R MANG MOT CHIEU KICH THUOC M*M LUU TRU MA TRAN ! TUONG QUAN CHUAN HOA CUA M BIEN ! DIMENSION X(N*M),XX(N,M),R(M*M),TB(M),SX(M) K=0 DO J=1,M TB(J)=0.0 SX(J)=0.0 DO I=1,N K=K+1 TB(J)=TB(J)+X(K) SX(J)=SX(J)+X(K)*X(K) XX(I,J)=X(K) ENDDO TB(J)=TB(J)/REAL(N) SX(J)=SQRT(SX(J)/REAL(N)-TB(J)*TB(J)) ! PRINT*,TB(J),SX(J) ENDDO JK=0 DO J=1,M DO K=1,M JK=JK+1 R(JK)=0.0 DO I=1,N R(JK)=R(JK)+XX(I,J)*XX(I,K) ENDDO R(JK)=R(JK)/REAL(N)-TB(J)*TB(K) R(JK)=R(JK)/(SX(J)*SX(K)) ENDDO ENDDO RETURN END