Go to the source code of this file.
|
template<class T > |
constexpr T | qx::abs (T value) |
| Constexpr absolute value. More...
|
|
template<std::integral T> |
constexpr bool | qx::is_odd (T val) |
| Check if value is odd. More...
|
|
template<std::integral T> |
constexpr bool | qx::is_even (T val) |
| Check if value is even. More...
|
|
constexpr int | qx::gcd (int nFirst, int nSecond) |
| Greatest common divisor. More...
|
|
constexpr int | qx::lcm (int nFirst, int nSecond) |
| Least common multiple. More...
|
|
template<class T > |
constexpr double | qx::pow (T number, int nPower) |
| Power function for integer power. More...
|
|
template<std::integral I> |
I | qx::maxpot (I nValue) |
| Max power of two in integer. More...
|
|
- Author
- Khrapov
- Date
- 29.04.2023
- Copyright
- © Nick Khrapov, 2023. All right reserved.
Definition in file common.inl.
◆ abs()
template<class T >
constexpr T qx::abs |
( |
T |
value | ) |
|
|
constexpr |
Constexpr absolute value.
- Template Parameters
-
- Parameters
-
- Return values
-
Definition at line 14 of file common.inl.
◆ gcd()
constexpr int qx::gcd |
( |
int |
nFirst, |
|
|
int |
nSecond |
|
) |
| |
|
constexpr |
Greatest common divisor.
Euclid's algorithm based on fact gcd(A, B) == gcd(B, A mod B)
- Complexity:
- O(log(second))
- Parameters
-
nFirst | - first num |
nSecond | - second num |
- Return values
-
- | greatest common divisor if first and second > 0, otherwise 0 |
Definition at line 31 of file common.inl.
◆ is_even()
template<std::integral T>
constexpr bool qx::is_even |
( |
T |
val | ) |
|
|
constexpr |
Check if value is even.
- Template Parameters
-
- Parameters
-
- Return values
-
Definition at line 26 of file common.inl.
◆ is_odd()
template<std::integral T>
constexpr bool qx::is_odd |
( |
T |
val | ) |
|
|
constexpr |
Check if value is odd.
- Template Parameters
-
- Parameters
-
- Return values
-
Definition at line 20 of file common.inl.
◆ lcm()
constexpr int qx::lcm |
( |
int |
nFirst, |
|
|
int |
nSecond |
|
) |
| |
|
constexpr |
Least common multiple.
- Complexity:
- O(log(second))
- Parameters
-
nFirst | - first num |
nSecond | - second num |
- Return values
-
- | least common multiple if first and second > 0, otherwise 0 |
Definition at line 46 of file common.inl.
◆ maxpot()
template<std::integral I>
Max power of two in integer.
- Template Parameters
-
- Parameters
-
- Return values
-
- | max power of two in the number |
Definition at line 129 of file common.inl.
◆ pow()
template<class T >
constexpr double qx::pow |
( |
T |
number, |
|
|
int |
nPower |
|
) |
| |
|
constexpr |
Power function for integer power.
About 2.22 times (positive powers) 1.7 times (positive and negative powers) 2.33 times (negative powers) faster than std::pow
- Complexity:
- O(log(power))
- Template Parameters
-
T | - Integral or floating point type |
- Parameters
-
number | - integral of floating point value |
nPower | - integral power |
- Return values
-
Definition at line 58 of file common.inl.