Advanced Chunk Processing Library 0.2.0
A comprehensive C++ library for advanced data chunking strategies and processing operations
Loading...
Searching...
No Matches
WaveletChunking< T > Class Template Reference

#include <wavelet_chunking.hpp>

Public Member Functions

 WaveletChunking (size_t window_size, double threshold)
 
std::vector< std::vector< T > > chunk (const std::vector< T > &data)
 
void set_threshold (double new_threshold)
 
void set_window_size (size_t new_size)
 

Private Member Functions

bool detect_boundary (const std::vector< T > &window)
 

Private Attributes

double threshold_
 
size_t window_size_
 

Detailed Description

template<typename T>
class WaveletChunking< T >

Definition at line 2 of file wavelet_chunking.hpp.

Constructor & Destructor Documentation

◆ WaveletChunking()

template<typename T >
WaveletChunking< T >::WaveletChunking ( size_t  window_size,
double  threshold 
)
inline

Definition at line 4 of file wavelet_chunking.hpp.

5 : window_size_(window_size), threshold_(threshold) {
6 if (window_size == 0) {
7 throw std::invalid_argument("Window size cannot be zero");
8 }
9 }

Member Function Documentation

◆ chunk()

template<typename T >
std::vector< std::vector< T > > WaveletChunking< T >::chunk ( const std::vector< T > &  data)
inline

Definition at line 22 of file wavelet_chunking.hpp.

22 {
23 if (data.empty()) {
24 throw std::invalid_argument("Cannot chunk empty data");
25 }
26
27 std::vector<std::vector<T>> result;
28 std::vector<T> current_chunk;
29
30 for (size_t i = 0; i < data.size(); ++i) {
31 current_chunk.push_back(data[i]);
32
33 if (current_chunk.size() >= window_size_) {
34 // Perform wavelet analysis to detect boundaries
35 if (detect_boundary(current_chunk)) {
36 result.push_back(current_chunk);
37 current_chunk.clear();
38 }
39 }
40 }
41
42 if (!current_chunk.empty()) {
43 result.push_back(current_chunk);
44 }
45
46 return result;
47 }
bool detect_boundary(const std::vector< T > &window)

◆ detect_boundary()

template<typename T >
bool WaveletChunking< T >::detect_boundary ( const std::vector< T > &  window)
inlineprivate

Definition at line 53 of file wavelet_chunking.hpp.

53 {
54 if (window.size() < 2)
55 return false;
56
57 // Simple boundary detection based on value differences
58 double max_diff = 0.0;
59 for (size_t i = 1; i < window.size(); ++i) {
60 max_diff = std::max(max_diff, std::abs(static_cast<double>(window[i] - window[i - 1])));
61 }
62 return max_diff > threshold_;
63 }

◆ set_threshold()

template<typename T >
void WaveletChunking< T >::set_threshold ( double  new_threshold)
inline

Definition at line 18 of file wavelet_chunking.hpp.

18 {
19 threshold_ = new_threshold;
20 }

◆ set_window_size()

template<typename T >
void WaveletChunking< T >::set_window_size ( size_t  new_size)
inline

Definition at line 11 of file wavelet_chunking.hpp.

11 {
12 if (new_size == 0) {
13 throw std::invalid_argument("Window size cannot be zero");
14 }
15 window_size_ = new_size;
16 }

Member Data Documentation

◆ threshold_

template<typename T >
double WaveletChunking< T >::threshold_
private

Definition at line 51 of file wavelet_chunking.hpp.

◆ window_size_

template<typename T >
size_t WaveletChunking< T >::window_size_
private

Definition at line 50 of file wavelet_chunking.hpp.


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