Skip to content

Commit f597678

Browse files
committed
refactor: Rename Akima to Makima
Fixes #37 Signed-off-by: Sietze van Buuren <s.van.buuren@gmail.com>
1 parent a916c42 commit f597678

File tree

12 files changed

+412
-785
lines changed

12 files changed

+412
-785
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ support.
1111
|:--:|:--:|
1212
| *2D Linear interpolation* | *2D Monotonic cubic spline interpolation* |
1313

14-
| ![2D Akima spline interpolation](docs/images/akima_2D.png) | ![2D Natural spline interpolation](docs/images/natural_spline_2D.png) |
14+
| ![2D Modfied Akima spline interpolation](docs/images/makima_2D.png) | ![2D Natural spline interpolation](docs/images/natural_spline_2D.png) |
1515
|:--:|:--:|
1616
| *2D Akima spline interpolation* | *2D Natural spline interpolation* |
1717

@@ -24,7 +24,7 @@ interpolation in `N` dimensions.
2424
For cubic piecewise interpolation, the library features three types:
2525

2626
- Monotone cubic interpolation
27-
- Akima spline interpolation
27+
- Mdofied Akima spline interpolation
2828
- Natural cubic spline interpolation
2929

3030
All classes are templatized and support the STL's vector types.

cubinterpp/main.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import cubinterpp.cubinterpp_py as cubinterpp # cubinterpp_py is a pybind11 module
88

99

10-
def get_test_data(case='akima', start=1.0, end=5.0, size=8):
11-
""" Generates test input data for Akima Spline tests """
12-
if case == 'akima':
10+
def get_test_data(case='makima', start=1.0, end=5.0, size=8):
11+
""" Generates test input data for Modified Akima Spline tests """
12+
if case == 'makima':
1313
return np.array([1, 2, 3, 4.0, 5.0, 5.5, 7.0, 8.0, 9.0, 9.5, 10]), \
1414
np.array([0, 0, 0, 0.5, 0.4, 1.2, 1.2, 0.1, 0.0, 0.3, 0.6])
1515

