scamp_extensions.utilities.math

Subpackage containing mathematical utility functions (many of which are imported from scamp.utilities.

Classes

AtanWarp(in_lo, in_hi, out_min, out_max)

A warping function that uses an appropriately scaled arctan to warp values from the input range to the output range.

Functions

atan_warp(value, in_lo, in_hi, out_min, out_max)

Uses an appropriately scaled arctan function to warp values from the input range to the output range.

lcm(a, b)

Return lowest common multiple.

remap(value_or_values, out_min, out_max[, ...])

Rescales the given value or values so that they fall within the given output range.

wrap_to_range(x, range_min, range_max[, mirror])

Wraps the input x into the given range, either jumping back to the other side of the range at the boundaries, or if the mirror parameter is set, reflecting at the boundaries.

is_multiple(x, y)

Checks if x is a multiple of y.

prime_factor(n)

Returns a list of the prime factors of n.

round_x_to_pow_of_y(x, y)

Returns the integer power of y that is closest to x (above or below).

floor_to_multiple(x, factor)

Returns the multiple of factor that is closest below x.

gcd(*integers)

Greatest Common Divisor.

round_to_multiple(x, factor)

Returns the multiple of factor that is closest to x (above or below).

ceil_to_multiple(x, factor)

Returns the multiple of factor that is closest above x.

is_x_pow_of_y(x, y)

Checks if x is an integer (including negative) power of y

ceil_x_to_pow_of_y(x, y)

Returns the integer power of y that is closest above x.

floor_x_to_pow_of_y(x, y)

Returns the integer power of y that is closest below x.

is_prime(a)

Checks if a is a prime number.