#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 #include #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& X, const vector& Y); ~LSM(); bool is_legal(); void reset(const vector& X, const vector& Y); private: void polyfit_init(); public: vector polyfit(int orders); vector> polyfit(); vector polyval(int orders); double polyval(double x, int orders); vector 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 pnn; array r2a; int order_best = 1; }; }; // namespace DAA