22 lines
769 B
C++
22 lines
769 B
C++
#ifndef GAUSSPOLYCOE_H
|
|
#define GAUSSPOLYCOE_H
|
|
|
|
#include <vector>
|
|
|
|
class GaussPolyCoe {
|
|
public:
|
|
// 高斯消元法求解线性方程组 Ax = b
|
|
static std::vector<double> GaussianElimination(std::vector<std::vector<double>> A, std::vector<double> b);
|
|
|
|
// 多项式拟合:返回系数 [a0, a1, ..., an] 表示 y = a0 + a1*x + ... + an*x^n
|
|
static std::vector<double> PolynomialFit(const std::vector<double>& x, const std::vector<double>& y, int degree);
|
|
|
|
// 计算拟合曲线在x处的值
|
|
static double Predict(const std::vector<double>& coeffs, double x);
|
|
|
|
// 计算均方误差
|
|
static double MeanSquareError(const std::vector<double>& x, const std::vector<double>& y, const std::vector<double>& coeffs);
|
|
};
|
|
|
|
#endif // GAUSSPOLYCOE_H
|