Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
xerus
xerus
Commits
70aa8d02
Commit
70aa8d02
authored
Dec 11, 2017
by
Ben Huber
Browse files
fixed ambiguous calls to misc::pow on some systems (relates
#205
)
parent
aa5cad36
Pipeline
#854
passed with stages
in 8 minutes and 36 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/xerus/misc/math.h
View file @
70aa8d02
...
...
@@ -46,35 +46,15 @@ namespace xerus {
///@brief: Calculates _base^_exp by binary exponentiation
template
<
class
T
>
constexpr
T
pow
(
const
T
&
_base
,
const
uint32
_exp
)
noexcept
{
return
_exp
==
0
?
T
(
1
)
:
(
_exp
%
2
==
0
?
pow
(
T
(
_base
*
_base
),
_exp
/
2
)
:
T
(
_base
*
pow
(
_base
,
_exp
-
1
)));
}
///@brief: Calculates _base^_exp by binary exponentiation
template
<
class
T
>
constexpr
T
pow
(
const
T
&
_base
,
const
uint64
_exp
)
noexcept
{
template
<
class
T
,
class
I
,
typename
std
::
enable_if
<
std
::
is_integral
<
I
>
::
value
&&
std
::
is_unsigned
<
I
>::
value
,
bool
>::
type
=
true
>
constexpr
T
pow
(
const
T
&
_base
,
const
I
_exp
)
noexcept
{
return
_exp
==
0
?
T
(
1
)
:
(
_exp
%
2
==
0
?
pow
(
T
(
_base
*
_base
),
_exp
/
2
)
:
T
(
_base
*
pow
(
_base
,
_exp
-
1
)));
}
///@brief: Calculates _base^_exp by binary exponentiation
template
<
class
T
>
constexpr
T
pow
(
const
T
&
_base
,
const
int64
_exp
)
noexcept
{
return
_exp
==
0
?
T
(
1
)
:
(
_exp
<
0
?
T
(
1
/
pow
(
_base
,
-
_exp
))
:
(
_exp
%
2
==
0
?
pow
(
T
(
_base
*
_base
),
_exp
/
2
)
:
T
(
_base
*
pow
(
_base
,
_exp
-
1
))
)
);
}
///@brief: Calculates _base^_exp by binary exponentiation
template
<
class
T
>
constexpr
T
pow
(
const
T
&
_base
,
const
int32
_exp
)
noexcept
{
template
<
class
T
,
class
I
,
typename
std
::
enable_if
<
std
::
is_integral
<
I
>
::
value
&&
!
std
::
is_unsigned
<
I
>::
value
,
bool
>::
type
=
true
>
constexpr
T
pow
(
const
T
&
_base
,
const
I
_exp
)
noexcept
{
return
_exp
==
0
?
T
(
1
)
:
(
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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