StatMech
Loading...
Searching...
No Matches
powi.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#ifndef __NVCC__
4
# define __host__
5
# define __device__
6
#endif
7
8
template
<
typename
Integer1,
typename
Integer2>
9
static
inline
__host__ __device__ Integer1 powi(Integer1 base, Integer2 exponent) {
10
if
(exponent == 0)
return
1;
11
if
(exponent == 1)
return
base;
12
13
Integer1 temp = powi(base, exponent / 2);
14
if
(exponent % 2 == 0)
return
temp * temp;
15
else
return
base * temp * temp;
16
}
Locality
Headers
Algorithm
powi.hpp
Generated on Thu Jul 20 2023 03:02:34 for StatMech by
1.9.7