module Phase::CoordUtil

Overview

A collection of utility functions for putting coordinates (whose ordinates may be positive, forward indexes, or negative, reverse indexes) into canoncial form.

Extended Modules

Defined in:

coord_util.cr

Instance Method Summary

Instance Method Detail

def canonicalize_coord(coord, shape) : Coord #

Converts a coord into canonical form, such that each index in coord is positive. Throws an IndexError if at least one index specified in coord is out of range for the corresponding axis of shape.


[View source]
def canonicalize_index(index, shape, axis) #

Returns the canonical (positive) form of index along a particular axis of shape. Throws an IndexError if index is out of range of shape along this axis.


[View source]
def canonicalize_index(index, size) #

Returns the canonical (positive) form of index along a particular axis of a given size (number of elements). Throws an IndexError if index is not a valid positive or negative array index for size elements.


[View source]
def has_coord?(coord, shape) #

Checks if coord is a valid coordinate for an array-like object with dimensions specified by shape. A coord is a list (Enumerable) of integers specifying an index along each axis in shape.


[View source]
def has_index?(index, shape, axis) #

Checks if index is a valid index along axis for an array-like object with dimensions specified by shape.


[View source]
def has_index?(index, size : Int::Unsigned) #

[View source]
def has_index?(index, size : Int) #

Returns true if a given index can be used to access an array axis with size elements.


[View source]