Useful Helper Routines

Operator Subsetting

hedge.tools.indexing.count_subset(subset)
hedge.tools.indexing.full_to_subset_indices(subset, base=0)

Takes a sequence of bools and turns it into an array of indices to be used to extract the subset from the full set.

Example:

>>> full_to_subset_indices([False, True, True])
array([1 2])
hedge.tools.indexing.full_to_all_subset_indices(subsets, base=0)

Takes a sequence of bools and generates it into an array of indices to be used to extract the subset from the full set.

Example:

>>> list(full_to_all_subset_indices([[False, True, True], [True,False,True]]))
[array([1 2]), array([3 5]
hedge.tools.indexing.partial_to_all_subset_indices(subsets, base=0)

Takes a sequence of bools and generates it into an array of indices to be used to insert the subset into the full set.

Example:

>>> list(partial_to_all_subset_indices([[False, True, True], [True,False,True]]))
[array([0 1]), array([2 3]

Mathematical Helpers

class hedge.tools.math.SubsettableCrossProduct(op1_subset=(True, True, True), op2_subset=(True, True, True), result_subset=(True, True, True))
A cross product that can operate on an arbitrary subsets of its two operands and return an arbitrary subset of its result.
hedge.tools.math.normalize(v)
hedge.tools.math.sign(x)
hedge.tools.math.get_spherical_coord(x_vec)
Parameter:x_vec – is an array whose leading dimension iterates over the X, Y, Z axes, and whose further dimensions may iterate over a number of points.
Returns:object array of [r, phi, theta]. phi is the angle in (x,y) in (-\pi,\pi).

Convergence Tests

hedge.tools.convergence.estimate_order_of_convergence(abscissae, errors)

Assuming that abscissae and errors are connected by a law of the form

error = constant * abscissa ^ (-order),

this function finds, in a least-squares sense, the best approximation of constant and order for the given data set. It returns a tuple (constant, order).

class hedge.tools.convergence.EOCRecorder

Miscellaneous

Table Of Contents

Previous topic

Visualization

Next topic

Hedge’s Inner Workings

This Page