Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
SWIFT
SWIFTsim
Commits
f67f292b
Commit
f67f292b
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Avoid overflow in pow_gamma()
parent
f53617b2
No related branches found
No related tags found
1 merge request
!202
Bug fixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/adiabatic_index.h
+9
-10
9 additions, 10 deletions
src/adiabatic_index.h
with
9 additions
and
10 deletions
src/adiabatic_index.h
+
9
−
10
View file @
f67f292b
...
...
@@ -60,15 +60,12 @@ __attribute__((always_inline)) INLINE static float pow_gamma(float x) {
#if defined(HYDRO_GAMMA_5_3)
const
float
x2
=
x
*
x
;
const
float
x5
=
x2
*
x2
*
x
;
return
cbrtf
(
x5
);
const
float
cbrt
=
cbrtf
(
x
);
/* x^(1/3) */
return
cbrt
*
cbrt
*
x
;
/* x^(5/3) */
#elif defined(HYDRO_GAMMA_4_3)
const
float
x2
=
x
*
x
;
const
float
x4
=
x2
*
x2
;
return
cbrtf
(
x4
);
return
cbrtf
(
x
)
*
x
;
/* x^(4/3) */
#elif defined(HYDRO_GAMMA_2_1)
...
...
@@ -93,11 +90,12 @@ __attribute__((always_inline)) INLINE static float pow_gamma_minus_one(
#if defined(HYDRO_GAMMA_5_3)
return
cbrtf
(
x
*
x
);
const
float
cbrt
=
cbrtf
(
x
);
/* x^(1/3) */
return
cbrt
*
cbrt
;
/* x^(2/3) */
#elif defined(HYDRO_GAMMA_4_3)
return
cbrtf
(
x
);
return
cbrtf
(
x
);
/* x^(1/3) */
#elif defined(HYDRO_GAMMA_2_1)
...
...
@@ -122,11 +120,12 @@ __attribute__((always_inline)) INLINE static float pow_minus_gamma_minus_one(
#if defined(HYDRO_GAMMA_5_3)
return
1
.
f
/
cbrtf
(
x
*
x
);
const
float
inv_cbrt
=
1
.
f
/
cbrtf
(
x
);
/* x^(-1/3) */
return
inv_cbrt
*
inv_cbrt
;
/* x^(-2/3) */
#elif defined(HYDRO_GAMMA_4_3)
return
1
.
f
/
cbrtf
(
x
);
return
1
.
f
/
cbrtf
(
x
);
/* x^(-1/3) */
#elif defined(HYDRO_GAMMA_2_1)
...
...
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