Skip to content

Commit 9ea6dc1

Browse files
committed
update interpolation results
1 parent 02c2ec9 commit 9ea6dc1

File tree

2 files changed

+12
-35
lines changed

2 files changed

+12
-35
lines changed

source/mir/interpolation/linear.d

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,11 @@ struct LinearInterpolation(RangeG, RangeV)
7878
auto y0 = _values[interval + 0];
7979
auto y1 = _values[interval + 1];
8080

81-
return eval(x0, x1, y0, y1, x);
81+
return opCall!T(x0, x1, y0, y1, x);
8282
}
8383

84-
/// ditto
85-
alias opIndex = opCall;
86-
87-
package:
88-
static alias eval = .evalImpl!(G, V);
89-
90-
size_t length ()() @property { return grid.length - 1; }
91-
bool empty ()() @property { return length == 0; }
92-
auto ref front()() @property { return grid.front; }
93-
94-
void popFront()()
95-
{
96-
assert(grid.length > 1);
97-
grid.popFront;
98-
values.popFront;
99-
}
100-
}
101-
102-
private template evalImpl(G, V)
103-
{
104-
@fastmath
105-
auto evalImpl(T)(G x0, G x1, V y0, V y1, in T x)
84+
///
85+
static auto opCall(T)(G x0, G x1, V y0, V y1, in T x)
10686
{
10787
auto step = x1 - x0;
10888
auto w0 = x - x0;
@@ -113,8 +93,10 @@ private template evalImpl(G, V)
11393
y1 *= w0;
11494
return y0 + y1;
11595
}
116-
}
11796

97+
/// ditto
98+
alias opIndex = opCall;
99+
}
118100

119101
/++
120102
Linear interpolation.

source/mir/interpolation/pchip.d

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,11 @@ struct Pchip(RangeG, RangeV, RangeS)
8787
auto s0 = _slopes[interval + 0];
8888
auto s1 = _slopes[interval + 1];
8989

90-
return eval(x0, x1, y0, y1, s0, s1, x);
90+
return opCall!T(x0, x1, y0, y1, s0, s1, x);
9191
}
9292

93-
/// ditto
94-
alias opIndex = opCall;
95-
96-
package static alias eval = .evalImpl!(G, V, S);
97-
}
98-
99-
package template evalImpl(G, V, S)
100-
{
101-
@fastmath
102-
auto evalImpl(T)(G x0, G x1, V y0, V y1, S s0, S s1, in T x)
93+
///
94+
auto opCall(T)(G x0, G x1, V y0, V y1, S s0, S s1, in T x)
10395
{
10496
auto step = x1 - x0;
10597
auto diff = y1 - y0;
@@ -127,6 +119,9 @@ package template evalImpl(G, V, S)
127119

128120
return y0 + y1;
129121
}
122+
123+
/// ditto
124+
alias opIndex = opCall;
130125
}
131126

132127
/++

0 commit comments

Comments
 (0)