Commit b4e42135 authored by Louis Duchemin's avatar Louis Duchemin
Browse files

TDG09 : faster matrix exponentiation (hopefully ?)

parent de17b6b5
...@@ -22,8 +22,13 @@ module Evolution_model = struct ...@@ -22,8 +22,13 @@ module Evolution_model = struct
) )
let transition_probability_matrix p = let transition_probability_matrix p =
let m = rate_matrix p in let m = rate_matrix p in
let (d_vec, transform_matrix) = Amino_acid.Matrix.diagonalize m in
let rev_trans_matrix = Amino_acid.Matrix.inverse transform_matrix in
fun t -> fun t ->
Amino_acid.Matrix.(expm (scal_mul t m)) let exp_matrix = Amino_acid.Vector.(exp (scal_mul t d_vec))
|> Amino_acid.Matrix.diagm in
Amino_acid.Matrix.(dot (dot transform_matrix exp_matrix) rev_trans_matrix)
(* Amino_acid.Matrix.(expm (scal_mul t m)) *)
end end
let choose_aa p = let choose_aa p =
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment