Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
why3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Why3
why3
Commits
5ca3f3f9
Commit
5ca3f3f9
authored
6 years ago
by
Raphaël Rieu-Helft
Browse files
Options
Downloads
Patches
Plain Diff
Add square root tests
parent
4e093781
No related branches found
No related tags found
1 merge request
!106
GMP square root
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/multiprecision/tests.c
+58
-2
58 additions, 2 deletions
examples/multiprecision/tests.c
with
58 additions
and
2 deletions
examples/multiprecision/tests.c
+
58
−
2
View file @
5ca3f3f9
...
...
@@ -12,6 +12,7 @@
#define TEST_MUL
#define TEST_TOOM
#define TEST_DIV
#define TEST_SQRT1
#endif
#ifdef TEST_MINIGMP
...
...
@@ -25,6 +26,7 @@
#include
"build/mul.h"
#include
"build/div.h"
#include
"build/toom.h"
#include
"build/sqrt1.h"
#endif
#include
"mt19937-64.c"
...
...
@@ -60,7 +62,7 @@ int main () {
struct
timeval
begin
,
end
;
double
elapsed
;
#endif
uint64_t
c
,
refc
;
uint64_t
a
,
c
,
refc
;
//gmp_randstate_t rands;
//TMP_DECL;
//TMP_MARK;
...
...
@@ -355,10 +357,64 @@ int main () {
#endif
}
}
#endif
#ifdef COMPARE
printf
(
"division ok
\n
"
);
#endif
#endif
#ifdef TEST_SQRT1
#ifdef BENCH
printf
(
"#t(s)
\n
"
);
#endif
#ifdef BENCH
elapsed
=
0
;
#endif
an
=
bn
=
rn
=
1
;
for
(
int
iter
=
0
;
iter
!=
500
;
++
iter
)
{
init_valid
(
ap
,
bp
,
1
,
1
);
a
=
*
ap
;
if
(
a
<
0x4000000000000000
)
continue
;
#ifdef BENCH
gettimeofday
(
&
begin
,
NULL
);
for
(
int
i
=
0
;
i
!=
100
;
++
i
)
{
#endif
#if defined(TEST_GMP) || defined(TEST_MINIGMP)
mpn_sqrtrem
(
refr
,
refp
,
ap
,
1
);
refc
=
*
refr
;
#endif
#ifdef TEST_WHY3
c
=
sqrt1
(
rp
,
a
);
#endif
#ifdef BENCH
}
gettimeofday
(
&
end
,
NULL
);
elapsed
+=
(
end
.
tv_sec
-
begin
.
tv_sec
)
+
((
end
.
tv_usec
-
begin
.
tv_usec
)
/
1000000
.
0
)
printf
(
"%f
\n
"
,
an
,
bn
,
elapsed
);
printf
(
"
\n
"
);
//for gnuplot
#endif
#ifdef COMPARE
if
(
mpn_cmp
(
refp
,
rp
,
rn
)
||
c
!=
refc
)
{
printf
(
"ERROR, i=%d
\n
"
,
(
int
)
iter
);
printf
(
"a: "
);
mpn_dump
(
ap
,
an
);
printf
(
"r: "
);
mpn_dump
(
rp
,
rn
);
printf
(
"ref: "
);
mpn_dump
(
refp
,
rn
);
printf
(
"c: %016lx
\n
"
,
c
);
printf
(
"refc: %016lx
\n
"
,
refc
);
abort
();
}
#endif
}
#ifdef COMPARE
printf
(
"sqrt1 ok
\n
"
);
#endif
#endif
//TMP_FREE;
//tests_end ();
return
0
;
...
...
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