use crate::Akima;
use crate::AkimaPeriodic;
use crate::InterpType;
use crate::tests::XYTable;
use crate::tests::test_interp;
use crate::tests::test_interp_extra;
#[test]
fn test_type_fields() {
let _ = <Akima as InterpType<f64>>::name(&Akima);
let _ = <Akima as InterpType<f64>>::min_size(&Akima);
let _ = <AkimaPeriodic as InterpType<f64>>::name(&AkimaPeriodic);
let _ = <AkimaPeriodic as InterpType<f64>>::min_size(&AkimaPeriodic);
}
#[test]
fn gsl_test_akima() {
let xa = [0.0, 1.0, 2.0, 3.0, 4.0];
let ya = [0.0, 1.0, 2.0, 3.0, 4.0];
let xtest = [0.0, 0.5, 1.0, 2.0];
let ytest = [0.0, 0.5, 1.0, 2.0];
let dytest = [1.0, 1.0, 1.0, 1.0];
let iytest = [0.0, 0.125, 0.5, 2.0];
let data_table = XYTable { x: &xa, y: &ya };
let test_e_table = XYTable {
x: &xtest,
y: &ytest,
};
let test_d_table = XYTable {
x: &xtest,
y: &dytest,
};
let test_i_table = XYTable {
x: &xtest,
y: &iytest,
};
let interp = Akima.build(&xa, &ya).unwrap();
test_interp(data_table, test_e_table, test_d_table, test_i_table, interp);
}
#[test]
fn extra_test_akima() {
let xa = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0];
#[rustfmt::skip]
let ya = [
1.000000000000000, 1.040000000000000, 1.160000000000000,
1.360000000000000, 1.640000000000000, 2.000000000000000,
];
#[rustfmt::skip]
let xtest = [
0.000000000000000, 0.052631578947368, 0.105263157894737, 0.157894736842105, 0.210526315789474,
0.263157894736842, 0.315789473684211, 0.368421052631579, 0.421052631578947, 0.473684210526316,
0.526315789473684, 0.578947368421053, 0.631578947368421, 0.684210526315789, 0.736842105263158,
0.789473684210526, 0.842105263157894, 0.894736842105263, 0.947368421052631, 1.000000000000000,
];
#[rustfmt::skip]
let ytest = [
1.000000000000000, 1.002770083102493, 1.011080332409972, 1.024930747922438, 1.044321329639889,
1.069252077562327, 1.099722991689751, 1.135734072022161, 1.177285318559557, 1.224376731301939,
1.277008310249307, 1.335180055401662, 1.398891966759003, 1.468144044321329, 1.542936288088642,
1.623268698060942, 1.709141274238227, 1.800554016620498, 1.897506925207756, 1.999999999999999,
];
#[rustfmt::skip]
let dytest = [
0.000000000000000, 0.105263157894737, 0.210526315789474, 0.315789473684211, 0.421052631578948,
0.526315789473685, 0.631578947368422, 0.736842105263158, 0.842105263157894, 0.947368421052630,
1.052631578947367, 1.157894736842104, 1.263157894736842, 1.368421052631580, 1.473684210526317,
1.578947368421054, 1.684210526315789, 1.789473684210525, 1.894736842105262, 1.999999999999999,
];
let d2ytest = vec![2.0; xtest.len()];
#[rustfmt::skip]
let iytest = [
0.000000000000000, 0.052680176896535, 0.105651941488069, 0.159206881469602, 0.213636584536133,
0.269232638382660, 0.326286630704184, 0.385090149195704, 0.445934781552218, 0.509112115468727,
0.574913738640229, 0.643631238761724, 0.715556203528211, 0.790980220634689, 0.870194877776158,
0.953491762647616, 1.041162462944063, 1.133498566360499, 1.230791660591922, 1.333333333333333,
];
let data_table = XYTable { x: &xa, y: &ya };
let test_e_table = XYTable {
x: &xtest,
y: &ytest,
};
let test_d_table = XYTable {
x: &xtest,
y: &dytest,
};
let test_d2_table = XYTable {
x: &xtest,
y: &d2ytest,
};
let test_i_table = XYTable {
x: &xtest,
y: &iytest,
};
let interp = Akima.build(&xa, &ya).unwrap();
test_interp_extra(
data_table,
test_e_table,
test_d_table,
test_d2_table,
test_i_table,
interp,
);
}
#[test]
fn extra_test_akima_periodic() {
let xa = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0];
#[rustfmt::skip]
let ya = [
1.000000000000000, 0.309016994374947, -0.809016994374947,
-0.809016994374948, 0.309016994374947, 1.000000000000000,
];
#[rustfmt::skip]
let xtest = [
0.000000000000000, 0.052631578947368, 0.105263157894737, 0.157894736842105, 0.210526315789474,
0.263157894736842, 0.315789473684211, 0.368421052631579, 0.421052631578947, 0.473684210526316,
0.526315789473684, 0.578947368421053, 0.631578947368421, 0.684210526315789, 0.736842105263158,
0.789473684210526, 0.842105263157894, 0.894736842105263, 0.947368421052631, 1.000000000000000,
];
#[rustfmt::skip]
let ytest = [
1.000000000000000, 0.928934657017679, 0.748900534188608, 0.509640490689629, 0.258383653944135,
-0.036897104662222, -0.362274649293334, -0.663076287136839, -0.885212500770372, -0.997264716057761,
-0.997264716057761, -0.885212500770372, -0.663076287136839, -0.362274649293335, -0.036897104662223,
0.258383653944133, 0.509640490689627, 0.748900534188607, 0.928934657017678, 1.000000000000000,
];
#[rustfmt::skip]
let dytest = [
0.000000000000004, -2.542963979268214, -4.140813634176468, -4.793548964724756, -4.978154558473962,
-6.069384074661775, -6.121832427414685, -5.135499616732693, -3.193488135690584, -1.064496045230197,
1.064496045230191, 3.193488135690583, 5.135499616732687, 6.121832427414679, 6.069384074661773,
4.978154558473970, 4.793548964724757, 4.140813634176478, 2.542963979268236, 0.000000000000032,
];
#[rustfmt::skip]
let d2ytest = [
-57.294901687515825, -39.337729524676483, -21.380557361837141, -3.423385198997792, -30.601781860200020,
-10.864939754936870, 8.871902350326280, 28.608744455589431, 40.450849718747342, 40.450849718747371,
40.450849718747392, 40.450849718747421, 28.608744455589434, 8.871902350326341, -10.864939754936756,
-30.601781860199843, -3.423385198997668, -21.380557361836978, -39.337729524676291, -57.294901687515598,
];
#[rustfmt::skip]
let iytest = [
0.000000000000000, 0.051348456805005, 0.095870862495778, 0.129141040742931, 0.149342034559610,
0.155422527665410, 0.144930115015784, 0.117719510315017, 0.076519868071256, 0.026489536859606,
-0.026489536859606, -0.076519868071256, -0.117719510315017, -0.144930115015784, -0.155422527665410,
-0.149342034559610, -0.129141040742931, -0.095870862495778, -0.051348456805006, -0.000000000000000,
];
let data_table = XYTable { x: &xa, y: &ya };
let test_e_table = XYTable {
x: &xtest,
y: &ytest,
};
let test_d_table = XYTable {
x: &xtest,
y: &dytest,
};
let test_d2_table = XYTable {
x: &xtest,
y: &d2ytest,
};
let test_i_table = XYTable {
x: &xtest,
y: &iytest,
};
let interp = AkimaPeriodic.build(&xa, &ya).unwrap();
test_interp_extra(
data_table,
test_e_table,
test_d_table,
test_d2_table,
test_i_table,
interp,
);
}