Report a bug
If you spot a problem with this page, click here to create a Github issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.ndslice.field

This is a submodule of mir.ndslice.
Field is a type with opIndex(ptrdiff_t index) primitive. An iterator can be created on top of a field using FieldIterator . An ndslice can be created on top of a field using slicedField .

Fields

Field Name Used By
BitField bitwise 
BitpackField bitpack 
CycleField cycle  (2 kinds)
LinspaceField linspace 
MagicField magic 
MapField map  and mapField 
ndIotaField ndiota 
OrthogonalReduceField orthogonalReduceField 
RepeatField repeat 
Authors:
Ilya Yaroshenko
struct MapField(Field, alias _fun);
MapField is used by map .
Field _field;
const @property auto lightConst()();
immutable @property auto lightImmutable()();
template __map(alias fun1)
User defined constructor used by mapField.
@property auto assumeFieldsHaveZeroShift();
Defined if Field has member assumeFieldsHaveZeroShift.
struct VmapField(Field, Fun);
VmapField is used by map .
Field _field;
Fun _fun;
const @property auto lightConst()();
immutable @property auto lightImmutable()();
@property auto assumeFieldsHaveZeroShift();
Defined if Field has member assumeFieldsHaveZeroShift.
struct ZipField(Fields...) if (Fields.length > 1);
Iterates multiple fields in lockstep.
ZipField is used by zipFields .
Fields _fields;
const @property auto lightConst()();
immutable @property auto lightImmutable()();
@property auto assumeFieldsHaveZeroShift();
Defined if at least one of Fields has member assumeFieldsHaveZeroShift.
struct RepeatField(T);
RepeatField is used by repeat .
alias UT = Unqual!T;
UT _value;
const @property auto lightConst()();
immutable @property auto lightImmutable()();
struct BitField(Field, I = typeof(cast()Field.init[size_t.init])) if (__traits(isUnsigned, I));
BitField is used by bitwise .
Examples:
import mir.ndslice.iterator: FieldIterator;
   ushort[10] data;
   auto f = FieldIterator!(BitField!(ushort*))(0, BitField!(ushort*)(data.ptr));
   f[123] = true;
   f++;
   assert(f[122]);
Field _field;
auto __vmap(Fun : LeftOp!(op, bool), string op)(Fun fun)
if (op == "|" || op == "&" || op == "^");

auto __vmap(Fun : RightOp!(op, bool), string op)(Fun fun)
if (op == "|" || op == "&" || op == "^");

auto __vmap(Fun)(Fun fun);

template __map(alias fun)
optimization for bitwise operations
const @property auto lightConst()();
immutable @property auto lightImmutable()();
@property auto assumeFieldsHaveZeroShift();
Defined if Field has member assumeFieldsHaveZeroShift.
struct BitpackField(Field, uint pack, I = typeof(cast()Field.init[size_t.init])) if (__traits(isUnsigned, I));
BitpackField is used by bitpack .
Examples:
import mir.ndslice.iterator: FieldIterator;
ushort[10] data;
auto f = FieldIterator!(BitpackField!(ushort*, 6))(0, BitpackField!(ushort*, 6)(data.ptr));
f[0] = cast(ushort) 31;
f[1] = cast(ushort) 13;
f[2] = cast(ushort)  8;
f[3] = cast(ushort) 43;
f[4] = cast(ushort) 28;
f[5] = cast(ushort) 63;
f[6] = cast(ushort) 39;
f[7] = cast(ushort) 23;
f[8] = cast(ushort) 44;

assert(f[0] == 31);
assert(f[1] == 13);
assert(f[2] ==  8);
assert(f[3] == 43);
assert(f[4] == 28);
assert(f[5] == 63);
assert(f[6] == 39);
assert(f[7] == 23);
assert(f[8] == 44);
assert(f[9] == 0);
assert(f[10] == 0);
assert(f[11] == 0);
Field _field;
const @property auto lightConst()();
immutable @property auto lightImmutable()();
@property auto assumeFieldsHaveZeroShift();
Defined if Field has member assumeFieldsHaveZeroShift.
struct OrthogonalReduceField(FieldsIterator, alias fun, T);
Slice!FieldsIterator _fields;
non empty slice
T _initialValue;
const @property auto lightConst()();
immutable @property auto lightImmutable()();
auto opIndex()(size_t index);
r = fun(r, fields[i][index]); reduction by i
struct CycleField(Field);
size_t _length;
Cycle length
Field _field;
const @property auto lightConst()();
immutable @property auto lightImmutable()();
ref auto opIndex()(size_t index);
ref auto opIndexAssign(T)(auto ref T value, size_t index);
@property auto assumeFieldsHaveZeroShift();
Defined if Field has member assumeFieldsHaveZeroShift.
struct CycleField(Field, size_t length);
enum auto _length;
Cycle length
Field _field;
const @property auto lightConst()();
immutable @property auto lightImmutable()();
ref auto opIndex()(size_t index);
ref auto opIndexAssign(T)(auto ref T value, size_t index);
@property auto assumeFieldsHaveZeroShift();
Defined if Field has member assumeFieldsHaveZeroShift.
struct ndIotaField(size_t N) if (N);
ndIotaField is used by ndiota .
size_t[N - 1] _lengths;
const @property auto lightConst()();
const @property auto lightImmutable()();
const size_t[N] opIndex()(size_t index);
struct LinspaceField(T);
LinspaceField is used by linspace .
size_t _length;
T _start;
T _stop;
const @property auto lightConst()();
const @property auto lightImmutable()();
const T opIndex()(sizediff_t index);
const @property size_t length();
const @nogc @property size_t[1] shape(size_t dimension = 0)()
if (dimension == 0);
struct MagicField();
Magic square field.
size_t _n;
Magic Square size.
const @property auto lightConst()();
const @property auto lightImmutable()();
const @property size_t length(size_t dimension = 0)()
if (dimension <= 2);
const @nogc @property size_t[1] shape();
const size_t opIndex()(size_t index);