67 lines
1.2 KiB
C++
67 lines
1.2 KiB
C++
#pragma once
|
|
/**
|
|
* @file LSM.h
|
|
* @brief 相关性/拟合数据处理
|
|
* @author your name (you@domain.com)
|
|
* @version 0.1
|
|
* @date 2024-02-26
|
|
*
|
|
* Copyright: Baosight Co. Ltd.
|
|
* DO NOT COPY/USE WITHOUT PERMISSION
|
|
*
|
|
*/
|
|
#include <array>
|
|
#include <vector>
|
|
#include "STA.h"
|
|
#include "mlpack_header.h"
|
|
namespace DAA {
|
|
using std::array;
|
|
using std::vector;
|
|
using namespace mlpack;
|
|
using namespace arma;
|
|
const size_t max_orders = 5;
|
|
using DAA::limit_precision;
|
|
/**
|
|
* @brief 相关性/拟合 类
|
|
*/
|
|
class LSM {
|
|
public:
|
|
LSM(const vector<double>& X, const vector<double>& Y);
|
|
~LSM();
|
|
bool is_legal();
|
|
void reset(const vector<double>& X, const vector<double>& Y);
|
|
|
|
private:
|
|
void polyfit_init();
|
|
|
|
public:
|
|
vector<double> polyfit(int orders);
|
|
|
|
vector<vector<double>> polyfit();
|
|
|
|
vector<double> polyval(int orders);
|
|
|
|
double polyval(double x, int orders);
|
|
|
|
vector<double> get_r2a();
|
|
|
|
int get_order_best();
|
|
|
|
public:
|
|
double cor();
|
|
|
|
private:
|
|
bool is_init = false;
|
|
arma::vec vX;
|
|
arma::vec vY;
|
|
arma::vec pn;
|
|
arma::vec fY;
|
|
int order_now = 0;
|
|
double cor_coef = 2;
|
|
array<arma::vec, 5> pnn;
|
|
array<double, 5> r2a;
|
|
int order_best = 1;
|
|
};
|
|
|
|
}; // namespace DAA
|