mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Maths functions documentation
This commit is contained in:
parent
7813d3ce7b
commit
303ba36f6d
5
docs/maths/_index.md
Normal file
5
docs/maths/_index.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
title: "Maths"
|
||||
weight: 100
|
||||
---
|
||||
|
||||
37
docs/maths/absolute.md
Normal file
37
docs/maths/absolute.md
Normal file
@ -0,0 +1,37 @@
|
||||
---
|
||||
title: "absolute"
|
||||
---
|
||||
|
||||
A template functions that return the absolute value.
|
||||
|
||||
```cpp
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR T absolute(T value)
|
||||
```
|
||||
**Return**
|
||||
The absolute of `value`.
|
||||
|
||||
If T is `int8_t`:-
|
||||
`0` => `0`
|
||||
`127` => `127`
|
||||
`-127` => `127`
|
||||
|
||||
**Error**
|
||||
Asserts if `value == etl::integral_limits<T>::min`.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR etl::make_unsigned_t<T> absolute_unsigned(T value)
|
||||
```
|
||||
**Return**
|
||||
The absolute of `value`, cast to the unsigned version of type `T`.
|
||||
|
||||
If T is `int8_t`:-
|
||||
|
||||
Return type is `etl::make_unsigned_t<T>`
|
||||
`0` => `0`
|
||||
`127` => `127`
|
||||
`-127` => `127`
|
||||
`-128` => `128`
|
||||
@ -1,7 +1,11 @@
|
||||
Checksums & hashes
|
||||
---
|
||||
title: "Checksums & hashes"
|
||||
---
|
||||
|
||||
A set of algorithms for producing checksums and hashes from data.
|
||||
____________________________________________________________________________________________________
|
||||
Generic hashes
|
||||
|
||||
## Generic hashes
|
||||
```
|
||||
Type Class Header
|
||||
Checksum checksum checksum.h (8, 16, 32 or 64 bit)
|
||||
BSD Checksum bsd_checksum checksum.h (8, 16, 32 or 64 bit)
|
||||
@ -19,11 +23,17 @@ Jenkins jenkins jenkins.h
|
||||
Pearson pearson pearson.h
|
||||
|
||||
Murmur3 murmur3 murmur3.h (32 or 64 bit)
|
||||
____________________________________________________________________________________________________
|
||||
CRC hashes
|
||||
```
|
||||
|
||||
## CRC1
|
||||
```
|
||||
Type Class Table size Header
|
||||
CRC1 crc1 0 crc1.h, crc.h
|
||||
```
|
||||
|
||||
## CRC8
|
||||
```
|
||||
Type Class Table size Header
|
||||
CRC8 CCITT crc8_ccitt 256 crc8_ccitt.h, crc.h
|
||||
crc8_ccitt_t4 4
|
||||
crc8_ccitt_t16 16
|
||||
@ -95,7 +105,10 @@ CRC8 WCDMA crc8_wcdma 256 crc8_wcdma.h, cr
|
||||
crc8_wcdma_t16 16
|
||||
crc8_wcdma_t256 256
|
||||
crc8_wcdma_t<N> N = 4, 16, 256
|
||||
____________________________________________________________________________________________________
|
||||
```
|
||||
## CRC16
|
||||
```
|
||||
Type Class Table size Header
|
||||
CRC16 crc16 256 crc16.h, crc.h
|
||||
crc16_t4 4
|
||||
crc16_t16 16
|
||||
@ -251,7 +264,11 @@ CRC16 XMODEM crc16_xmodem 256 crc16_xmodem.h,
|
||||
crc16_xmodem_t16 16
|
||||
crc16_xmodem_t256 256
|
||||
crc16_xmodem_t<N> N = 4, 16, 256
|
||||
____________________________________________________________________________________________________
|
||||
```
|
||||
|
||||
## CRC32
|
||||
```
|
||||
Type Class Table size Header
|
||||
CRC32 crc32 256 crc32.h, crc.h
|
||||
crc32_t4 4
|
||||
crc32_t16 16
|
||||
@ -305,7 +322,11 @@ CRC32 XFER crc32_xfer 256 crc32_xfer.h,
|
||||
crc32_xfer_t16 16
|
||||
crc32_xfer_t256 256
|
||||
crc32_xfer_t<N> N = 4, 16, 256
|
||||
____________________________________________________________________________________________________
|
||||
```
|
||||
|
||||
## CRC32
|
||||
```
|
||||
Type Class Table size Header
|
||||
CRC64 ECMA crc64_ecma 256 crc64_ecma.h, crc.h
|
||||
crc32_ecma_t4 4
|
||||
crc32_ecma_t16 16
|
||||
@ -317,56 +338,85 @@ CRC64 ISO crc64_iso 256 crc64_iso.h, cr
|
||||
crc32_iso_t16 16
|
||||
crc32_iso_t256 256
|
||||
crc32_iso_t<N> N = 4, 16, 256
|
||||
```
|
||||
|
||||
The library also includes etl::hash which is a reverse engineered version of std::hash in hash.h
|
||||
## Hash
|
||||
The library also includes etl::hash which is a reverse engineered version of `std::hash` in `hash.h`
|
||||
|
||||
All hashing templates have the same API, apart from the members returning the hash value, which return the appropriate type.
|
||||
|
||||
A hash that requires finalising before the value is read should do it in the conversion operator and value() member functions. Trying to add values after finalisation should result in an etl::hash_finalised error being asserted. Construction or reset should clear any finalisation flag.
|
||||
____________________________________________________________________________________________________
|
||||
Hash API
|
||||
A hash that requires finalising before the value is read should do it in the conversion operator and `value()` member functions. Trying to add values after finalisation should result in an `etl::hash_finalised error` being asserted. Construction or reset should clear any finalisation flag.
|
||||
|
||||
## Hash API
|
||||
All hashing algorithms supply the following API.
|
||||
|
||||
Default constructor
|
||||
Initialises the hash value to its appropriate starting value.
|
||||
____________________________________________________________________________________________________
|
||||
|
||||
Constructor from a range. (Any iterator type)
|
||||
Creates a hash from the supplied range.
|
||||
____________________________________________________________________________________________________
|
||||
|
||||
```cpp
|
||||
void reset();
|
||||
```
|
||||
**Decsription**
|
||||
Resets the hash to the initial condition.
|
||||
____________________________________________________________________________________________________
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
void add(uint8_t value);
|
||||
Adds a uint8_t to the hash.
|
||||
____________________________________________________________________________________________________
|
||||
```
|
||||
Adds a `uint8_t` to the hash.
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void add(TIterator begin, Titerator end);
|
||||
|
||||
```
|
||||
**Description**
|
||||
Adds a range of values to the hash.
|
||||
If the type pointed to must be default castable to uint8_t.
|
||||
____________________________________________________________________________________________________
|
||||
value_type value() const;
|
||||
Returns the hash value.
|
||||
The hash will be finalised if required.
|
||||
____________________________________________________________________________________________________
|
||||
operator value_type() const;
|
||||
Returns the hash value.
|
||||
The hash will be finalised if required.
|
||||
__________________________________________________________________________________________________
|
||||
iterator input()
|
||||
Returns an iterator that allows the input of new values.
|
||||
If the type pointed to must be default castable to `uint8_t`.
|
||||
|
||||
Example
|
||||
---
|
||||
|
||||
```cpp
|
||||
value_type value() const;
|
||||
```
|
||||
**Return**
|
||||
The hash value.
|
||||
The hash will be finalised if required.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
operator value_type() const;
|
||||
```
|
||||
**Return**
|
||||
The hash value.
|
||||
The hash will be finalised if required.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
iterator input()
|
||||
```
|
||||
**Return**
|
||||
An iterator that allows the input of new values.
|
||||
|
||||
**Example**
|
||||
```cpp
|
||||
std::array data{ 9, 1, 8, 2, 7, 3, 6, 4, 5 };
|
||||
etl::crc32 crc_calculator;
|
||||
std::copy(data.begin(), data.end(), crc_calculator.input());
|
||||
uint32_t crc = crc_calculator.value();
|
||||
____________________________________________________________________________________________________
|
||||
Creating a new frame check type.
|
||||
```
|
||||
|
||||
## Creating a new frame check type.
|
||||
The frame_check_sequence class may be customised with new policies that contain the expected typedef and member functions:-
|
||||
|
||||
Example
|
||||
**Example**
|
||||
|
||||
```cpp
|
||||
struct special_16
|
||||
{
|
||||
typedef uint16_t value_type;
|
||||
@ -386,9 +436,11 @@ struct special_16
|
||||
return ~sum; // How to read the final value.
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
The hash class would be declared as follows.
|
||||
|
||||
```cpp
|
||||
//*************************************************************************
|
||||
/// Special checksum
|
||||
//*************************************************************************
|
||||
@ -416,4 +468,4 @@ public:
|
||||
this->add(begin, end);
|
||||
}
|
||||
};
|
||||
|
||||
```
|
||||
47
docs/maths/comb-perm.md
Normal file
47
docs/maths/comb-perm.md
Normal file
@ -0,0 +1,47 @@
|
||||
---
|
||||
title: "Combinations / Permutations"
|
||||
---
|
||||
|
||||
Templates to provide combinations and permutations constants.
|
||||
|
||||
## Combinations
|
||||
|
||||
See [Combinations](https://en.wikipedia.org/wiki/Combination)
|
||||
|
||||
```cpp
|
||||
template <size_t N, size_t K>
|
||||
struct combinations
|
||||
```
|
||||
|
||||
**Member const**
|
||||
Number of combinations of K items from a total of N.
|
||||
```cpp
|
||||
static ETL_CONSTEXPR size_t value
|
||||
```
|
||||
|
||||
If C++17 is supported.
|
||||
```cpp
|
||||
template <size_t N, size_t K>
|
||||
inline constexpr size_t combinations_v = combinations<N, K>::value;
|
||||
```
|
||||
|
||||
## Permutations
|
||||
|
||||
See [Permutations](https://en.wikipedia.org/wiki/Permutation)
|
||||
|
||||
```cpp
|
||||
template <size_t N, size_t K>
|
||||
struct permutations
|
||||
```
|
||||
|
||||
**Member const**
|
||||
Number of permutations of K items from a total of N.
|
||||
```cpp
|
||||
static ETL_CONSTEXPR size_t value
|
||||
```
|
||||
|
||||
If C++17 is supported.
|
||||
```cpp
|
||||
template <size_t N, size_t K>
|
||||
inline constexpr size_t permutations_v = permutations<N, K>::value;
|
||||
```
|
||||
@ -1,135 +1,190 @@
|
||||
Constants
|
||||
---
|
||||
title: "Constants"
|
||||
---
|
||||
|
||||
A set of compile time constants.
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
log.h
|
||||
log
|
||||
## log
|
||||
```cpp
|
||||
template <size_t N, size_t BASE>
|
||||
struct log;
|
||||
```
|
||||
|
||||
Defines the member value as the log of N to base BASE.
|
||||
Set to the integer below the ideal floating point value.
|
||||
Header: *log.h*
|
||||
|
||||
C++17 and above
|
||||
Defines the member value as the log of N to base BASE.
|
||||
Set to the integer below the ideal floating point value.
|
||||
|
||||
C++17 and above
|
||||
```cpp
|
||||
template <size_t N, size_t BASE>
|
||||
inline constexpr size_t log_v = log<N, BASE>::value;
|
||||
____________________________________________________________________________________________________
|
||||
log2
|
||||
```
|
||||
|
||||
## log2
|
||||
```cpp
|
||||
template <size_t N>
|
||||
struct log2;
|
||||
```
|
||||
|
||||
Defines the member value as the log of N to base 2
|
||||
Set to the integer below the ideal floating point value.
|
||||
Header: *log.h*
|
||||
|
||||
C++17 and above
|
||||
Defines the member value as the log of N to base 2
|
||||
Set to the integer below the ideal floating point value.
|
||||
|
||||
C++17 and above
|
||||
```cpp
|
||||
template <size_t N>
|
||||
inline constexpr size_t log2_v = log2<N>::value;
|
||||
``
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
log10
|
||||
## log10
|
||||
```cpp
|
||||
template <size_t N>
|
||||
struct log10;
|
||||
```
|
||||
|
||||
Defines the member value as the log of N to base 10
|
||||
Set to the integer below the ideal floating point value.
|
||||
Header: *log.h*
|
||||
|
||||
C++17 and above
|
||||
Defines the member value as the log of N to base 10
|
||||
Set to the integer below the ideal floating point value.
|
||||
|
||||
C++17 and above
|
||||
```cpp
|
||||
template <size_t N>
|
||||
inline constexpr size_t log10_v = log10<N>::value;
|
||||
```
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
power.h
|
||||
power
|
||||
## power
|
||||
```cpp
|
||||
template <size_t N, size_t POWER>
|
||||
struct power;
|
||||
```
|
||||
|
||||
Defines the member value as N raised to the power POWER.
|
||||
Header: *power.h*
|
||||
|
||||
C++17 and above
|
||||
Defines the member value as N raised to the power `POWER`.
|
||||
|
||||
C++17 and above
|
||||
```cpp
|
||||
template <size_t N, size_t POWER>
|
||||
inline constexpr size_t power_v = power<N, POWER>::value;
|
||||
```
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
power_of_2_round_up
|
||||
## power_of_2_round_up
|
||||
```cpp
|
||||
template <size_t N>
|
||||
struct power_of_2_round_up;
|
||||
```
|
||||
|
||||
Defines the member value to the next equal or higher power of 2.
|
||||
Header: *power.h*
|
||||
|
||||
Defines the member value to the next equal or higher power of 2.
|
||||
|
||||
```cpp
|
||||
power_of_2_round_up<7> -> 8
|
||||
power_of_2_round_up<8> -> 8
|
||||
power_of_2_round_up<9> -> 16
|
||||
```
|
||||
|
||||
C++17 and above
|
||||
C++17 and above
|
||||
```cpp
|
||||
template <size_t N, size_t POWER>
|
||||
inline constexpr size_t power_of_2_round_up_v = power_of_2_round_up<N, POWER>::value;
|
||||
____________________________________________________________________________________________________
|
||||
power_of_2_round_down
|
||||
```
|
||||
|
||||
## power_of_2_round_down
|
||||
```cpp
|
||||
template <size_t N>
|
||||
struct power_of_2_round_down;
|
||||
```
|
||||
|
||||
Defines the member value to the next equal or lower power of 2.
|
||||
Header: *power.h*
|
||||
|
||||
Defines the member value to the next equal or lower power of 2.
|
||||
|
||||
```cpp
|
||||
power_of_2_round_down<7> -> 4
|
||||
power_of_2_round_down<8> -> 4
|
||||
power_of_2_round_down<9> -> 8
|
||||
```
|
||||
|
||||
C++17 and above
|
||||
C++17 and above
|
||||
```cpp
|
||||
template <size_t N, size_t POWER>
|
||||
inline constexpr size_t power_of_2_round_down_v = power_of_2_round_down<N, POWER>::value;
|
||||
```
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
is_power_of_2
|
||||
## is_power_of_2
|
||||
```cpp
|
||||
template <size_t N>
|
||||
struct is_power_of_2;
|
||||
```
|
||||
|
||||
Defines the member value to true if N is a power of 2, otherwise false.
|
||||
Header: *power.h*
|
||||
|
||||
C++17 and above
|
||||
Defines the member value to true if N is a power of 2, otherwise false.
|
||||
|
||||
C++17 and above
|
||||
```cpp
|
||||
template <size_t N, size_t POWER>
|
||||
inline constexpr size_t is_power_of_2_v = is_power_of_2<N, POWER>::value;
|
||||
```
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
sqrt.h
|
||||
sqrt
|
||||
## sqrt
|
||||
```cpp
|
||||
template <size_t N, size_t I = 1>
|
||||
struct sqrt;
|
||||
```
|
||||
|
||||
Defines the member value as the largest integer that, when squared, is at less than or equal to N.
|
||||
Header: *sqrt.h*
|
||||
|
||||
C++17 and above
|
||||
Defines the member value as the largest integer that, when squared, is at less than or equal to N.
|
||||
|
||||
C++17 and above
|
||||
```cpp
|
||||
template <size_t N, size_t I = 1>
|
||||
inline constexpr size_t sqrt_v = sqrt<N, POWER>::value;
|
||||
```
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
factorial.h
|
||||
factorial
|
||||
## factorial
|
||||
```cpp
|
||||
template <const size_t N>
|
||||
struct factorial;
|
||||
```
|
||||
|
||||
Defines the member value as the Nth factorial.
|
||||
Header: *factorial.h*
|
||||
|
||||
C++17 and above
|
||||
Defines the member value as the Nth factorial.
|
||||
|
||||
C++17 and above
|
||||
```cpp
|
||||
template <size_t N>
|
||||
inline constexpr size_t factorial_v = factorial<N>::value;
|
||||
```
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
fibbonacci.h
|
||||
fibbonacci
|
||||
## fibbonacci
|
||||
```cpp
|
||||
template <const size_t N>
|
||||
struct fibbonacci;
|
||||
```
|
||||
|
||||
Defines the member value as the Nth in the Fibbonacci sequence
|
||||
Header: *fibbonacci.h*
|
||||
|
||||
C++17 and above
|
||||
Defines the member value as the Nth in the Fibbonacci sequence
|
||||
|
||||
C++17 and above
|
||||
```cpp
|
||||
template <size_t N>
|
||||
inline constexpr size_t fibbonacci_v = fibbonacci<N>::value;
|
||||
```
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
math_constants.h
|
||||
## Maths constants
|
||||
|
||||
Namespace : etl::math
|
||||
Header: *math_constants.h*
|
||||
Namespace : *etl::math*
|
||||
|
||||
```cpp
|
||||
ETL_CONSTANT double pi = 3.14159265358979;
|
||||
ETL_CONSTANT double pi_reciprocal = 0.31830988618379;
|
||||
ETL_CONSTANT double pi_squared = 9.86960440108936;
|
||||
@ -140,4 +195,4 @@ ETL_CONSTANT double root2 = 1.41421356237310;
|
||||
ETL_CONSTANT double root2_reciprocal = 0.70710678118655;
|
||||
ETL_CONSTANT double euler = 0.57721566490153;
|
||||
ETL_CONSTANT double golden_ratio = 1.61803398874989;
|
||||
|
||||
```
|
||||
@ -1,57 +1,114 @@
|
||||
Correlation
|
||||
20.9.0
|
||||
---
|
||||
title: "Correlation"
|
||||
---
|
||||
|
||||
{{< callout type="info">}}
|
||||
Header: `correlation.h`
|
||||
Since: `20.9.0`
|
||||
{{< /callout >}}
|
||||
|
||||
Calculates the correlation of two sets of data.
|
||||
|
||||
```cpp
|
||||
template <bool Correlation_Type, typename TInput, typename TCalc = TInput>
|
||||
class correlation : public etl::binary_function<TInput, TInput, void>
|
||||
```
|
||||
`Correlation_Type` `Population` or `Sample`.
|
||||
`TInput` The input data type.
|
||||
`TCalc` The type to use for internal calculations. By default, equal to `TInput`.
|
||||
|
||||
Correlation_Type Population or Sample.
|
||||
TInput The input data type.
|
||||
TCalc The type to use for internal calculations. By default, equal to TInput.
|
||||
____________________________________________________________________________________________________
|
||||
correlation_type
|
||||
etl::correlation_type::Sample
|
||||
etl::correlation_type::Population
|
||||
____________________________________________________________________________________________________
|
||||
correlation
|
||||
**correlation_type**
|
||||
`etl::correlation_type::Sample`
|
||||
`etl::correlation_type::Population`
|
||||
|
||||
## Construction
|
||||
```cpp
|
||||
correlation()
|
||||
```
|
||||
**Description**
|
||||
Default constructor.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
correlation(TIterator first1, TIterator last1, TIterator first2)
|
||||
```
|
||||
**Decsription**
|
||||
Construct from two iterator ranges.
|
||||
____________________________________________________________________________________________________
|
||||
|
||||
```cpp
|
||||
void add(TInput value1, TInput value2)
|
||||
```
|
||||
**Description**
|
||||
Add a pair of values.
|
||||
|
||||
## Member functions
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void add(TIterator first1, TIterator last1, TIterator first2)
|
||||
```
|
||||
**Description**
|
||||
Add a range of values.
|
||||
____________________________________________________________________________________________________
|
||||
|
||||
```cpp
|
||||
void operator()(TInput value1, TInput value2)
|
||||
```
|
||||
Add a pair of values.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void operator()(TIterator first1, TIterator last1, TIterator first2)
|
||||
```
|
||||
**Description**
|
||||
Add a range of values.
|
||||
____________________________________________________________________________________________________
|
||||
double get_covariance() const
|
||||
Returns the calculated covariance for the data.
|
||||
____________________________________________________________________________________________________
|
||||
double get_correlation() const
|
||||
Returns the calculated correlation for the data.
|
||||
____________________________________________________________________________________________________
|
||||
operator double() const
|
||||
Returns the calculated correlation for the data.
|
||||
____________________________________________________________________________________________________
|
||||
size_t count() const
|
||||
Get the total number added entries.
|
||||
____________________________________________________________________________________________________
|
||||
void clear()
|
||||
Clear the correlation.
|
||||
____________________________________________________________________________________________________
|
||||
Example
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
double get_covariance() const
|
||||
```
|
||||
**Decsription**
|
||||
Returns the calculated covariance for the data.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
double get_correlation() const
|
||||
```
|
||||
**Description**
|
||||
Returns the calculated correlation for the data.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
operator double() const
|
||||
```
|
||||
**Description**
|
||||
Returns the calculated correlation for the data.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
size_t count() const
|
||||
```
|
||||
**Description**
|
||||
Get the total number added entries.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
void clear()
|
||||
```
|
||||
**Description**
|
||||
Clear the correlation.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
std::array<char, 10> input_c
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
||||
@ -71,4 +128,4 @@ double covariance_result;
|
||||
|
||||
correlation_result = correlation; // correlation_result == -1.0
|
||||
covariance_result = correlation.get_covariance(); // covariance_result == -8.25
|
||||
|
||||
```
|
||||
121
docs/maths/covariance.md
Normal file
121
docs/maths/covariance.md
Normal file
@ -0,0 +1,121 @@
|
||||
---
|
||||
title: "Covariance"
|
||||
---
|
||||
|
||||
{{< callout type="info">}}
|
||||
Header: `covariance.h`
|
||||
Since: `20.9.0`
|
||||
{{< /callout >}}
|
||||
|
||||
```cpp
|
||||
template <bool Covariance_Type, typename TInput, typename TCalc = TInput>
|
||||
class covariance : public etl::binary_function<TInput, TInput, void>
|
||||
```
|
||||
|
||||
`Covariance_Type` `Population` or `Sample`.
|
||||
`TInput` The input data type.
|
||||
`TCalc` The type to use for internal calculations. By default, equal to `TInput`.
|
||||
|
||||
|
||||
## covariance_type
|
||||
`etl::covariance_type::Sample`
|
||||
`etl::covariance_type::Population`
|
||||
|
||||
## Constructor
|
||||
```cpp
|
||||
covariance()
|
||||
```
|
||||
Default constructor.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
covariance(TIterator first1, TIterator last1, TIterator first2)
|
||||
```
|
||||
**Description**
|
||||
Construct from two iterator ranges.
|
||||
|
||||
## Member functions
|
||||
|
||||
```cpp
|
||||
void add(TInput value1, TInput value2)
|
||||
```
|
||||
**Description**
|
||||
Add a pair of values.
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void add(TIterator first1, TIterator last1, TIterator first2)
|
||||
```
|
||||
**Description**
|
||||
Add a range of values.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
void operator()(TInput value1, TInput value2)
|
||||
```
|
||||
**Description**
|
||||
Add a pair of values.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void operator()(TIterator first1, TIterator last1, TIterator first2)
|
||||
```
|
||||
**Description**
|
||||
Add a range of values.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
double get_covariance() const
|
||||
```
|
||||
**Return**
|
||||
The calculated covariance for the data.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
operator double() const
|
||||
```
|
||||
**Return**
|
||||
The calculated covariance for the data.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
size_t count() const
|
||||
```
|
||||
**Description**
|
||||
Get the total number added entries.
|
||||
|
||||
```cpp
|
||||
void clear()
|
||||
```
|
||||
**Description**
|
||||
Clear the covariance.
|
||||
|
||||
## Example
|
||||
|
||||
```cpp
|
||||
std::array<char, 10> input_c
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
||||
};
|
||||
|
||||
std::array<char, 10> input_c_inv
|
||||
{
|
||||
0, -1, -2, -3, -4, -5, -6, -7, -8, -9
|
||||
};
|
||||
|
||||
etl::covariance<etl::covariance_type::Population, char, int32_t> covariance(input_c.begin(),
|
||||
input_c.end(),
|
||||
input_c_inv.begin());
|
||||
|
||||
double covariance_result;
|
||||
|
||||
covariance_result = covariance; // covariance_result == -8.25
|
||||
```
|
||||
@ -1,30 +1,57 @@
|
||||
Gamma
|
||||
20.9.0
|
||||
---
|
||||
title: "Gamma"
|
||||
---
|
||||
|
||||
There are two gamma functors, gamma_encode and gamma_decode.
|
||||
{{< callout type="info">}}
|
||||
Header: `gamma.h`
|
||||
Since: `20.9.0`
|
||||
{{< /callout >}}
|
||||
|
||||
There are two gamma functors, `gamma_encode` and `gamma_decode`.
|
||||
|
||||
```cpp
|
||||
template <typename TInput>
|
||||
class gamma_encode : public etl::unary_function<TInput, TInput>
|
||||
|
||||
```
|
||||
```cpp
|
||||
template <typename TInput>
|
||||
class gamma_decode : public etl::unary_function<TInput, TInput>
|
||||
```
|
||||
|
||||
TInput The input data type.
|
||||
____________________________________________________________________________________________________
|
||||
`TInput` The input data type.
|
||||
|
||||
```cpp
|
||||
gamma_encode(double gamma, TInput maximum)
|
||||
```
|
||||
**Description**
|
||||
Constructor.
|
||||
____________________________________________________________________________________________________
|
||||
TInput operator()(TInput value) const
|
||||
Gamma a value.
|
||||
____________________________________________________________________________________________________
|
||||
gamma_decode(double gamma, TInput maximum)
|
||||
Constructor.
|
||||
____________________________________________________________________________________________________
|
||||
TInput operator()(TInput value) const
|
||||
Gamma a value.
|
||||
____________________________________________________________________________________________________
|
||||
Example
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
TInput operator()(TInput value) const
|
||||
```
|
||||
**Description**
|
||||
Gamma a value.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
gamma_decode(double gamma, TInput maximum)
|
||||
```
|
||||
**Decsription**
|
||||
Constructor.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
TInput operator()(TInput value) const
|
||||
```
|
||||
**Description**
|
||||
Gamma a value.
|
||||
|
||||
## Example
|
||||
```cpp
|
||||
std::array<double, 10> input
|
||||
{
|
||||
0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0
|
||||
@ -45,4 +72,4 @@ etl::gamma_decode<double> gamma_decode(0.5, 9.0);
|
||||
std::transform(output_encode.begin(), output_encode.end(), output_decode.begin(), gamma_decode);
|
||||
|
||||
// output_decode == 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0
|
||||
|
||||
```
|
||||
352
docs/maths/histogram.md
Normal file
352
docs/maths/histogram.md
Normal file
@ -0,0 +1,352 @@
|
||||
---
|
||||
title: "Histgram"
|
||||
---
|
||||
|
||||
{{< callout type="info">}}
|
||||
Header: `histogram.h`
|
||||
Since: `20.9.0`
|
||||
{{< /callout >}}
|
||||
|
||||
## Member types
|
||||
`const_iterator` The iterator used to traverse the histogram data.
|
||||
`key_type` The index type for the histogram.
|
||||
`count_type` The type used for the histogram counter.
|
||||
`value_type` The type returned from the histogram.
|
||||
|
||||
## Constants
|
||||
`Max_Size` The maximum number of elements in the histogram.
|
||||
|
||||
## histogram
|
||||
```cpp
|
||||
template <typename TKey, typename TCount, size_t Max_Keys>
|
||||
class histogram
|
||||
```
|
||||
**Description**
|
||||
A histogram where the start index of the keys is defined in the constructor.
|
||||
|
||||
## Member functions
|
||||
```cpp
|
||||
histogram()
|
||||
```
|
||||
**Description**
|
||||
Default constructor.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
histogram(TIterator first, TIterator last)
|
||||
```
|
||||
**Description**
|
||||
Construct from an iterator range.
|
||||
|
||||
---
|
||||
|
||||
## histogram
|
||||
|
||||
```cpp
|
||||
template <typename TKey, typename TCount, size_t Max_Keys, size_t Start_Index>
|
||||
class histogram
|
||||
```
|
||||
**Description**
|
||||
A histogram where the start index of the keys is defined as a template parameter.
|
||||
|
||||
## Member functions
|
||||
|
||||
```cpp
|
||||
histogram()
|
||||
```
|
||||
**Description**
|
||||
Default constructor.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
histogram(TIterator first, TIterator last)
|
||||
```
|
||||
**Description**
|
||||
Construct from an iterator range.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
histogram(const histogram& other)
|
||||
```
|
||||
**Description**
|
||||
Copy constructor.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
histogram(histogram&& other)
|
||||
```
|
||||
**Description**
|
||||
Move constructor.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
histogram& operator =(const histogram& rhs)
|
||||
```
|
||||
**Description**
|
||||
Assignment operator.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
histogram& operator =(histogram&& rhs)
|
||||
```
|
||||
**Description**
|
||||
Move assignment operator.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
void add(key_type key)
|
||||
```
|
||||
**Description**
|
||||
Increment the count for the key.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void add(TIterator first, TIterator last)
|
||||
```
|
||||
**Description**
|
||||
Increment the counts for the keys from an iterator range.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
void operator ()(key_type key)
|
||||
```
|
||||
**Description**
|
||||
Increment the count for the key.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void operator ()(TIterator first, TIterator last)
|
||||
```
|
||||
**Description**
|
||||
Increment the counts for the keys from an iterator range.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
value_type operator [](key_type key) const
|
||||
```
|
||||
**Description**
|
||||
Get the count for a key.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
const_iterator begin() const
|
||||
const_iterator cbegin() const
|
||||
```
|
||||
**Description**
|
||||
Get the iterator to the first histogram entry.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
const_iterator end() const
|
||||
const_iterator cend() const
|
||||
```
|
||||
**Description**
|
||||
Get the iterator to the last + 1 histogram entry.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
void clear()
|
||||
```
|
||||
**Description**
|
||||
Clear the counts to zero.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR size_t size() const
|
||||
```
|
||||
Get the number of items in the histogram.
|
||||
**Description**
|
||||
Always equal to max_size().
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR size_t max_size() const
|
||||
```
|
||||
**Description**
|
||||
Get the number of items in the histogram.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
size_t count() const
|
||||
```
|
||||
**Description**
|
||||
Get the total of all the counts.
|
||||
|
||||
## sparse_histogram
|
||||
|
||||
```cpp
|
||||
template <typename TKey, typename TCount, size_t Max_Keys>
|
||||
class sparse_histogram
|
||||
```
|
||||
**Description**
|
||||
A histogram where the keys are sparse or non-integral types.
|
||||
|
||||
## Types
|
||||
`const_iterator` The iterator used to traverse the histogram data.
|
||||
`key_type` The index type for the histogram.
|
||||
`count_type` The type used for the histogram counter.
|
||||
`value_type` The type returned from the histogram. A pair containing the key and count.
|
||||
|
||||
## Constants
|
||||
`Max_Size` The maximum number of elements in the histogram.
|
||||
|
||||
## Member functions
|
||||
```cpp
|
||||
sparse_histogram()
|
||||
```
|
||||
**Description**
|
||||
Default constructor.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
sparse_histogram(TIterator first, TIterator last)
|
||||
```
|
||||
**Description**
|
||||
Construct from an iterator range.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
sparse_histogram(const sparse_histogram& other)
|
||||
```
|
||||
**Description**
|
||||
Copy constructor.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
sparse_histogram(sparse_histogram&& other)
|
||||
```
|
||||
**Description**
|
||||
Move constructor.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
sparse_histogram& operator =(const sparse_histogram& rhs)
|
||||
```
|
||||
**Description**
|
||||
Assignment operator.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
sparse_histogram& operator =(sparse_histogram&& rhs)
|
||||
```
|
||||
**Description**
|
||||
Move assignment operator.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
void add(key_type key)
|
||||
```
|
||||
**Description**
|
||||
Increment the count for the key.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void add(TIterator first, TIterator last)
|
||||
```
|
||||
**Description**
|
||||
Increment the counts for the keys from an iterator range.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
void operator ()(key_type key)
|
||||
```
|
||||
**Description**
|
||||
Increment the count for the key.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void operator ()(TIterator first, TIterator last)
|
||||
```
|
||||
**Description**
|
||||
Increment the counts for the keys from an iterator range.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
const value_type& operator [](key_type key) const
|
||||
```
|
||||
**Description**
|
||||
Get the count for a key.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
const_iterator begin() const
|
||||
const_iterator cbegin() const
|
||||
```
|
||||
**Description**
|
||||
Get the iterator to the first histogram entry.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
const_iterator end() const
|
||||
const_iterator cend() const
|
||||
```
|
||||
**Description**
|
||||
Get the iterator to the last + 1 histogram entry.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
void clear()
|
||||
```
|
||||
**Description**
|
||||
Clear the counts to zero.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR size_t size() const
|
||||
```
|
||||
**Description**
|
||||
Get the number of items in the histogram.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR size_t max_size() const
|
||||
```
|
||||
**Description**
|
||||
Get the number of items in the histogram.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
size_t count() const
|
||||
```
|
||||
**Description**
|
||||
Get the total of all the counts.
|
||||
@ -1,67 +0,0 @@
|
||||
Covariance
|
||||
20.9.0
|
||||
template <bool Correlation_Type, typename TInput, typename TCalc = TInput>
|
||||
class correlation : public etl::binary_function<TInput, TInput, void>
|
||||
|
||||
Covariance_Type Population or Sample.
|
||||
TInput The input data type.
|
||||
TCalc The type to use for internal calculations. By default, equal to TInput.
|
||||
____________________________________________________________________________________________________
|
||||
covariance_type
|
||||
etl::covariance_type::Sample
|
||||
etl::covariance_type::Population
|
||||
____________________________________________________________________________________________________
|
||||
covariance
|
||||
covariance()
|
||||
Default constructor.
|
||||
|
||||
template <typename TIterator>
|
||||
covariance(TIterator first1, TIterator last1, TIterator first2)
|
||||
Construct from two iterator ranges.
|
||||
____________________________________________________________________________________________________
|
||||
void add(TInput value1, TInput value2)
|
||||
Add a pair of values.
|
||||
|
||||
template <typename TIterator>
|
||||
void add(TIterator first1, TIterator last1, TIterator first2)
|
||||
Add a range of values.
|
||||
____________________________________________________________________________________________________
|
||||
void operator()(TInput value1, TInput value2)
|
||||
Add a pair of values.
|
||||
|
||||
template <typename TIterator>
|
||||
void operator()(TIterator first1, TIterator last1, TIterator first2)
|
||||
Add a range of values.
|
||||
____________________________________________________________________________________________________
|
||||
double get_covariance() const
|
||||
Returns the calculated covariance for the data.
|
||||
____________________________________________________________________________________________________
|
||||
operator double() const
|
||||
Returns the calculated covariance for the data.
|
||||
____________________________________________________________________________________________________
|
||||
size_t count() const
|
||||
Get the total number added entries.
|
||||
____________________________________________________________________________________________________
|
||||
void clear()
|
||||
Clear the covariance.
|
||||
____________________________________________________________________________________________________
|
||||
Example
|
||||
|
||||
std::array<char, 10> input_c
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
||||
};
|
||||
|
||||
std::array<char, 10> input_c_inv
|
||||
{
|
||||
0, -1, -2, -3, -4, -5, -6, -7, -8, -9
|
||||
};
|
||||
|
||||
etl::covariance<etl::covariance_type::Population, char, int32_t> covariance(input_c.begin(),
|
||||
input_c.end(),
|
||||
input_c_inv.begin());
|
||||
|
||||
double covariance_result;
|
||||
|
||||
covariance_result = covariance; // covariance_result == -8.25
|
||||
|
||||
@ -1,157 +0,0 @@
|
||||
Histogram
|
||||
20.9.0
|
||||
____________________________________________________________________________________________________
|
||||
histogram
|
||||
|
||||
Types
|
||||
const_iterator The iterator used to traverse the histogram data.
|
||||
key_type The index type for the histogram.
|
||||
count_type The type used for the histogram counter.
|
||||
value_type The type returned from the histogram.
|
||||
____________________________________________________________________________________________________
|
||||
Constants
|
||||
Max_Size The maximum number of elements in the histogram.
|
||||
____________________________________________________________________________________________________
|
||||
template <typename TKey, typename TCount, size_t Max_Keys>
|
||||
class histogram
|
||||
A histogram where the start index of the keys is defined in the constructor.
|
||||
|
||||
histogram()
|
||||
Default constructor.
|
||||
|
||||
template <typename TIterator>
|
||||
histogram(TIterator first, TIterator last)
|
||||
Construct from an iterator range.
|
||||
____________________________________________________________________________________________________
|
||||
template <typename TKey, typename TCount, size_t Max_Keys, size_t Start_Index>
|
||||
class histogram
|
||||
A histogram where the start index of the keys is defined as a template parameter.
|
||||
|
||||
histogram()
|
||||
Default constructor.
|
||||
|
||||
template <typename TIterator>
|
||||
histogram(TIterator first, TIterator last)
|
||||
Construct from an iterator range.
|
||||
____________________________________________________________________________________________________
|
||||
histogram(const histogram& other)
|
||||
Copy constructor.
|
||||
|
||||
histogram(histogram&& other)
|
||||
Move constructor.
|
||||
|
||||
histogram& operator =(const histogram& rhs)
|
||||
Assignment operator.
|
||||
|
||||
histogram& operator =(histogram&& rhs)
|
||||
Move assignment operator.
|
||||
____________________________________________________________________________________________________
|
||||
void add(key_type key)
|
||||
Increment the count for the key.
|
||||
|
||||
template <typename TIterator>
|
||||
void add(TIterator first, TIterator last)
|
||||
Increment the counts for the keys from an iterator range.
|
||||
____________________________________________________________________________________________________
|
||||
void operator ()(key_type key)
|
||||
Increment the count for the key.
|
||||
|
||||
template <typename TIterator>
|
||||
void operator ()(TIterator first, TIterator last)
|
||||
Increment the counts for the keys from an iterator range.
|
||||
____________________________________________________________________________________________________
|
||||
value_type operator [](key_type key) const
|
||||
Get the count for a key.
|
||||
____________________________________________________________________________________________________
|
||||
const_iterator begin() const
|
||||
const_iterator cbegin() const
|
||||
Get the iterator to the first histogram entry.
|
||||
____________________________________________________________________________________________________
|
||||
const_iterator end() const
|
||||
const_iterator cend() const
|
||||
Get the iterator to the last + 1 histogram entry.
|
||||
____________________________________________________________________________________________________
|
||||
void clear()
|
||||
Clear the counts to zero.
|
||||
____________________________________________________________________________________________________
|
||||
ETL_CONSTEXPR size_t size() const
|
||||
Get the number of items in the histogram.
|
||||
Always equal to max_size().
|
||||
____________________________________________________________________________________________________
|
||||
ETL_CONSTEXPR size_t max_size() const
|
||||
Get the number of items in the histogram.
|
||||
____________________________________________________________________________________________________
|
||||
size_t count() const
|
||||
Get the total of all the counts.
|
||||
____________________________________________________________________________________________________
|
||||
sparse_histogram
|
||||
|
||||
Types
|
||||
const_iterator The iterator used to traverse the histogram data.
|
||||
key_type The index type for the histogram.
|
||||
count_type The type used for the histogram counter.
|
||||
value_type The type returned from the histogram. A pair containing the key and count.
|
||||
____________________________________________________________________________________________________
|
||||
Constants
|
||||
Max_Size The maximum number of elements in the histogram.
|
||||
____________________________________________________________________________________________________
|
||||
template <typename TKey, typename TCount, size_t Max_Keys>
|
||||
class sparse_histogram
|
||||
A histogram where the keys are sparse or non-integral types.
|
||||
|
||||
sparse_histogram()
|
||||
Default constructor.
|
||||
|
||||
template <typename TIterator>
|
||||
sparse_histogram(TIterator first, TIterator last)
|
||||
Construct from an iterator range.
|
||||
|
||||
sparse_histogram(const sparse_histogram& other)
|
||||
Copy constructor.
|
||||
|
||||
sparse_histogram(sparse_histogram&& other)
|
||||
Move constructor.
|
||||
|
||||
sparse_histogram& operator =(const sparse_histogram& rhs)
|
||||
Assignment operator.
|
||||
|
||||
sparse_histogram& operator =(sparse_histogram&& rhs)
|
||||
Move assignment operator.
|
||||
____________________________________________________________________________________________________
|
||||
void add(key_type key)
|
||||
Increment the count for the key.
|
||||
|
||||
template <typename TIterator>
|
||||
void add(TIterator first, TIterator last)
|
||||
Increment the counts for the keys from an iterator range.
|
||||
____________________________________________________________________________________________________
|
||||
void operator ()(key_type key)
|
||||
Increment the count for the key.
|
||||
|
||||
template <typename TIterator>
|
||||
void operator ()(TIterator first, TIterator last)
|
||||
Increment the counts for the keys from an iterator range.
|
||||
____________________________________________________________________________________________________
|
||||
const value_type& operator [](key_type key) const
|
||||
Get the count for a key.
|
||||
____________________________________________________________________________________________________
|
||||
const_iterator begin() const
|
||||
const_iterator cbegin() const
|
||||
Get the iterator to the first histogram entry.
|
||||
____________________________________________________________________________________________________
|
||||
const_iterator end() const
|
||||
const_iterator cend() const
|
||||
Get the iterator to the last + 1 histogram entry.
|
||||
____________________________________________________________________________________________________
|
||||
void clear()
|
||||
Clear the counts to zero.
|
||||
____________________________________________________________________________________________________
|
||||
ETL_CONSTEXPR size_t size() const
|
||||
Get the number of items in the histogram.
|
||||
____________________________________________________________________________________________________
|
||||
ETL_CONSTEXPR size_t max_size() const
|
||||
Get the number of items in the histogram.
|
||||
____________________________________________________________________________________________________
|
||||
size_t count() const
|
||||
Get the total of all the counts.
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
absolute
|
||||
A template functions that return the absolute value.
|
||||
____________________________________________________________________________________________________
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR T absolute(T value)
|
||||
Returns the absolute of value.
|
||||
|
||||
If T is int8_t:-
|
||||
0 => 0
|
||||
127 => 127
|
||||
-127 => 127
|
||||
____________________________________________________________________________________________________
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR etl::make_unsigned_t<T> absolute_unsigned(T value)
|
||||
Returns the absolute of value, cast to the unsigned version of type T.
|
||||
|
||||
If T is int8_t:-
|
||||
|
||||
Return type is etl::make_unsigned_t<T>
|
||||
0 => 0
|
||||
127 => 127
|
||||
-127 => 127
|
||||
-128 => 128
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
|
||||
Combinations / Permutations
|
||||
Templates to provide combinations and permutations constants.
|
||||
____________________________________________________________________________________________________
|
||||
Combinations
|
||||
|
||||
template <size_t N, size_t K>
|
||||
struct combinations
|
||||
|
||||
Member const
|
||||
static ETL_CONSTEXPR size_t value = Number of combinations of K items from a total of N
|
||||
|
||||
If C++17 is supported.
|
||||
template <size_t N, size_t K>
|
||||
inline constexpr size_t combinations_v = combinations<N, K>::value;
|
||||
|
||||
____________________________________________________________________________________________________
|
||||
Permutations
|
||||
|
||||
template <size_t N, size_t K>
|
||||
struct permutations
|
||||
|
||||
Member const
|
||||
static ETL_CONSTEXPR size_t value = Number of permutations of K items from a total of N
|
||||
|
||||
If C++17 is supported.
|
||||
template <size_t N, size_t K>
|
||||
inline constexpr size_t permutations_v = permutations<N, K>::value;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user