Skip to content

Commit 1a5dbca

Browse files
committed
rework MetaSpline
1 parent 2db1139 commit 1a5dbca

1 file changed

Lines changed: 19 additions & 25 deletions

File tree

source/mir/interpolate/spline.d

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ MetaSpline!(T, X) metaSpline(F, X, T)(
15601560
const F param = 0,
15611561
)
15621562
{
1563-
return metaSpline!(F, X, T)(grid, data, boundaries, boundaries, kind, param);
1563+
return metaSpline!(F, X, T)(grid, data, SplineConfiguration!F(kind, boundaries, boundaries, param));
15641564
}
15651565

15661566
/++
@@ -1587,7 +1587,7 @@ MetaSpline!(T, X) metaSpline(F, X, T)(
15871587
)
15881588
{
15891589
import core.lifetime: move;
1590-
return MetaSpline!(T, X)(grid.move, data.move, kind, param, lBoundary, rBoundary);
1590+
return metaSpline(grid.move, data.move, SplineConfiguration!F(kind, lBoundary, rBoundary, param));
15911591
}
15921592

15931593
/++
@@ -1607,8 +1607,7 @@ MetaSpline!(T, X) metaSpline(F, X, T)(
16071607
)
16081608
{
16091609
import core.lifetime: move;
1610-
with(configuration)
1611-
return metaSpline!(F, X, T)(grid.move, data.move, leftBoundary, rightBoundary, kind, param);
1610+
return MetaSpline!(T, X)(grid.move, data.move, configuration);
16121611
}
16131612

16141613
/// ditto
@@ -1619,29 +1618,19 @@ struct MetaSpline(T, X)
16191618
// alias ElementInterpolator = Linear!(F, N, X);
16201619
alias F = ValueType!(T, X);
16211620
///
1622-
Spline!F spline;
1621+
private Spline!F spline;
16231622
///
16241623
RCArray!(const T) data;
16251624
//
16261625
private RCArray!F _temp;
16271626
///
1628-
SplineType splineType;
1629-
///
1630-
F splineParam;
1631-
///
1632-
SplineBoundaryCondition!F lBoundary;
1633-
///
1634-
SplineBoundaryCondition!F rBoundary;
1635-
1627+
SplineConfiguration!F configuration;
16361628

16371629
///
16381630
this(
16391631
RCArray!(immutable X) grid,
16401632
RCArray!(const T) data,
1641-
SplineType splineType,
1642-
F splineParam,
1643-
SplineBoundaryCondition!F lBoundary,
1644-
SplineBoundaryCondition!F rBoundary,
1633+
SplineConfiguration!F configuration,
16451634
)
16461635
{
16471636
import core.lifetime: move;
@@ -1661,10 +1650,15 @@ struct MetaSpline(T, X)
16611650
this.data = data.move;
16621651
this._temp = grid.length;
16631652
this.spline = grid.moveToSlice;
1664-
this.splineType = splineType;
1665-
this.splineParam = splineParam;
1666-
this.lBoundary = lBoundary;
1667-
this.rBoundary = rBoundary;
1653+
this.configuration = configuration;
1654+
}
1655+
1656+
///
1657+
bool opEquals()(auto ref scope const typeof(this) rhs) scope const @trusted pure nothrow @nogc
1658+
{
1659+
return this.gridScopeView == rhs.gridScopeView
1660+
&& this.data == rhsthis.data
1661+
&& this.configuration == rhs.configuration;
16681662
}
16691663

16701664
///
@@ -1711,10 +1705,10 @@ struct MetaSpline(T, X)
17111705
foreach (i, ref d; data)
17121706
mutable[i][0] = d(xs[1 .. $]);
17131707
(*cast(Spline!F*)&spline)._computeDerivativesTemp(
1714-
splineType,
1715-
splineParam,
1716-
lBoundary,
1717-
rBoundary,
1708+
configuration.kind,
1709+
configuration.param,
1710+
configuration.leftBoundary,
1711+
configuration.rightBoundary,
17181712
(cast(F[])_temp[]).sliced);
17191713
return spline(xs[0]);
17201714
}

0 commit comments

Comments
 (0)