diff --git a/docs/maths/_index.md b/docs/maths/_index.md new file mode 100644 index 00000000..97c2fca9 --- /dev/null +++ b/docs/maths/_index.md @@ -0,0 +1,5 @@ +--- +title: "Maths" +weight: 100 +--- + diff --git a/docs/maths/absolute.md b/docs/maths/absolute.md new file mode 100644 index 00000000..1c726cf5 --- /dev/null +++ b/docs/maths/absolute.md @@ -0,0 +1,37 @@ +--- +title: "absolute" +--- + +A template functions that return the absolute value. + +```cpp +template +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::min`. + +--- + +```cpp +template +ETL_CONSTEXPR etl::make_unsigned_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` +`0` => `0` +`127` => `127` +`-127` => `127` +`-128` => `128` diff --git a/docs/raw/maths/Checksums & hashes.txt b/docs/maths/checksums-hashes.md similarity index 90% rename from docs/raw/maths/Checksums & hashes.txt rename to docs/maths/checksums-hashes.md index e9d8a896..b0fecec2 100644 --- a/docs/raw/maths/Checksums & hashes.txt +++ b/docs/maths/checksums-hashes.md @@ -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 = 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 = 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 = 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 = 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 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); } }; - +``` diff --git a/docs/maths/comb-perm.md b/docs/maths/comb-perm.md new file mode 100644 index 00000000..9b4c3ec0 --- /dev/null +++ b/docs/maths/comb-perm.md @@ -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 +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 +inline constexpr size_t combinations_v = combinations::value; +``` + +## Permutations + +See [Permutations](https://en.wikipedia.org/wiki/Permutation) + +```cpp +template +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 +inline constexpr size_t permutations_v = permutations::value; +``` diff --git a/docs/raw/maths/Constants.txt b/docs/maths/constants.md similarity index 53% rename from docs/raw/maths/Constants.txt rename to docs/maths/constants.md index 2386140e..76d46bd5 100644 --- a/docs/raw/maths/Constants.txt +++ b/docs/maths/constants.md @@ -1,135 +1,190 @@ -Constants +--- +title: "Constants" +--- + A set of compile time constants. -____________________________________________________________________________________________________ -log.h -log +## log +```cpp template 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 inline constexpr size_t log_v = log::value; -____________________________________________________________________________________________________ -log2 +``` + +## log2 +```cpp template 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 inline constexpr size_t log2_v = log2::value; +`` -____________________________________________________________________________________________________ -log10 +## log10 +```cpp template 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 inline constexpr size_t log10_v = log10::value; +``` -____________________________________________________________________________________________________ -power.h -power +## power +```cpp template 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 inline constexpr size_t power_v = power::value; +``` -____________________________________________________________________________________________________ -power_of_2_round_up +## power_of_2_round_up +```cpp template 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 inline constexpr size_t power_of_2_round_up_v = power_of_2_round_up::value; -____________________________________________________________________________________________________ -power_of_2_round_down +``` + +## power_of_2_round_down +```cpp template 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 inline constexpr size_t power_of_2_round_down_v = power_of_2_round_down::value; +``` -____________________________________________________________________________________________________ -is_power_of_2 +## is_power_of_2 +```cpp template 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 inline constexpr size_t is_power_of_2_v = is_power_of_2::value; +``` -____________________________________________________________________________________________________ -sqrt.h -sqrt +## sqrt +```cpp template 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 inline constexpr size_t sqrt_v = sqrt::value; +``` -____________________________________________________________________________________________________ -factorial.h -factorial +## factorial +```cpp template 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 inline constexpr size_t factorial_v = factorial::value; +``` -____________________________________________________________________________________________________ -fibbonacci.h -fibbonacci +## fibbonacci +```cpp template 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 inline constexpr size_t fibbonacci_v = fibbonacci::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; - +``` diff --git a/docs/raw/maths/Correlation.txt b/docs/maths/correlation.md similarity index 56% rename from docs/raw/maths/Correlation.txt rename to docs/maths/correlation.md index bf0c1d14..4b47f177 100644 --- a/docs/raw/maths/Correlation.txt +++ b/docs/maths/correlation.md @@ -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 class correlation : public etl::binary_function +``` +`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 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 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 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 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 - +``` diff --git a/docs/maths/covariance.md b/docs/maths/covariance.md new file mode 100644 index 00000000..9151e66d --- /dev/null +++ b/docs/maths/covariance.md @@ -0,0 +1,121 @@ +--- +title: "Covariance" +--- + +{{< callout type="info">}} + Header: `covariance.h` + Since: `20.9.0` +{{< /callout >}} + +```cpp +template +class covariance : public etl::binary_function +``` + +`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 +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 +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 +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 input_c +{ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 +}; + +std::array input_c_inv +{ + 0, -1, -2, -3, -4, -5, -6, -7, -8, -9 +}; + +etl::covariance covariance(input_c.begin(), + input_c.end(), + input_c_inv.begin()); + +double covariance_result; + +covariance_result = covariance; // covariance_result == -8.25 +``` diff --git a/docs/raw/maths/Gamma.txt b/docs/maths/gamma.md similarity index 61% rename from docs/raw/maths/Gamma.txt rename to docs/maths/gamma.md index 4f5c99ba..c014646b 100644 --- a/docs/raw/maths/Gamma.txt +++ b/docs/maths/gamma.md @@ -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 class gamma_encode : public etl::unary_function - +``` +```cpp template class gamma_decode : public etl::unary_function +``` -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 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 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 - +``` diff --git a/docs/maths/histogram.md b/docs/maths/histogram.md new file mode 100644 index 00000000..63863bfa --- /dev/null +++ b/docs/maths/histogram.md @@ -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 +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 +histogram(TIterator first, TIterator last) +``` +**Description** +Construct from an iterator range. + +--- + +## histogram + +```cpp +template +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 +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 +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 +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 +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 +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 +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 +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. diff --git a/docs/raw/maths/Covariance.txt b/docs/raw/maths/Covariance.txt deleted file mode 100644 index 69b56c26..00000000 --- a/docs/raw/maths/Covariance.txt +++ /dev/null @@ -1,67 +0,0 @@ -Covariance -20.9.0 -template -class correlation : public etl::binary_function - -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 -covariance(TIterator first1, TIterator last1, TIterator first2) -Construct from two iterator ranges. -____________________________________________________________________________________________________ -void add(TInput value1, TInput value2) -Add a pair of values. - -template -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 -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 input_c -{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 -}; - -std::array input_c_inv -{ - 0, -1, -2, -3, -4, -5, -6, -7, -8, -9 -}; - -etl::covariance covariance(input_c.begin(), - input_c.end(), - input_c_inv.begin()); - -double covariance_result; - -covariance_result = covariance; // covariance_result == -8.25 - diff --git a/docs/raw/maths/Histogram.txt b/docs/raw/maths/Histogram.txt deleted file mode 100644 index 6f669151..00000000 --- a/docs/raw/maths/Histogram.txt +++ /dev/null @@ -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 -class histogram -A histogram where the start index of the keys is defined in the constructor. - -histogram() -Default constructor. - -template -histogram(TIterator first, TIterator last) -Construct from an iterator range. -____________________________________________________________________________________________________ -template -class histogram -A histogram where the start index of the keys is defined as a template parameter. - -histogram() -Default constructor. - -template -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 -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 -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 -class sparse_histogram -A histogram where the keys are sparse or non-integral types. - -sparse_histogram() -Default constructor. - -template -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 -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 -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. - diff --git a/docs/raw/maths/absolute.txt b/docs/raw/maths/absolute.txt deleted file mode 100644 index 2d7381fc..00000000 --- a/docs/raw/maths/absolute.txt +++ /dev/null @@ -1,24 +0,0 @@ -absolute -A template functions that return the absolute value. -____________________________________________________________________________________________________ -template -ETL_CONSTEXPR T absolute(T value) -Returns the absolute of value. - -If T is int8_t:- -0 => 0 -127 => 127 --127 => 127 -____________________________________________________________________________________________________ -template -ETL_CONSTEXPR etl::make_unsigned_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 -0 => 0 -127 => 127 --127 => 127 --128 => 128 - diff --git a/docs/raw/maths/comb-perm.txt b/docs/raw/maths/comb-perm.txt deleted file mode 100644 index 3dfdfcf8..00000000 --- a/docs/raw/maths/comb-perm.txt +++ /dev/null @@ -1,30 +0,0 @@ - -Combinations / Permutations -Templates to provide combinations and permutations constants. -____________________________________________________________________________________________________ -Combinations - -template -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 -inline constexpr size_t combinations_v = combinations::value; - -____________________________________________________________________________________________________ -Permutations - -template -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 -inline constexpr size_t permutations_v = permutations::value; - -