Question: I need to finish this code in Fortran, the code calculates the inverse matrix of a 4 x 4 matrix that reads from the data.dat

I need to finish this code in Fortran, the code calculates the inverse matrix of a 4x4 matrix that reads from the data.dat file, this can be anything. I need to implement the two subroutines that are there (triangulars and triangulari), one is to triangulate superiorly and the other inferiorly. And finally check that the code is correct by compiling it.
That is, it is the base code, I don't know if it is necessary to add something else for it to work. program inverse_calculation
real :: a(1:100,1:200),b(1:100,1:100),c(1:100,1:100)
open(unit=10,file='data.dat')
n=4
do i=1,n
read(10,*)(a(i,j), j=1,n)
enddo
close(10)
a(1:n,n+1:2*n)=0.0
do i=1,n
a(i,n+i)=1.0
enddo
call triangulars(a(1:n,1:2*n),n)
call triangulari(a(1:n,1:2*n),n)
do i=1,n
a(i,:)=a(i,:)/a(i,i)
enddo
do i=1,n
write(*,*)(a(i,j), j=1,n)
enddo
write(*,*)'**********************************'
do i=1,n
write(*,*)(a(i,j), j=n+1,2*n)
enddo
open(unit=12,file='data.dat')
do i=1,n
read(12,*)(b(i,j), j=1,n)
enddo
write(*,*)'***********************************'
do i=1,n
write(*,*)(b(i,j), j=1,n)
enddo
close(12)
! Verification of the inverse calculation procedure
do i=1,n
do j=1,n
c(i,j)=dot_product(a(i,n+1:2*n),b(:,j))
enddo
enddo
write(*,*)'*************************************'
do i=1,n
write(*,*)(c(i,j), j=1,n)
enddo
end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!