INFO702 - TPs
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Histogramme Struct Reference

Public Member Functions

template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, unsigned char>
void init (R &&valeurs)
 

Public Attributes

std::array< double, 256 > h {}
 
std::array< double, 256 > H {}
 

Detailed Description

Definition at line 18 of file exemples-cpp20.cpp.

Member Function Documentation

◆ init()

template<std::ranges::input_range R>
requires std::same_as<std::ranges::range_value_t<R>, unsigned char>
void Histogramme::init ( R &&  valeurs)
inline

Definition at line 22 of file exemples-cpp20.cpp.

22 {
23 h.fill(0); H.fill(0);
24 std::size_t n = 0;
25 for (auto v : valeurs) { ++h[v]; ++n; }
26 if (n == 0) throw std::invalid_argument("sequence vide");
27 double cumul = 0;
28 for (std::size_t i = 0; i < h.size(); ++i) {
29 h[i] /= static_cast<double>(n);
30 H[i] = cumul += h[i];
31 }
32 H.back() = 1;
33 }

Member Data Documentation

◆ h

std::array<double, 256> Histogramme::h {}

Definition at line 19 of file exemples-cpp20.cpp.

19{}, H{};

◆ H

std::array<double, 256> Histogramme::H {}

Definition at line 19 of file exemples-cpp20.cpp.

19{}, H{};

The documentation for this struct was generated from the following file: