numerical-collection-cpp
0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
pow_pos_int.h
Go to the documentation of this file.
1
/*
2
* Copyright 2021 MusicScience37 (Kenta Kabashima)
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
20
#pragma once
21
22
#include "
num_collect/constants/one.h
"
// IWYU pragma: keep
23
#include "
num_collect/constants/two.h
"
// IWYU pragma: keep
24
#include "
num_collect/constants/zero.h
"
// IWYU pragma: keep
25
26
namespace
num_collect::constants::impl
{
27
39
template
<
typename
T,
typename
I>
40
constexpr
auto
pow_pos_int
(T base, I
exp
) -> T {
41
if
(
exp
==
zero<I>
) {
42
return
one<T>
;
43
}
44
if
(
exp
==
one<I>
) {
45
return
base;
46
}
47
if
(
exp
==
two<I>
) {
48
return
base * base;
49
}
50
I exp1 =
exp
/
two<I>
;
51
I exp2 =
exp
- exp1;
52
return
pow_pos_int
(base, exp1) *
pow_pos_int
(base, exp2);
53
}
54
55
}
// namespace num_collect::constants::impl
num_collect::constants::impl
Namespace of internal implementations.
Definition
exp_maclaurin.h:24
num_collect::constants::impl::pow_pos_int
constexpr auto pow_pos_int(T base, I exp) -> T
Calculate the value of base raised to the power exp.
Definition
pow_pos_int.h:40
num_collect::constants::two
constexpr T two
Value 2.
Definition
two.h:30
num_collect::constants::exp
constexpr auto exp(T x) -> T
Calculate exponential function .
Definition
exp.h:46
num_collect::constants::zero
constexpr T zero
Value 0.
Definition
zero.h:30
num_collect::constants::one
constexpr T one
Value 1.
Definition
one.h:30
one.h
Definition of one.
two.h
Definition of two.
zero.h
Definition of zero.
include
num_collect
constants
impl
pow_pos_int.h
Generated on Sat Jan 18 2025 03:47:32 for numerical-collection-cpp by
1.12.0