Skip to content

Commit 046b7b3

Browse files
committed
fix interplate module and opt attributes
1 parent a7004c3 commit 046b7b3

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

source/mir/interpolate/constant.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ struct Constant(F, size_t N = 1, FirstGridIterator = F*, NextGridIterators = Rep
183183
this._ownsData = false;
184184
}
185185

186+
@trusted:
187+
186188
///
187189
GridVectors[dimension] grid(size_t dimension = 0)() const @property
188190
if (dimension < N)
@@ -232,7 +234,7 @@ struct Constant(F, size_t N = 1, FirstGridIterator = F*, NextGridIterators = Rep
232234
else
233235
indexes[i] = this.findInterval!i(xs[i]);
234236
}
235-
return _data[indexes];
237+
return _data[][indexes];
236238
}
237239
}
238240
}

source/mir/interpolate/linear.d

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ struct Linear(F, size_t N = 1, FirstGridIterator = F*, NextGridIterators...)
269269
this._ownsData = false;
270270
}
271271

272+
@trusted:
273+
272274
///
273275
GridVectors[dimension] grid(size_t dimension = 0)() const @property
274276
if (dimension < N)
@@ -362,7 +364,7 @@ struct Linear(F, size_t N = 1, FirstGridIterator = F*, NextGridIterators...)
362364
static if (rp2d == 1)
363365
shuffle3!1(local[1][0 .. L], local[1][L .. 2 * L], local[0][0 .. L], local[0][L .. 2 * L]);
364366
static if (i + 1 == N)
365-
return *cast(SplineReturnType!(F, N, rp2d)*) local[0].ptr;
367+
return *cast(SplineReturnType!(F, N, 2 ^^ rp2d)*) local[0].ptr;
366368
}
367369
}
368370
}

source/mir/interpolate/package.d

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ template findInterval(size_t dimension = 0)
6767
auto grid = interpolant.grid[1 .. $][0 .. len];
6868
}
6969
assert(len >= 0);
70-
return len - grid
71-
.assumeSorted
72-
.upperBound(x)
73-
.length;
70+
return len - grid.assumeSorted.upperBound(x).length;
7471
}
7572
}
7673

@@ -262,10 +259,10 @@ auto copyvec(F, size_t N)(ref const F[N] from, ref F[N] to)
262259

263260
package template SplineReturnType(F, size_t N, size_t P)
264261
{
265-
static if (P == 0 || N == 0)
262+
static if (P <= 1 || N == 0)
266263
alias SplineReturnType = F;
267264
else
268-
alias SplineReturnType = .SplineReturnType!(F, N - 1, P)[2 ^^ P];
265+
alias SplineReturnType = .SplineReturnType!(F, N - 1, P)[P];
269266
}
270267

271268
template generateShuffles3(size_t N, size_t P)

source/mir/interpolate/spline.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,12 +566,12 @@ struct Spline(F, size_t N = 1, FirstGridIterator = F*, NextGridIterators...)
566566
// X.length == N || derivative == 0 && X.length && X.length <= N
567567
{
568568
auto d4 = this.opCall!3(xs);
569-
SplineReturnType!(F, N, 2) d3;
569+
SplineReturnType!(F, N, 3) d3;
570570
void fun(size_t d, A, B)(ref A a, ref B b)
571571
{
572572
static if (d)
573573
foreach(i; Iota!3)
574-
fun!(d - 1)(a, b);
574+
fun!(d - 1)(a[i], b[i]);
575575
else
576576
b = a;
577577
}
@@ -653,7 +653,7 @@ struct Spline(F, size_t N = 1, FirstGridIterator = F*, NextGridIterators...)
653653
);
654654
static if (i + 1 == N)
655655
{
656-
return *cast(SplineReturnType!(F, N, rp2d)*) local[0].ptr;
656+
return *cast(SplineReturnType!(F, N, 2 ^^ rp2d)*) local[0].ptr;
657657
}
658658
else
659659
{

source/mir/math/common.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ version(LDC)
6969
}
7070
else
7171
{
72-
enum { fastmath, fusedmath, optmath };
72+
enum { fmamath, optmath, fastmath };
7373
}
7474

7575
version(LDC)

0 commit comments

Comments
 (0)