Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ROCK
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Véronique LEGRAND
ROCK
Commits
f259025d
Commit
f259025d
authored
3 years ago
by
Veronique Legrand
Browse files
Options
Downloads
Patches
Plain Diff
had forgotten to commit unit_test_math_utils.cpp
parent
b29d3401
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/unit_test_math_utils.cpp
+85
-0
85 additions, 0 deletions
src/unit_test_math_utils.cpp
with
85 additions
and
0 deletions
src/unit_test_math_utils.cpp
0 → 100644
+
85
−
0
View file @
f259025d
/*
* unit_test_math_utils.cpp
*
* Created on: 7 mai 2021
* Author: vlegrand
*/
#include
<iostream>
#include
<cassert>
#include
<cmath>
#include
"math_utils.h"
using
namespace
std
;
void
test_getCollisionProba
()
{
float
p
=
getCollisionProba
(
2
,
5000000000
,
UINT_MAX
,
2
);
assert
(
round
(
p
*
10000
)
==
127
);
p
=
getCollisionProba
(
2
,
5000000000
,
UINT_MAX
,
1
);
assert
(
p
=
0.1128
);
p
=
getCollisionProba
(
1
,
2
,
UINT_MAX
,
3
);
//cout<<p<<endl;
assert
(
p
==
0.0
);
p
=
getCollisionProba
(
1
,
1000000000
,
UINT_MAX
,
1
);
assert
(
floor
(
p
*
1000
+
0.5
)
==
23
);
p
=
getCollisionProba
(
5
,
1000000000
,
UINT_MAX
,
1
);
assert
(
floor
(
p
*
1000
+
0.5
)
==
0
);
p
=
getCollisionProba
(
5
,
50000000000
,
UINT_MAX
,
1
);
assert
(
floor
(
p
*
1000
+
0.5
)
==
975
);
}
void
test_gammln
()
{
float
a
;
a
=
gammln
(
1
);
assert
(
exp
(
a
)
==
1
);
a
=
gammln
(
2
);
assert
(
exp
(
a
)
==
1
);
a
=
gammln
(
3
);
assert
(
exp
(
a
)
==
2
);
a
=
gammln
(
4
);
assert
(
exp
(
a
)
==
6
);
a
=
gammln
(
5
);
assert
(
exp
(
a
)
==
24
);
a
=
gammln
(
6
);
float
tmp
=
exp
(
a
);
float
tmp2
=
tmp
*
10000
;
float
tmp3
=
round
(
tmp2
)
/
10000
;
//printf("%s \n",tmp3);
assert
(
tmp3
==
120
);
/* unsigned long n=5000;
unsigned long m=n+1;
a=gammln(m);
float b=gammln(n);
double truc=exp(a-b);
assert(truc==n);
*/
}
void
test_pmf
()
{
unsigned
long
nb_k_mers
=
5000000000
;
float
p
=
pmf
(
0
,
nb_k_mers
,
UINT_MAX
);
assert
(
round
(
p
*
10000
)
==
3122
);
p
=
pmf
(
1
,
nb_k_mers
,
UINT_MAX
);
assert
(
round
(
p
*
10000
)
==
3634
);
p
=
pmf
(
2
,
nb_k_mers
,
UINT_MAX
);
assert
(
round
(
p
*
10000
)
==
2115
);
}
void
test_ccdf
()
{
unsigned
long
nb_k_mers
=
5000000000
;
double
res
=
ccdf
(
2
,
nb_k_mers
,
UINT_MAX
);
assert
(
round
(
res
*
10000
)
==
1128
);
}
int
main
(
int
argc
,
char
**
argv
)
{
cout
<<
"testing the gammln function"
<<
endl
;
test_gammln
();
cout
<<
"testing the pmf function"
<<
endl
;
test_pmf
();
cout
<<
"testing the ccdf function"
<<
endl
;
test_ccdf
();
cout
<<
"testing computation of collision probability."
<<
endl
;
test_getCollisionProba
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment