74 lines
1.4 KiB
C++
74 lines
1.4 KiB
C++
#pragma once
|
|
/**
|
|
* @file PolyfitStat.h
|
|
* @brief
|
|
* @author Cat (null.null.null@qq.com)
|
|
* @version 0.1
|
|
* @date 2021-04-07
|
|
*
|
|
* Company: Baosight Co. Ltd.
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
|
*
|
|
*/
|
|
#include <boost/optional.hpp>
|
|
#include <log4cplus/LOG.h>
|
|
#include <mix_cc/db2.h>
|
|
|
|
class PolyfitStat {
|
|
private:
|
|
/* data */
|
|
mix_cc::db2::DBCom db_com_;
|
|
long max_fit_count_;
|
|
|
|
std::string rule_id_;
|
|
|
|
std::unique_ptr<> logger_;
|
|
|
|
std::vector<std::vector<double>> tsample_analysisd_data_;
|
|
|
|
struct SamplePolyfit3Dim {
|
|
bool calculated_ = false;
|
|
uint64_t size;
|
|
std::vector<double> coeff_;
|
|
std::vector<double> x1_;
|
|
std::vector<double> x2_;
|
|
std::vector<double> y_;
|
|
};
|
|
|
|
struct SamplePolyfit2Dim {
|
|
bool calculated_ = false;
|
|
uint64_t size;
|
|
std::vector<double> coeff_;
|
|
std::vector<double> x_;
|
|
std::vector<double> y_;
|
|
};
|
|
|
|
SamplePolyfit2Dim sample_2d_; // 2d data
|
|
|
|
SamplePolyfit3Dim sample_3d_; // 3d data
|
|
|
|
int dims_ = 2; // 2 is 2 dim, 3 is 3dim
|
|
|
|
int power_index_ = 3;
|
|
|
|
public:
|
|
PolyfitStat(std::string ruleId, int max_fit_count);
|
|
~PolyfitStat();
|
|
|
|
int set_workingset_dim(int dim);
|
|
int filter_data();
|
|
|
|
int save_data(double x, double y, double z);
|
|
int save_data(double x, double y);
|
|
|
|
int load();
|
|
|
|
int fit();
|
|
|
|
boost::optional<double> get_y(double x);
|
|
|
|
boost::optional<double> get_y(double x, double y);
|
|
|
|
std::string stringify_polyfit();
|
|
};
|