Hello Everyone !
First of all, I am glad to see this group for help in FORTRAN. And I hope to get valuable suggestions and help here.
I am working in FORTRAN 90 where I need to calculate Inverse of a 7x7 Matrix accurately. I have used a subroutine in main program which augmenting the matrix with Identity matrix and then perform calculations for Inverse determination by pivoting. But the problem is that most of the time I do not get the correct answer. I verify my inverse using fact that : matrix A multiplied by its Inverse = Identity Matrix . But it do not gives Identity matrix when I use the Inverse calculated by the subroutine. The code is attached here(named: MatInv.f90) .
I am working in Ubuntu 16.04 LTS. I have installed FORTRAN 90 and I compile my programs by command " gfortran porgram.f90 -o program" in terminal.
I searched on INTERNET that LAPACK is a library which can efficiently calculates inverse of large matrices. So following instruction in a video on YOUTUBE, I installed LAPACK by commands in terminal as follows:
1) tar zxvf lapack-3.6.0.gz
2) cd lapack-3.6.0
◇ gfortran
cp make.inc.example make.inc
4) make blaslib
5) make lapacklib
6) sudo ln -s $HOME/lapack-3.6.0/librefblas.a /usr/local/lib/libblas.a
7) sudo ln -s $HOME/lapack-3.6.0/liblapack.a /usr/local/lib/liblapack.a
(on checking in /usr/local/bin these libraries are present there)
Now I want to use the program which uses LAPACK to find inverse of a large matrix but I do not know how to compile the code using these libraries. After searching on INTERNET and using file matrix_inverse.f90 (attached named: inverse_mat.f90) when I use command :
gfortran my_program.f90 -llapack -lblas
It says:
(.text+0x20): undefined reference to `main'collect2: error: ld returned 1 exit status
I am completely stuck here. I do not know certain things as follows:
(I). Whether I need to use LAPACK or not to find Inverse of a 7x7 matrix
(II). Why my program (without LAPACK) do not give correct result for inverse. If the inverse is accurate it should satisfy condition:
matrix A multiplied by its Inverse = Identity Matrix
but it do not satisfy this condition.
(III). If I use LAPACK, then how to accuratly use it to write and compile a program for inverse
(IV). What is the reason of the error mentioned above
(V). How to check whether I have installed LAPACK correctly or not
(VI). How I can install and use LAPACK, step by step instruction.
(VII). Finally, without knowing answers of all above questions, how can I find ACCURATE Inverse of a 7x7 martrix in FORTRAN 90?
I shall be highly grateful for any suggestions and help.
Best Regards,
Mirza Younis Baig