Skip to content

Commit 9aceb1a

Browse files
committed
change primitives constraints
1 parent ed579c9 commit 9aceb1a

File tree

4 files changed

+10
-21
lines changed

4 files changed

+10
-21
lines changed

source/mir/interpolate/linear.d

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ struct Linear(F, size_t N = 1, FirstGridIterator = F*, NextGridIterators = Repea
302302
alias withDerivative = opCall!1;
303303
}
304304

305-
///
306305
struct LinearKernel(uint derivative, X)
307306
if (derivative <= 3)
308307
{
@@ -319,7 +318,6 @@ struct LinearKernel(uint derivative, X)
319318
w1 = c1 / step;
320319
}
321320

322-
///
323321
auto opCall(Y)(in Y y0, in Y y1)
324322
{
325323
auto r0 = y0 * w1;

source/mir/interpolate/spline.d

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ struct Spline(F, size_t N = 1, FirstGridIterator = F*, NextGridIterators = Repea
384384
Params:
385385
lbc = left boundary condition
386386
rbc = right boundary condition
387+
387388
$(RED For internal use.)
388389
+/
389390
void _computeDerivatives()(SplineBoundaryCondition!F lbc, SplineBoundaryCondition!F rbc) @trusted nothrow @nogc
@@ -762,7 +763,6 @@ void splineSlopes(F, T, IP, IV, IS, SliceKind gkind, SliceKind vkind, SliceKind
762763
}
763764
}
764765

765-
///
766766
struct SplineKernel(uint derivative, X)
767767
if (derivative <= 3)
768768
{
@@ -781,7 +781,6 @@ struct SplineKernel(uint derivative, X)
781781
wq = w0 * w1;
782782
}
783783

784-
///
785784
auto opCall(Y)(in Y y0, in Y y1, in Y s0, in Y s1)
786785
{
787786
auto diff = y1 - y0;

source/mir/ndslice/sorting.d

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ unittest
8383
}
8484

8585
import mir.ndslice.slice;
86-
import mir.internal.utility;
86+
import mir.math.common: optmath;
8787

88-
@fastmath:
88+
@optmath:
8989

9090
deprecated(`Use 'yourSlice.pairwise!"a <= b".all' instead. Imports:
9191
import mir.ndslice.algorithm: all;
@@ -95,7 +95,7 @@ template isSorted(alias less = "!(a >= b)")
9595
{
9696
import mir.functional: naryFun;
9797
static if (__traits(isSame, naryFun!less, less))
98-
@fastmath bool isSorted(SliceKind kind, size_t[] packs, Iterator)
98+
@optmath bool isSorted(SliceKind kind, size_t[] packs, Iterator)
9999
(Slice!(kind, packs, Iterator) slice)
100100
if (packs.length == 1)
101101
{
@@ -116,7 +116,7 @@ template isStrictlyMonotonic(alias less = "a < b")
116116
{
117117
import mir.functional: naryFun;
118118
static if (__traits(isSame, naryFun!less, less))
119-
@fastmath bool isStrictlyMonotonic(SliceKind kind, size_t[] packs, Iterator)
119+
@optmath bool isStrictlyMonotonic(SliceKind kind, size_t[] packs, Iterator)
120120
(Slice!(kind, packs, Iterator) slice)
121121
if (packs.length == 1)
122122
{
@@ -168,7 +168,7 @@ template sort(alias less = "a < b")
168168
import mir.functional: naryFun;
169169
static if (__traits(isSame, naryFun!less, less))
170170
///
171-
@fastmath Slice!(kind, packs, Iterator) sort(SliceKind kind, size_t[] packs, Iterator)
171+
@optmath Slice!(kind, packs, Iterator) sort(SliceKind kind, size_t[] packs, Iterator)
172172
(Slice!(kind, packs, Iterator) slice)
173173
if (packs.length == 1)
174174
{

source/mir/primitives.d

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ enum bool hasShape(R) = is(typeof(
6868
}
6969

7070
///
71-
auto shape(Range)(Range range)
72-
if (__traits(hasMember, Range, "shape") || __traits(hasMember, Range, "length") || isArray!Range)
71+
auto shape(Range)(auto ref Range range)
72+
if (hasLength!Range || hasShape!Range)
7373
{
7474
static if (__traits(hasMember, Range, "shape"))
7575
{
@@ -101,11 +101,7 @@ template DimensionCount(T)
101101

102102
///
103103
bool anyEmpty(Range)(Range range)
104-
if (
105-
__traits(compiles, { bool b = range.anyEmpty; }) ||
106-
__traits(compiles, { auto b = range.shape; enum size_t e = b.length; }) ||
107-
__traits(compiles, { bool b = range.empty; })
108-
)
104+
if (hasShape!Range || __traits(hasMember, Range, "anyEmpty"))
109105
{
110106
static if (__traits(hasMember, Range, "anyEmpty"))
111107
{
@@ -128,13 +124,13 @@ bool anyEmpty(Range)(Range range)
128124

129125
///
130126
size_t elementsCount(Range)(Range range)
127+
if (hasShape!Range || __traits(hasMember, Range, "elementsCount"))
131128
{
132129
static if (__traits(hasMember, Range, "elementsCount"))
133130
{
134131
return range;
135132
}
136133
else
137-
static if (__traits(hasMember, Range, "shape"))
138134
{
139135
auto sh = range.shape;
140136
size_t ret = sh[0];
@@ -144,8 +140,4 @@ size_t elementsCount(Range)(Range range)
144140
}
145141
return ret;
146142
}
147-
else
148-
{
149-
return range.length;
150-
}
151143
}

0 commit comments

Comments
 (0)