Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
18e62203
Commit
18e62203
authored
Aug 02, 2016
by
Matthieu Schaller
Browse files
testMaths is now less verbose when everything is fine.
parent
8a7620ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/testMaths.c
View file @
18e62203
...
...
@@ -39,24 +39,29 @@ int main() {
const
float
rel
=
0
.
5
f
*
fabs
(
exp_correct
-
exp_approx
)
/
fabs
(
exp_correct
+
exp_approx
);
printf
(
"%2d: x= %f exp(x)= %e approx_exp(x)=%e abs=%e rel=%e
\n
"
,
i
,
x
,
exp_correct
,
exp_approx
,
abs
,
rel
);
int
error
=
0
;
if
(
abs
>
3e-6
&&
fabsf
(
x
)
<=
0
.
2
)
{
printf
(
"Absolute difference too large !
\n
"
);
return
1
;
error
=
1
;
}
if
(
abs
>
1.2e-7
&&
fabsf
(
x
)
<=
0
.
1
)
{
printf
(
"Absolute difference too large !
\n
"
);
return
1
;
error
=
1
;
}
if
(
rel
>
1e-6
&&
fabsf
(
x
)
<=
0
.
2
)
{
printf
(
"Relative difference too large !
\n
"
);
return
1
;
error
=
1
;
}
if
(
rel
>
4e-8
&&
fabsf
(
x
)
<=
0
.
1
)
{
printf
(
"Relative difference too large !
\n
"
);
error
=
1
;
}
if
(
error
)
{
printf
(
"%2d: x= %f exp(x)= %e approx_exp(x)=%e abs=%e rel=%e
\n
"
,
i
,
x
,
exp_correct
,
exp_approx
,
abs
,
rel
);
return
1
;
}
}
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment