You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/interp1d/strategies/cubic_spline.rs
+21-9Lines changed: 21 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -469,20 +469,33 @@ where
469
469
470
470
// apply boundary conditions
471
471
match(boundary.specialize(), len){
472
-
(InternalBoundary::Periodic,_) => {
473
-
letfirst = data.index_axis(AX0,0);
474
-
letlast = data.index_axis(AX0,len - 1);
475
-
iffirst != last{
472
+
(InternalBoundary::Periodic,3) => {
473
+
lety0 = data.index_axis(AX0,0);
474
+
lety2 = data.index_axis(AX0,2);
475
+
ify0 != y2{
476
476
if data.ndim() == 1{
477
477
returnErr(BuilderError::ValueError(format!("for periodic boundary condition the first and last value must be equal. First: {:?}, last: {:?}", data.first().unwrap_or_else(||unreachable!()), data.last().unwrap_or_else(||unreachable!()))));
478
478
}else{
479
-
returnErr(BuilderError::ValueError(format!("for periodic boundary condition the first and last value must be equal. First: {first:?}, last: {last:?}")));
479
+
returnErr(BuilderError::ValueError(format!("for periodic boundary condition the first and last value must be equal. First: {y0:?}, last: {y2:?}")));
480
480
}
481
481
}
482
482
483
-
if len == 3{
484
-
todo!();
485
-
returnOk(());
483
+
let y1 = data.index_axis(AX0,1);
484
+
let slope0:Array<T, _D::Smaller> = (&y1 - &y0) / dx0;
485
+
let slope1:Array<T, _D::Smaller> = (&y2 - &y1) / dx1;
returnErr(BuilderError::ValueError(format!("for periodic boundary condition the first and last value must be equal. First: {:?}, last: {:?}", data.first().unwrap_or_else(||unreachable!()), data.last().unwrap_or_else(||unreachable!()))));
496
+
}else{
497
+
returnErr(BuilderError::ValueError(format!("for periodic boundary condition the first and last value must be equal. First: {y0:?}, last: {y_1:?}")));
498
+
}
486
499
}
487
500
488
501
// due to the preriodicity we need to solve one less equation
@@ -496,7 +509,6 @@ where
496
509
a_mid[0] = two *(dx_1 + dx0);
497
510
a_up[0] = dx_1;
498
511
499
-
let y0 = data.index_axis(AX0,0);
500
512
let y1 = data.index_axis(AX0,1);
501
513
let slope0:Array<T, _D::Smaller> = (&y1 - &y0) / dx0;
0 commit comments