@@ -41,7 +41,7 @@ def get_test_data_2d(case='standard'):
4141
f = np.array([[1.0, 2.0, 2.0],
4242
[2.0, 3.0, 3.0],
4343
[3.0, 3.0, 4.0]])
44-
case 'akima':
44+
case 'makima':
4545
x = np.array([1, 2, 3, 4.0, 5.0, 5.5, 7.0, 8.0, 9.0, 9.5, 10])
4646
y = np.array([1, 2, 3, 4.0, 5.0, 5.5, 7.0, 8.0, 9.0, 9.5, 10])
4747
f = np.array([[0, 0, 0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
@@ -79,16 +79,16 @@ def scipy_linear_interp(x, y, f, x_fine, y_fine):
7979
return interp2((x_grid, y_grid))
8080

8181

82-
def cubinterpp_interp2(interp_type='linear', data_case='akima', refinement=50):
82+
def cubinterpp_interp2(interp_type='linear', data_case='makima', refinement=50):
8383
""" Short hand for 2D interpolatino with cubinterpp """
8484
x, y, f = get_test_data_2d(case=data_case)
8585
match interp_type:
8686
case 'linear':
8787
interp2 = cubinterpp.LinearInterp2D(x, y, f)
8888
case 'monotonic':
8989
interp2 = cubinterpp.MonotonicSpline2D(x, y, f)
90-
case 'akima':
91-
interp2 = cubinterpp.AkimaSpline2D(x, y, f)
90+
case 'makima':
91+
interp2 = cubinterpp.MakimaSpline2D(x, y, f)
9292
case 'natural_spline':
9393
interp2 = cubinterpp.NaturalSpline2D(x, y, f)
9494
x_fine, y_fine = refine_grid(x, refinement), refine_grid(y, refinement)
@@ -103,7 +103,7 @@ def cubinterpp_interp2(interp_type='linear', data_case='akima', refinement=50):
103103
def main():
104104
""" Tets Cubic spline interpolation """
105105

106-
x, y = get_test_data(case='akima')
106+
x, y = get_test_data(case='makima')
107107
x_fine = refine_grid(x)
108108

109109
spline = cubinterpp.LinearInterp1D(x, y)
@@ -112,23 +112,23 @@ def main():
112112
spline = cubinterpp.NaturalSpline1D(x, y)
113113
y_fine_natural = spline.evaln(x_fine)
114114

115-
spline = cubinterpp.AkimaSpline1D(x, y)
116-
y_fine_akima = spline.evaln(x_fine)
115+
spline = cubinterpp.MakimaSpline1D(x, y)
116+
y_fine_makima = spline.evaln(x_fine)
117117

118118
spline = cubinterpp.MonotonicSpline1D(x, y)
119119
y_fine_monotonic = spline.evaln(x_fine)
120120

121121
mpg.figure(title='Test figure')
122122
mpg.plot(x_fine, y_fine_linear)
123123
mpg.plot(x_fine, y_fine_monotonic)
124-
mpg.plot(x_fine, y_fine_akima)
124+
mpg.plot(x_fine, y_fine_makima)
125125
mpg.plot(x_fine, y_fine_natural)
126126
mpg.plot(x, y, width=0, symbol='o', symbol_color='r', symbol_size=6)
127127
mpg.gca().grid = True
128128
mpg.legend(
129129
'Linear interpolation',
130130
'Monotonic cubic interpolation',
131-
'Akima spline',
131+
'Modified Akima spline',
132132
'Natural cubic spline',
133133
'data points'
134134
)
@@ -138,7 +138,7 @@ def main():
138138
yp = np.tile(y, x.size)
139139
zp = f.flatten()
140140

141-
for interp_type in ('linear', 'monotonic', 'akima', 'natural_spline'):
141+
for interp_type in ('linear', 'monotonic', 'makima', 'natural_spline'):
142142
x_fine, y_fine, z_fine = cubinterpp_interp2(
143143
interp_type=interp_type,
144144
data_case='three_bumps',

docs/images/comparison_1D.svg

Lines changed: 371 additions & 744 deletions
Loading

docs/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interpolation.
66
For cubic piecewise interpolation, the library features three types:
77

88
- Monotone cubic interpolation
9-
- Akima spline interpolation
9+
- Modified Akima spline interpolation
1010
- Natural cubic spline interpolation
1111

1212
Linear interpolation is supported for `N`-dimensional data, whereas cubic

include/cubic_splines_1d.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ class MonotonicSpline1D : public CubicInterpND<T, N>
2929

3030

3131
template <typename T, std::size_t N=1>
32-
class AkimaSpline1D : public CubicInterpND<T, N>
32+
class MakimaSpline1D : public CubicInterpND<T, N>
3333
{
3434
using Vector = std::vector<T>;
3535
public:
36-
AkimaSpline1D(const Vector &x, const Vector &f)
36+
MakimaSpline1D(const Vector &x, const Vector &f)
3737
: CubicInterpND<T, N>(x, f)
3838
{
3939
this->build(f);
4040
}
4141

42-
~AkimaSpline1D() {}
42+
~MakimaSpline1D() {}
4343

4444
Vector calc_slopes(const Vector &x, const Vector &f) const override {
45-
return akima_slopes<T>(x, f);
45+
return makima_slopes<T>(x, f);
4646
}
4747

4848
};

include/cubic_splines_2d.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,22 @@ MonotonicSpline2D(const Vector &_x, const Vector &_y, const VectorN &_f)
2929

3030

3131
template <typename T, std::size_t N=2>
32-
class AkimaSpline2D : public CubicInterpND<T, N>
32+
class MakimaSpline2D : public CubicInterpND<T, N>
3333
{
3434
using Vector = std::vector<T>;
3535
using Mdspan1D = std::mdspan<T, std::dextents<std::size_t, 1>, std::layout_stride>;
3636
using VectorN = cip::VectorN<T, N>;
3737
public:
38-
AkimaSpline2D(const Vector &_x, const Vector &_y, const VectorN &_f)
38+
MakimaSpline2D(const Vector &_x, const Vector &_y, const VectorN &_f)
3939
: CubicInterpND<T, N>(_f, _x, _y)
4040
{
4141
this->build(_f, _x, _y);
4242
}
43-
~AkimaSpline2D() {}
43+
~MakimaSpline2D() {}
4444

4545
Vector calc_slopes(const Vector &x, const Mdspan1D &f) const override
4646
{
47-
return akima_slopes<T>(x, f);
47+
return makima_slopes<T>(x, f);
4848
}
4949
};
5050

include/slopes.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ std::vector<T> monotonic_slopes(const Tx x, const Tf f)
5252

5353

5454
template <typename T, typename Tx, typename Tf>
55-
std::vector<T> akima_slopes(const Tx x, const Tf f)
55+
std::vector<T> makima_slopes(const Tx x, const Tf f)
5656
{
5757
/*
58-
Derivative values for Akima cubic Hermite interpolation
58+
Derivative values for Modified Akima cubic Hermite interpolation
5959
6060
Akima's derivative estimate at grid node x(i) requires the four finite
6161
differences corresponding to the five grid nodes x(i-2:i+2).

src/cubinterpp_py_module.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ PYBIND11_MODULE(cubinterpp_py, m) {
2323
.def("eval", &cip::MonotonicSpline1D<double>::eval, py::return_value_policy::reference_internal)
2424
.def("evaln", &cip::MonotonicSpline1D<double>::evaln, py::return_value_policy::reference_internal);
2525

26-
py::class_<cip::AkimaSpline1D<double>>(m, "AkimaSpline1D")
26+
py::class_<cip::MakimaSpline1D<double>>(m, "MakimaSpline1D")
2727
.def(py::init<DoubleVector, DoubleVector>())
28-
.def("eval", &cip::AkimaSpline1D<double>::eval, py::return_value_policy::reference_internal)
29-
.def("evaln", &cip::AkimaSpline1D<double>::evaln, py::return_value_policy::reference_internal);
28+
.def("eval", &cip::MakimaSpline1D<double>::eval, py::return_value_policy::reference_internal)
29+
.def("evaln", &cip::MakimaSpline1D<double>::evaln, py::return_value_policy::reference_internal);
3030

3131
py::class_<cip::NaturalSpline1D<double>>(m, "NaturalSpline1D")
3232
.def(py::init<DoubleVector, DoubleVector>())
@@ -52,9 +52,9 @@ PYBIND11_MODULE(cubinterpp_py, m) {
5252
.def(py::init<DoubleVector, DoubleVector, DoubleVector2>())
5353
.def("eval", &cip::MonotonicSpline2D<double>::eval<double, double>, py::return_value_policy::reference_internal);
5454

55-
py::class_<cip::AkimaSpline2D<double>>(m, "AkimaSpline2D")
55+
py::class_<cip::MakimaSpline2D<double>>(m, "MakimaSpline2D")
5656
.def(py::init<DoubleVector, DoubleVector, DoubleVector2>())
57-
.def("eval", &cip::AkimaSpline2D<double>::eval<double, double>, py::return_value_policy::reference_internal);
57+
.def("eval", &cip::MakimaSpline2D<double>::eval<double, double>, py::return_value_policy::reference_internal);
5858

5959
py::class_<cip::NaturalSpline2D<double>>(m, "NaturalSpline2D")
6060
.def(py::init<DoubleVector, DoubleVector, DoubleVector2>())

tests/test_cubic_splines_1d.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
using Vector = std::vector<double>;
77
using MonotonicSpline = cip::MonotonicSpline1D<double>;
8-
using AkimaSpline = cip::AkimaSpline1D<double>;
8+
using MakimaSpline = cip::MakimaSpline1D<double>;
99
using NaturalSpline = cip::NaturalSpline1D<double, 1, cip::BoundaryConditionType::Natural>;
1010
using NaturalSplineNotAKnot = cip::NaturalSpline1D<double, 1, cip::BoundaryConditionType::NotAKnot>;
1111
using NaturalSplineClamped = cip::NaturalSpline1D<double, 1, cip::BoundaryConditionType::Clamped>;
@@ -20,12 +20,12 @@ TEST(TestCubicSpline1D, test_monotonic_spline_1d) {
2020
}
2121

2222

23-
TEST(TestCubicSpline1D, test_akima_spline_1d) {
23+
TEST(TestCubicSpline1D, test_makima_spline_1d) {
2424
cip::Vector x = { 1, 2, 3, 4.0, 5.0, 5.5, 7.0, 8.0, 9.0, 9.5, 10 };
2525
cip::Vector f = { 0, 0, 0, 0.5, 0.4, 1.2, 1.2, 0.1, 0.0, 0.3, 0.6 };
2626
cip::Vector x_fine = { 1.0, 1.375, 1.75, 2.125, 2.5, 2.875, 3.25, 3.625, 4.0, 4.375, 4.75, 5.125, 5.5, 5.875, 6.25, 6.625, 7.0, 7.375, 7.75, 8.125, 8.5, 8.875, 9.25, 9.625, 10.0 };
2727
cip::Vector f_fine = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.061279296875, 0.289154052734375, 0.5, 0.4924377441406449, 0.38676757812498863, 0.532760099085408, 1.1999999999999993, 1.3822294207317043, 1.4444817073170721, 1.3844931402439027, 1.2000000000000455, 0.7961763822113426, 0.30638221153833456, 0.04557132320800861, -0.05930944055945275, -0.0412170836975676, 0.1380681818177436, 0.3749999999999991, 0.5999999999999988 };
28-
ASSERT_TRUE(cip::Interp1DAssertions<AkimaSpline>(x, f, x_fine, f_fine));
28+
ASSERT_TRUE(cip::Interp1DAssertions<MakimaSpline>(x, f, x_fine, f_fine));
2929
}
3030

3131

0 commit comments

Comments
 (0)