httk.core.vectors.mutablefracvector

A mutable, list-backed variant of FracVector.

Classes

MutableFracVector

Same as FracVector, only this version allows

Module Contents

class httk.core.vectors.mutablefracvector.MutableFracVector(noms: Any, denom: int = 1)[source]

Bases: httk.core.vectors.fracvector.FracVector

Same as FracVector, only this version allows assignment of elements, e.g.:

mfracvec[2, 7] = 5

and, e.g.:

mfracvec[:, 7] = [1, 2, 3, 4]

Other than this, the FracVector methods exist and do the same, i.e., they return copies of the fracvector, rather than modifying it.

However, methods have also been added named with set_* prefixes which perform mutating operations, e.g.:

A.set_T()

replaces A with its own transpose, whereas:

A.T()

just returns a new MutableFracVector that is the transpose of A, leaving A unmodified.

nested_map: ClassVar[collections.abc.Callable[Ellipsis, Any]][source]
nested_inmap: ClassVar[collections.abc.Callable[Ellipsis, Any]][source]
nested_map_fractions: ClassVar[collections.abc.Callable[Ellipsis, Any]][source]
noms: Any[source]
classmethod use(old: Any) httk.core.vectors.fracvector.FracVector[source]

Make sure the variable is a MutableFracVector, and if not, convert it.

to_FracVector() httk.core.vectors.fracvector.FracVector[source]

Return a FracVector with the values of this MutableFracVector.

classmethod from_FracVector(other: httk.core.vectors.fracvector.FracVector) MutableFracVector[source]

Create a MutableFracVector from a FracVector.

validate() bool[source]
invalidate() None[source]

Internal method to call when the MutableFracVector is changed in such a way that cached properties are invalidated (e.g., _dim).

set_negative() None[source]

Change the MutableFracVector inline into its own negative: self -> -self.

set_T() None[source]

Change the MutableFracVector inline into its own transpose: self -> self.T.

set_inv() Any[source]

Change the MutableFracVector inline into its own inverse: self -> self^-1.

set_simplify() None[source]

Change the MutableFracVector; reduces any common factor between the denominator and all nominators.

set_set_denominator(resolution: int = 1000000000) None[source]

Change the MutableFracVector; reduces resolution.

Parameters:

resolution – the new denominator; each element becomes the closest numerical approximation using this denominator.

set_normalize() None[source]

Add/remove an integer +/-N to each element to place it in the range [0, 1).

set_normalize_half() None[source]

Add/remove an integer +/-N to each element to place it in the range [-1/2, 1/2).

This is useful to find the shortest vector C between two points A, B in a space with periodic boundary conditions [0, 1):

C = (A - B).normalize_half()