Skip to content

Instantly share code, notes, and snippets.

@9il 9il/ndslice_asm.d
Created Dec 25, 2015

Embed
What would you like to do?
NDSlice loops check
import std.experimental.ndslice;
//3D += number
void nd_test_val(Slice!(3, double*) slice, double value)
{
slice[] += value;
}
//3D += 1D
void nd_test_slice1(Slice!(3, double*) slice, Slice!(1, double*) value)
{
slice[] += value;
}
//3D += 2D
void nd_test_slice2(Slice!(3, double*) slice, Slice!(2, double*) value)
{
slice[] += value;
}
//3D += 3D
void nd_test_slice3(Slice!(3, double*) slice, Slice!(3, double*) value)
{
slice[] += value;
}
//3D += array[]
void nd_test_array1(Slice!(3, double*) slice, double[] value)
{
slice[] += value;
}
//3D += array[][]
void nd_test_array2(Slice!(3, double*) slice, double[][] value)
{
slice[] += value;
}
//3D += array[][][]
void nd_test_array3(Slice!(3, double*) slice, double[][][] value)
{
slice[] += value;
}
void elem_test(Slice!(3, double*) slice, double value)
{
foreach(ref e; slice.byElement)
e += value;
}
void same_test(Slice!(3, double*) slice, Slice!(3, double*) value)
{
foreach(matrix; assumeSameStructure!("a", "b")(slice, value))
foreach(vector; matrix)
foreach(elem; vector)
elem.a += elem.b;
}
void crazy_test(Slice!(4, double*) slice)
{
slice
.transposed!(3, 2)
.pack!(2)
.evertPack
.unpack
.swapped!(1, 3)
.strided(2, 3)
.reversed!(0)
.everted
[8, 0..$, 7, 2..$] *= 10.0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.