rust
This commit is contained in:
@ -39,7 +39,7 @@ pub fn interpolate_spline<T: Copy + Into<f64>,>(x_t: Vec<T>, y_t: Vec<T>, step:
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub fn interpolate_spline_at_points<T: Copy + Into<f64>>(x_t: Vec<T>, y_t: Vec<T>, x_target: Vec<f64>) -> Result<Vec<(f64)>, Box<dyn Error>> {
|
||||
pub fn interpolate_spline_at_points<T: Copy + Into<f64>>(x_t: Vec<T>, y_t: Vec<T>, x_target: Vec<f64>) -> Result<Vec<f64>, Box<dyn Error>> {
|
||||
let x: Vec<f64> = x_t.iter().map(|&x| x.into()).collect();
|
||||
let y: Vec<f64> = y_t.iter().map(|&y| y.into()).collect();
|
||||
|
||||
@ -138,7 +138,7 @@ pub fn compute_weave_coeff(x_data:Vec<f64>,y_data:Vec<f64>)->Vec<f64>{
|
||||
|
||||
// 构建设计矩阵 X 和观测向量 y
|
||||
let mut x_matrix = DMatrix::zeros(n, 4); // 三阶多项式有 4 个系数
|
||||
let mut y_vector = DVector::from_vec(y_data.clone());
|
||||
let y_vector = DVector::from_vec(y_data.clone());
|
||||
|
||||
for (i, &x) in x_data.iter().enumerate() {
|
||||
x_matrix[(i, 0)] = 1.0; // 常数项
|
||||
|
||||
Reference in New Issue
Block a user