WeightedLowess
A C++ library for LOWESS with various weighting schemes
Loading...
Searching...
No Matches
compute.hpp
Go to the documentation of this file.
1#ifndef WEIGHTEDLOWESS_COMPUTE_HPP
2#define WEIGHTEDLOWESS_COMPUTE_HPP
3
4#include <vector>
5
6#include "fit.hpp"
7#include "Options.hpp"
8
14namespace WeightedLowess {
15
35template<typename Data_>
36void compute(size_t num_points, const Data_* x, const PrecomputedWindows<Data_>& windows, const Data_* y, Data_* fitted, Data_* robust_weights, const Options<Data_>& opt) {
37 std::vector<Data_> rbuffer;
38 if (robust_weights == NULL) {
39 rbuffer.resize(num_points);
40 robust_weights = rbuffer.data();
41 }
42 internal::fit_trend(num_points, x, windows, y, fitted, robust_weights, opt);
43}
44
61template<typename Data_>
62void compute(size_t num_points, const Data_* x, const Data_* y, Data_* fitted, Data_* robust_weights, const Options<Data_>& opt) {
63 auto win = define_windows(num_points, x, opt);
64 compute(num_points, x, win, y, fitted, robust_weights, opt);
65}
66
71template<typename Data_>
72struct Results {
76 Results(size_t n) : fitted(n), robust_weights(n) {}
77
81 std::vector<Data_> fitted;
82
86 std::vector<Data_> robust_weights;
87};
88
104template<typename Data_>
105Results<Data_> compute(size_t num_points, const Data_* x, const Data_* y, const Options<Data_>& opt) {
106 Results<Data_> output(num_points);
107 compute(num_points, x, y, output.fitted.data(), output.robust_weights.data(), opt);
108 return output;
109}
110
111}
112
113#endif
Options for compute().
Namespace for LOWESS functions.
Definition compute.hpp:14
void compute(size_t num_points, const Data_ *x, const PrecomputedWindows< Data_ > &windows, const Data_ *y, Data_ *fitted, Data_ *robust_weights, const Options< Data_ > &opt)
Definition compute.hpp:36
PrecomputedWindows< Data_ > define_windows(size_t num_points, const Data_ *x, const Options< Data_ > &opt)
Definition window.hpp:263
Options for compute().
Definition Options.hpp:17
Precomputed windows for LOWESS smoothing.
Definition window.hpp:230
Store the smoothing results.
Definition compute.hpp:72
Results(size_t n)
Definition compute.hpp:76
std::vector< Data_ > fitted
Definition compute.hpp:81
std::vector< Data_ > robust_weights
Definition compute.hpp:86