-
-
Notifications
You must be signed in to change notification settings - Fork 21
Power Method
The video covering Power Method, Inverse Power Method, and Rayleigh Quotient can be found here https://youtu.be/LHlg_lfihiA. Example code is given in PowerMethod.ml file, written in OCAML it has Power Method, Inverse Power Method, and Rayleigh Quotient. You can run the program online from CodingGround. To run the program locally have OCAML installed (ocaml.org) then type ocaml PowerMethod.ml
in the terminal in the directory where PowerMethod.ml is saved. If you'd rather not use the terminal use an IDE instead like Geany to run the program (change the execute option to ocaml %e.ml
).
To change the matrix you're solving edit the a
variable and to change the initial vector edit the b
variable. You can also use the randomize
function with your starting vector if you really want to use random numbers.
let a = [|[|0.0;1.0|];
[|1.0;1.0|]|];;
let b = [|1.0; 1.0|];;
The invPower
and invPowerShift
only work for 2x2 matrices since they call the inv2x2
function.