module
Phase::Buffered(T)
Overview
A collection of convenience functions and optimizations targeted at multidimensional arrays stored linearly in memory (in lexicographic/row major/C order). This suggests the concept of a singular "index" representing each element, alongside the multidimensional coordinate.
TODO This should probably be parameterized by the buffer index type
Included Modules
Direct including types
Defined in:
buffered/buffered.crClass Method Summary
-
.axis_strides(shape)
Given an array of step sizes in each coordinate axis, returns the offset in the buffer that a step of that size represents.
-
.coord_to_index(coord, shape) : Int
Converts an n-dimensional relative coordinate (e.g.
-
.coord_to_index_fast(coord, shape, axis_strides) : Int
Converts an n-dimensional canonicalized coordinate (all ordinates must be in bounds and nonnegative) into a lexicographic buffer index.
-
.index_to_coord(index, shape) : Array
TODO OPTIMIZE: This could (maybe) be improved with use of
.axis_stridesConvert from a buffer location to an n-dimensional coord Converts a lexicographic buffer index into its corresponding coordinate in thisMultiIndexable.
Instance Method Summary
-
#buffer : Indexable
Returns the lexicographic buffer that stores the elements of this
MultiIndexable. -
#coord_to_index(coord) : Int
Converts an n-dimensional relative coordinate (e.g.
-
#index_to_coord(index) : Array
Convert from a buffer location to an n-dimensional coord Converts a lexicographic buffer index into its corresponding coordinate in this
MultiIndexable.
Instance methods inherited from module Phase::MultiIndexable(T)
%(other : MultiIndexable(U)) forall U%(other) %, &(other : MultiIndexable(U)) forall U
&(other) &, &*(other : MultiIndexable(U)) forall U
&*(other) &*, &**(other : MultiIndexable(U)) forall U
&**(other) &**, &+(other : MultiIndexable(U)) forall U
&+(other) &+, &-(other : MultiIndexable(U)) forall U
&-(other) &-, *(other : MultiIndexable(U)) forall U
*(other) *, **(other : MultiIndexable(U)) forall U
**(other) **, +(other : MultiIndexable(U)) forall U
+(other)
+ +, -(other : MultiIndexable(U)) forall U
-(other)
- -, /(other : MultiIndexable(U)) forall U
/(other) /, //(other : MultiIndexable(U)) forall U
//(other) //, <(other : MultiIndexable(U)) forall U
<(other) <, <=(other : MultiIndexable(U)) forall U
<=(other) <=, <=>(other : MultiIndexable(U)) forall U
<=>(other) <=>, ==(other : self) : Bool ==, =~(value) : MultiIndexable(Bool) =~, >(other : MultiIndexable(U)) forall U
>(other) >, >=(other : MultiIndexable(U)) forall U
>=(other) >=, [](region_literal : Indexable, drop : Bool = MultiIndexable::DROP_BY_DEFAULT)
[](region : IndexRegion)
[](*region_literal, drop : Bool = MultiIndexable::DROP_BY_DEFAULT) [], []?(bool_mask : MultiIndexable(Bool)) : MultiIndexable(T | Nil)
[]?(region : Indexable, drop : Bool = MultiIndexable::DROP_BY_DEFAULT) : MultiIndexable(T) | Nil
[]?(region : IndexRegion) : MultiIndexable(T) | Nil
[]?(*region_literal, drop : Bool = MultiIndexable::DROP_BY_DEFAULT) []?, ^(other : MultiIndexable(U)) forall U
^(other) ^, |(other : MultiIndexable(U)) forall U
|(other) |, ~ ~, apply : ApplyProxy apply, apply! : InPlaceApplyProxy apply!, colex_each : ElemIterator
colex_each(&) : Nil colex_each, colex_each_coord : ColexIterator
colex_each_coord(&) : Nil colex_each_coord, dimensions : Int dimensions, each : ElemIterator
each(&) : Nil each, each_coord : LexIterator
each_coord(&) : Nil each_coord, each_slice(axis = 0) : Iterator
each_slice(axis = 0, &) each_slice, each_with(*args, &) each_with, each_with_coord : ElemAndCoordIterator
each_with_coord(&) : Nil each_with_coord, empty? : Bool empty?, ensure_writable ensure_writable, eq(other : MultiIndexable(U)) : MultiIndexable(Bool) forall U
eq(value) : MultiIndexable(Bool) eq, equals?(other : MultiIndexable, &) : Bool equals?, fast_each : Iterator(T)
fast_each(&) : Nil fast_each, first : T first, get(coord : Indexable) : T
get(*coord : Int) get, get_available(region_literal : Indexable, drop : Bool = DROP_BY_DEFAULT)
get_available(region : IndexRegion, drop : Bool = DROP_BY_DEFAULT)
get_available(*region_literal, drop : Bool = MultiIndexable::DROP_BY_DEFAULT) get_available, get_chunk(coord : Indexable, region_shape : Indexable(I)) forall I
get_chunk(region_literal : Indexable, drop : Bool = DROP_BY_DEFAULT)
get_chunk(region : IndexRegion) : MultiIndexable(T)
get_chunk(*region_literal, drop : Bool = MultiIndexable::DROP_BY_DEFAULT) get_chunk, get_element(coord : Indexable) : T
get_element(*coord : Int) get_element, has_coord?(coord : Indexable) : Bool
has_coord?(*coord : Int) has_coord?, has_region?(region_literal : Indexable, drop : Bool = DROP_BY_DEFAULT) : Bool
has_region?(region : IndexRegion) : Bool
has_region?(*region_literal, drop : Bool = MultiIndexable::DROP_BY_DEFAULT) has_region?, hash(hasher) hash, last : T last, map(&block : T -> R) : MultiIndexable(R) forall R map, map!(&block : T -> T | MultiIndexable(T)) : MultiIndexable(T) map!, map_with(*args : *U, &) forall U
map_with(*args, &) map_with, map_with!(*args : *U, &) forall U map_with!, map_with_coord(&) map_with_coord, map_with_coord!(&block : T -> MultiIndexable(T)) map_with_coord!, permute(*args) : MultiIndexable(T) permute, process(&block : T -> R) : ProcView(self, T, R) forall R
process(proc : Proc(T, R)) : ProcView(self, T, R) forall R process, reshape(*args) : MultiIndexable(T) reshape, reverse(*args) : MultiIndexable(T) reverse, sample(n : Int, random = Random::DEFAULT) : Enumerable(T)
sample(random = Random::DEFAULT) : T sample, scalar? : Bool scalar?, shape : Array shape, size size, slices(axis = 0) : Indexable slices, tile(counts : Enumerable(Int)) : MultiIndexable
tile(*counts : Int) tile, to_f : Float to_f, to_literal_s(io : IO) : Nil to_literal_s, to_narr : NArray(T) to_narr, to_s(io : IO, settings = Formatter::Settings.new) : Nil
to_s(settings = Formatter::Settings.new) : String to_s, to_scalar : T to_scalar, to_scalar? : T | Nil to_scalar?, unsafe_fetch_chunk(region : IndexRegion) : MultiIndexable(T) unsafe_fetch_chunk, unsafe_fetch_element(coord : Indexable) : T unsafe_fetch_element, view(region : Indexable | Nil | IndexRegion = nil) : View(self, T)
view(*region) : View(self, T) view
Class methods inherited from module Phase::MultiIndexable(T)
each_with(*args : *U, &) forall U
each_with
Macros inherited from module Phase::MultiIndexable(T)
coord_splat_overload(name)
coord_splat_overload,
def_elementwise_binary(name)
def_elementwise_binary,
def_elementwise_unary(name)
def_elementwise_unary,
region_splat_overload(name)
region_splat_overload
Class Method Detail
Given an array of step sizes in each coordinate axis, returns the offset in the buffer that a step of that size represents. The buffer index of a multidimensional coordinate, x, is equal to x dotted with axis_strides
Converts an n-dimensional relative coordinate (e.g. negative indexing allowed) into a lexicographic buffer index.
Converts an n-dimensional canonicalized coordinate (all ordinates must be in bounds and nonnegative) into a lexicographic buffer index. This allows a slight performance increase at the expense of safety.
TODO OPTIMIZE: This could (maybe) be improved with use of .axis_strides
Convert from a buffer location to an n-dimensional coord
Converts a lexicographic buffer index into its corresponding coordinate
in this MultiIndexable. The coordinate will be produced in canonical
form (nonnegative indexes).
Instance Method Detail
Returns the lexicographic buffer that stores the elements of this MultiIndexable.
Converts an n-dimensional relative coordinate (e.g. negative indexing allowed) into a lexicographic buffer index.
Convert from a buffer location to an n-dimensional coord
Converts a lexicographic buffer index into its corresponding coordinate
in this MultiIndexable. The coordinate will be produced in canonical
form (nonnegative indexes).