Helpers

This module contains various auxiliary functions which are used throughout the library.

reikna.helpers.bounding_power_of_2(num)

Returns the minimal number of the form 2**m such that it is greater or equal to n.

reikna.helpers.factors(num, limit=None)

Returns the list of pairs (factor, num/factor) for all factors of num (including 1 and num), sorted by factor. If limit is set, only pairs with factor <= limit are returned.

class reikna.helpers.ignore_integer_overflow

Context manager for ignoring integer overflow in numpy operations on scalars (not ignored by default because of a bug in numpy).

reikna.helpers.log2(num)

Integer-valued logarigthm with base 2. If n is not a power of 2, the result is rounded to the smallest number.

reikna.helpers.min_blocks(length, block)

Returns minimum number of blocks with length block necessary to cover the array with length length.

reikna.helpers.product(seq)

Returns the product of elements in the iterable seq.

reikna.helpers.template_def(signature, code)

Returns a Mako template with the given signature.

Parameters:signature – a list of postitional argument names, or a Signature object from funcsigs module.
Code:a body of the template.
reikna.helpers.template_for(filename)

Returns the Mako template object created from the file which has the same name as filename and the extension .mako. Typically used in computation modules as template_for(__filename__).

reikna.helpers.template_from(template)

Creates a Mako template object from a given string. If template already has render() method, does nothing.

reikna.helpers.wrap_in_tuple(seq_or_elem)

If seq_or_elem is a sequence, converts it to a tuple, otherwise returns a tuple with a single element seq_or_elem.

Related Topics

This Page