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
13a3b144
Commit
13a3b144
authored
5 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Make the integer pow() code compile with GCC
parent
c355ef62
No related branches found
No related tags found
1 merge request
!1077
Improved multipole acceptance criterion (MAC)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/integer_power.h
+9
-10
9 additions, 10 deletions
src/integer_power.h
with
9 additions
and
10 deletions
src/integer_power.h
+
9
−
10
View file @
13a3b144
...
@@ -26,18 +26,17 @@
...
@@ -26,18 +26,17 @@
#include
"error.h"
#include
"error.h"
#include
"inline.h"
#include
"inline.h"
/* Standard headers */
#include
<math.h>
/**
/**
* @brief Computes the power of x to the n for a (small) positive integer n.
* @brief Computes the power of x to the n for a (small) positive integer n.
*
*
* Only
vali
d for values 0 <= n <= 8.
* Only
optimize
d for values 0 <= n <= 8.
Defaults to pow() above.
*/
*/
__attribute__
((
const
))
INLINE
static
int
integer_pow
(
const
double
x
,
__attribute__
((
const
))
INLINE
static
int
integer_pow
(
const
double
x
,
const
unsigned
int
n
)
{
const
unsigned
int
n
)
{
#ifdef SWIFT_DEBUG_CHECKS
assert
(
n
<=
8
);
#endif
switch
(
n
)
{
switch
(
n
)
{
case
0
:
case
0
:
return
1
.;
return
1
.;
...
@@ -68,21 +67,19 @@ __attribute__((const)) INLINE static int integer_pow(const double x,
...
@@ -68,21 +67,19 @@ __attribute__((const)) INLINE static int integer_pow(const double x,
const
double
z
=
y
*
y
;
const
double
z
=
y
*
y
;
return
z
*
z
;
return
z
*
z
;
}
}
default:
return
pow
(
x
,
(
double
)
n
);
}
}
}
}
/**
/**
* @brief Computes the power of x to the n for a (small) positive integer n.
* @brief Computes the power of x to the n for a (small) positive integer n.
*
*
* Only
vali
d for values 0 <= n <= 8.
* Only
optimize
d for values 0 <= n <= 8.
Defaults to powf() above.
*/
*/
__attribute__
((
const
))
INLINE
static
int
integer_powf
(
const
float
x
,
__attribute__
((
const
))
INLINE
static
int
integer_powf
(
const
float
x
,
const
unsigned
int
n
)
{
const
unsigned
int
n
)
{
#ifdef SWIFT_DEBUG_CHECKS
assert
(
n
<=
8
);
#endif
switch
(
n
)
{
switch
(
n
)
{
case
0
:
case
0
:
return
1
.
f
;
return
1
.
f
;
...
@@ -113,6 +110,8 @@ __attribute__((const)) INLINE static int integer_powf(const float x,
...
@@ -113,6 +110,8 @@ __attribute__((const)) INLINE static int integer_powf(const float x,
const
float
z
=
y
*
y
;
const
float
z
=
y
*
y
;
return
z
*
z
;
return
z
*
z
;
}
}
default:
return
powf
(
x
,
(
float
)
n
);
}
}
}
}
...
...
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