httk.core.vectors.vectormath¶
Functional wrappers over the math module that also work on FracVector-like objects.
Each function first tries to dispatch to a method on the argument (so a FracVector computes
an exact-rational element-wise result), and otherwise falls back to the corresponding
math function on a plain scalar.
Functions¶
|
Return the ceiling of x, the smallest integer value greater than or equal to x. |
|
Return x with the sign of y. If an element of y is zero, abs of the corresponding element |
|
Return the sign of x: -1, 0, or 1 (the numpy convention, so sign(0) == 0). |
|
Return the absolute value of x. |
|
Return x factorial. Raises ValueError if (any element of) x is negative. |
|
Return the floor of x, the largest integer value less than or equal to x. |
|
Equivalent to x % y. |
|
Return the mantissa and exponent of x as the pair (m, e). m is a float and e is an integer |
|
Equivalent to sum(iterable). |
|
Check if the float x is positive or negative infinity. |
|
Check if the float x is positive or negative infinity. |
|
Check if the float x is a NaN (not a number). |
|
Check if the float x is a NaN (not a number). |
|
Return x * (2**i). This is essentially the inverse of function frexp(). |
|
Return the fractional and integer parts of x. Both results carry the sign of x. |
|
Return the integer part of x. |
|
Return e**x. (For vectors applied to each element.) |
|
Return e**x - 1. (For vectors applied to each element.) |
|
With one argument, return the natural logarithm of x (to base e). |
|
Return the natural logarithm of 1+x (base e). The result is calculated in a way which is |
|
Return the base-10 logarithm of x. This is usually more accurate than log(x, 10). |
|
Return x raised to the power y. Equivalent with x**y. |
|
Return the square root of x. |
|
Return the arc cosine of x, in radians. |
|
Return the arc sine of x, in radians. |
|
Return the arc tangent of x, in radians. |
|
Return atan(y / x), in radians, with the standard |
|
Return the cosine of x radians. |
|
Return the Euclidean norm, sqrt(x*x + y*y). This is the length of the vector from the origin |
|
Return the sine of x radians. |
|
Return the tangent of x radians. |
|
Convert angle x from radians to degrees. |
|
Convert angle x from degrees to radians. |
|
Return the inverse hyperbolic cosine of x. |
|
Return the inverse hyperbolic sine of x. |
|
Return the inverse hyperbolic tangent of x. |
|
Return the hyperbolic cosine of x. |
|
Return the hyperbolic sine of x. |
|
Return the hyperbolic tangent of x. |
|
Return the error function at x. |
|
Return the complementary error function at x. |
|
Return the Gamma function at x. |
|
Return the natural logarithm of the absolute value of the Gamma function at x. |
|
Return the value of pi represented using the same scalar or vector representation as x. |
|
Return the value of e represented using the same scalar or vector representation as x. |
Module Contents¶
- httk.core.vectors.vectormath.ceil(x: Any, **args: Any) Any[source]¶
Return the ceiling of x, the smallest integer value greater than or equal to x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.copysign(x: Any, y: Any, **args: Any) Any[source]¶
Return x with the sign of y. If an element of y is zero, abs of the corresponding element in x is returned.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.sign(x: Any, **args: Any) Any[source]¶
Return the sign of x: -1, 0, or 1 (the numpy convention, so sign(0) == 0).
(For vectors applied to each element.)
- httk.core.vectors.vectormath.fabs(x: Any, **args: Any) Any[source]¶
Return the absolute value of x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.factorial(x: Any, **args: Any) Any[source]¶
Return x factorial. Raises ValueError if (any element of) x is negative.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.floor(x: Any, **args: Any) Any[source]¶
Return the floor of x, the largest integer value less than or equal to x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.frexp(x: Any, **args: Any) Any[source]¶
Return the mantissa and exponent of x as the pair (m, e). m is a float and e is an integer such that x == m * 2**e exactly. If x is zero, returns (0.0, 0), otherwise 0.5 <= abs(m) < 1.
This decomposition is only meaningful for binary floating-point values; exact rational types such as FracVector do not support it — convert with
to_floats()/to_float()first (a clear TypeError is raised otherwise).(For vectors applied to each element and returns tuples nested in lists.)
- httk.core.vectors.vectormath.fsum(iterable: Any, **args: Any) Any[source]¶
Equivalent to sum(iterable).
- httk.core.vectors.vectormath.isinf(x: Any, **args: Any) Any[source]¶
Check if the float x is positive or negative infinity.
(For vectors applied to each element and returns True/False as nested lists.)
- httk.core.vectors.vectormath.isanyinf(x: Any, **args: Any) Any[source]¶
Check if the float x is positive or negative infinity.
(For vectors returns True/False if any element is inf.)
- httk.core.vectors.vectormath.isnan(x: Any, **args: Any) Any[source]¶
Check if the float x is a NaN (not a number).
(For vectors applied to each element and returns True/False as nested lists.)
- httk.core.vectors.vectormath.isanynan(x: Any, **args: Any) Any[source]¶
Check if the float x is a NaN (not a number).
(For vectors returns True/False if any element is NaN.)
- httk.core.vectors.vectormath.ldexp(x: Any, i: int, **args: Any) Any[source]¶
Return x * (2**i). This is essentially the inverse of function frexp().
(For vectors applied to each element.)
- httk.core.vectors.vectormath.modf(x: Any, **args: Any) Any[source]¶
Return the fractional and integer parts of x. Both results carry the sign of x.
(For vectors applied to each element and returns tuples nested in lists.)
- httk.core.vectors.vectormath.trunc(x: Any, **args: Any) Any[source]¶
Return the integer part of x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.exp(x: Any, **args: Any) Any[source]¶
Return e**x. (For vectors applied to each element.)
- httk.core.vectors.vectormath.expm1(x: Any, **args: Any) Any[source]¶
Return e**x - 1. (For vectors applied to each element.)
- httk.core.vectors.vectormath.log(x: Any, base: Any = None, **args: Any) Any[source]¶
With one argument, return the natural logarithm of x (to base e).
With two arguments, return the logarithm of x to the given base, calculated as log(x)/log(base).
(For vectors applied to each element.)
- httk.core.vectors.vectormath.log1p(x: Any, **args: Any) Any[source]¶
Return the natural logarithm of 1+x (base e). The result is calculated in a way which is accurate for x near zero.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.log10(x: Any, **args: Any) Any[source]¶
Return the base-10 logarithm of x. This is usually more accurate than log(x, 10).
(For vectors applied to each element.)
- httk.core.vectors.vectormath.pow(x: Any, y: Any, **args: Any) Any[source]¶
Return x raised to the power y. Equivalent with x**y.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.sqrt(x: Any, **args: Any) Any[source]¶
Return the square root of x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.acos(x: Any, **args: Any) Any[source]¶
Return the arc cosine of x, in radians.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.asin(x: Any, **args: Any) Any[source]¶
Return the arc sine of x, in radians.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.atan(x: Any, **args: Any) Any[source]¶
Return the arc tangent of x, in radians.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.atan2(y: Any, x: Any, **args: Any) Any[source]¶
Return atan(y / x), in radians, with the standard
atan2(y, x)argument order used bymath.atan2(), numpy, andhttk.core.vectors.exactmath.atan2(). The result is between -pi and pi. The point of atan2() is that the signs of both inputs are known to it, so it can compute the correct quadrant for the angle.(For vectors applied to each element.)
- httk.core.vectors.vectormath.cos(x: Any, **args: Any) Any[source]¶
Return the cosine of x radians.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.hypot(x: Any, y: Any, **args: Any) Any[source]¶
Return the Euclidean norm, sqrt(x*x + y*y). This is the length of the vector from the origin to point (x, y).
(For vectors applied to each element.)
- httk.core.vectors.vectormath.sin(x: Any, **args: Any) Any[source]¶
Return the sine of x radians.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.tan(x: Any, **args: Any) Any[source]¶
Return the tangent of x radians.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.degrees(x: Any, **args: Any) Any[source]¶
Convert angle x from radians to degrees.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.radians(x: Any, **args: Any) Any[source]¶
Convert angle x from degrees to radians.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.acosh(x: Any, **args: Any) Any[source]¶
Return the inverse hyperbolic cosine of x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.asinh(x: Any, **args: Any) Any[source]¶
Return the inverse hyperbolic sine of x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.atanh(x: Any, **args: Any) Any[source]¶
Return the inverse hyperbolic tangent of x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.cosh(x: Any, **args: Any) Any[source]¶
Return the hyperbolic cosine of x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.sinh(x: Any, **args: Any) Any[source]¶
Return the hyperbolic sine of x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.tanh(x: Any, **args: Any) Any[source]¶
Return the hyperbolic tangent of x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.erf(x: Any, **args: Any) Any[source]¶
Return the error function at x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.erfc(x: Any, **args: Any) Any[source]¶
Return the complementary error function at x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.gamma(x: Any, **args: Any) Any[source]¶
Return the Gamma function at x.
(For vectors applied to each element.)
- httk.core.vectors.vectormath.lgamma(x: Any, **args: Any) Any[source]¶
Return the natural logarithm of the absolute value of the Gamma function at x.
(For vectors applied to each element.)