Skip to content

Latest commit

 

History

History
58 lines (44 loc) · 2.06 KB

File metadata and controls

58 lines (44 loc) · 2.06 KB

Cholesky decomposition existence check

About The Project

I wrote this Fortran code for a friend´s university project. It is clearly not the best Fortran code out there, but the code works with every quadratic matrices. You can test whether there is a Cholesky decomposition or not. I am uploading this project because if someone gets a similar task in the following semesters, this code could help. Also, I have not found a standard solution for this problem via Google.

Usually you don't comment every line of code, but it was requested that way. I leave the comments like this because I think it helps a lot if you don't understand Fortran well.

Installation

  • Install at least Fortran 90
  • Go to the root folder of the project
  • Compile (Windows)
 gfortran code.f90
  • Execute (Windows)
  a.exe

How to use it

  • Change this variable to the length of your quadratic matrix (Line 3)
    integer , parameter:: columnRowLength = 4
  • Put your matrix formatted in .txt or .csv in the root folder of the project and change it to your file name (line 15)
    open(10,file='CholeskyPossible.txt')
    For test purposes you can use the matrices: CholeskyNotPossible.txt, CholeskyPossible.txt & 5x5Matrix.txt (with the last one you have to change the variable to 5)
  • Compile and run/execute the project
  • The results are now printed out in your command line

How it works

If the matrix is quadratic, symmetric and positiv definit => then there is a Cholesky decomposition.

Quadratic:

  • square matrices are required (there is no test that sort out non-square matrices!)

Test symmetry:

  • compare the matrix to its own transposition

Test positiv definit:

  • via Laplace expansion:
    • If Laplace expansion is greater than 0 then the matrix is semi postiv definit
    • And if Laplace expansion is is greater than 0 and the matrix is symmetric then the matrix is postiv definit

License

Distributed under the MIT License. See LICENSE for more information.