Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VEBER Philippe
codepi
Commits
7fa09ac2
Commit
7fa09ac2
authored
Mar 25, 2021
by
Philippe Veber
Browse files
whitespacecommit
parent
1be6cf2f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
app/matrix_exponential_bench.ml
app/matrix_exponential_bench.ml
+3
-3
lib/tk/tdg09.ml
lib/tk/tdg09.ml
+5
-5
No files found.
app/matrix_exponential_bench.ml
View file @
7fa09ac2
...
...
@@ -6,7 +6,7 @@ let () =
let
stationary_distribution
=
Amino_acid
.
random_profile
0
.
5
in
let
exchangeability_matrix
=
Rate_matrix
.
Amino_acid
.
make
(
fun
aa_i
aa_j
->
let
i
,
j
=
Amino_acid
.(
to_int
aa_i
,
to_int
aa_j
)
in
if
i
<=
j
then
float_of_int
i
*.
0
.
01
+.
float_of_int
j
*.
0
.
001
if
i
<=
j
then
float_of_int
i
*.
0
.
01
+.
float_of_int
j
*.
0
.
001
else
float_of_int
j
*.
0
.
01
+.
float_of_int
i
*.
0
.
001
)
in
let
p
=
{
...
...
@@ -16,11 +16,11 @@ let () =
}
in
let
t
=
100
.
in
let
transition_matrix_diag
=
Evolution_model
.
transition_probability_matrix
p
in
let
transition_matrix_exp
=
let
transition_matrix_exp
=
let
m
=
Evolution_model
.
rate_matrix
p
in
fun
t
->
Amino_acid
.
Matrix
.(
expm
(
scal_mul
t
m
))
in
Core
.
Command
.
run
(
Bench
.
make_command
[
Bench
.
Test
.
create
~
name
:
"diag"
(
fun
()
->
transition_matrix_diag
t
)
;
Bench
.
Test
.
create
~
name
:
"exp"
(
fun
()
->
transition_matrix_exp
t
)
;
])
\ No newline at end of file
])
lib/tk/tdg09.ml
View file @
7fa09ac2
...
...
@@ -22,8 +22,8 @@ module Evolution_model = struct
)
let
transition_probability_matrix
p
=
let
module
V
=
Amino_acid
.
Vector
in
let
module
M
=
Amino_acid
.
Matrix
in
let
module
V
=
Amino_acid
.
Vector
in
let
module
M
=
Amino_acid
.
Matrix
in
let
m
=
rate_matrix
p
in
let
sqrt_pi
=
V
.
map
p
.
stationary_distribution
~
f
:
Float
.
sqrt
in
let
diag_pi
=
M
.
diagm
sqrt_pi
in
...
...
@@ -41,7 +41,7 @@ module Evolution_model = struct
let
stationary_distribution
=
Amino_acid
.
random_profile
0
.
5
in
let
exchangeability_matrix
=
Rate_matrix
.
Amino_acid
.
make
(
fun
aa_i
aa_j
->
let
i
,
j
=
Amino_acid
.(
to_int
aa_i
,
to_int
aa_j
)
in
if
i
<=
j
then
float_of_int
i
*.
0
.
01
+.
float_of_int
j
*.
0
.
001
if
i
<=
j
then
float_of_int
i
*.
0
.
01
+.
float_of_int
j
*.
0
.
001
else
float_of_int
j
*.
0
.
01
+.
float_of_int
i
*.
0
.
001
)
in
let
p
=
{
...
...
@@ -50,12 +50,12 @@ module Evolution_model = struct
scale
=
1
.;
}
in
let
t
=
100
.
in
let
diag_exp_matrix
=
transition_probability_matrix
p
t
in
let
diag_exp_matrix
=
transition_probability_matrix
p
t
in
let
m
=
rate_matrix
p
in
let
exp_matrix
=
Amino_acid
.
Matrix
.(
expm
(
scal_mul
t
m
))
in
Amino_acid
.
Matrix
.
robust_equal
~
tol
:
1e-10
diag_exp_matrix
exp_matrix
let
%
test
"Matrix exponential through diagonalisation matches naive implementation"
=
let
%
test
"Matrix exponential through diagonalisation matches naive implementation"
=
test_diagonal_matrix_exponential
()
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment