Version: SMASH-3.3
pow.h
Go to the documentation of this file.
1
/*
2
*
3
* Copyright (c) 2016-2018,2020,2022,2025
4
* SMASH Team
5
*
6
* GNU General Public License (GPLv3 or later)
7
*
8
*/
9
10
#ifndef SRC_INCLUDE_SMASH_POW_H_
11
#define SRC_INCLUDE_SMASH_POW_H_
12
13
namespace
smash
{
14
22
template
<
class
T>
23
inline
constexpr T
pow_int
(
const
T base,
unsigned
const
exponent) {
24
return
(exponent == 0) ? 1
25
: (exponent % 2 == 0)
26
?
pow_int
(base, exponent / 2) *
pow_int
(base, exponent / 2)
27
: base *
pow_int
(base, exponent - 1);
28
}
29
30
}
// namespace smash
31
32
#endif
// SRC_INCLUDE_SMASH_POW_H_
smash
Definition:
action.h:24
smash::pow_int
constexpr T pow_int(const T base, unsigned const exponent)
Efficient template for calculating integer powers using squaring.
Definition:
pow.h:23
src
include
smash
pow.h
Impressum
Data privacy protection
Generated on Wed Dec 3 2025 11:41:37 for SMASH Development Documentation by
Doxygen
1.9.1