[Fortran] 纯文本查看 复制代码
Program sacling_factor
include 'link_fnl_shared.h'
use imsl_libraries
implicit none
integer,parameter ::N=180
integer :: i
real*8 ::X(N,1),Y(N,1)
real*8 ::XT(1,N)
real*8 XTX(1,1),XTY(1,1)
open(11,file='1.txt')
! open(14,file='1.txt',status='old')
open(12,file='2.txt',status='old')
open(13,file='The_result.txt',status='replace')
do i=1,N
read(11,'(10X,D15.3)') X(i,1)
write(*,*) X(i,1)
read(12,'(10X,D15.3)') Y(i,1)
enddo
! Y=XA
! we want to compulate the parameter A
! XTY=XTXA====>A=(XTY)/(XTX)
XT=transpose(X)
XTX=matmul(XT,X)
XTY=matmul(XT,Y)
write(13,*) (XTY)/(XTX)
end program sacling_factor