Skip to content

Commit b57ee66

Browse files
committed
fix linear
1 parent be9ffea commit b57ee66

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

source/mir/interpolate/linear.d

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ version(mir_test)
9292
}
9393

9494
/// R^2 -> R: Bilinear interpolaiton
95+
version(mir_test)
9596
@safe pure unittest
9697
{
9798
import std.math: approxEqual;
@@ -133,6 +134,7 @@ version(mir_test)
133134
}
134135

135136
/// R^3 -> R: Trilinear interpolaiton
137+
version(mir_test)
136138
@safe pure unittest
137139
{
138140
import std.math: approxEqual;

source/mir/interpolate/package.d

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ template generateShuffles3(size_t N, size_t P)
286286
void shuffle3(size_t P, F, size_t N)(ref F[N] a, ref F[N] b, ref F[N] c, ref F[N] d)
287287
if (P <= N && N)
288288
{
289-
static if (P == 0)
289+
static if (P == 0 || N == 1)
290290
{
291291
copyvec(a, c);
292292
copyvec(b, d);
@@ -311,6 +311,7 @@ void shuffle3(size_t P, F, size_t N)(ref F[N] a, ref F[N] b, ref F[N] c, ref F[N
311311
static if (j < N)
312312
{
313313
copyvec(a[i * P .. i * P + P], c[j .. j + P]);
314+
static assert(j + 2 * P <= c.length);
314315
copyvec(b[i * P .. i * P + P], c[j + P .. j + 2 * P]);
315316
}
316317
else
@@ -325,9 +326,9 @@ void shuffle3(size_t P, F, size_t N)(ref F[N] a, ref F[N] b, ref F[N] c, ref F[N
325326
void shuffle2(size_t P, F, size_t N)(ref F[N] a, ref F[N] b, ref F[N] c, ref F[N] d)
326327
if (P <= N && N)
327328
{
328-
static if (P == 0)
329+
static if (P == 0 || N == 1)
329330
{
330-
copyvec(a, b);
331+
copyvec(a, c);
331332
copyvec(b, d);
332333
}
333334
else
@@ -366,9 +367,9 @@ void shuffle2(size_t P, F, size_t N)(ref F[N] a, ref F[N] b, ref F[N] c, ref F[N
366367
void shuffle1(size_t P, F, size_t N)(ref F[N] a, ref F[N] b, ref F[N] c, ref F[N] d)
367368
if (P <= N && N)
368369
{
369-
static if (P == 0)
370+
static if (P == 0 || N == 1)
370371
{
371-
copyvec(a, b);
372+
copyvec(a, c);
372373
copyvec(b, d);
373374
}
374375
else

0 commit comments

Comments
 (0)