geoclide.mathope module#
- geoclide.mathope.clamp(val, val_min, val_max)#
Clamps val into the range [val_min, val_max]
- Parameters:
- valfloat
The scalar to be clamped
- val_minfloat
The minumum value
- val_maxfloat
The maximum value
- Returns:
- outfloat
The result of the clamp
Examples
>>> import geoclide as gc >>> gc.clamp(4, val_min=5, val_max=11) 5
- geoclide.mathope.quadratic(a, b, c)#
Resolve the quadratic polynomial: ax**2 + bx + c
where x is the quadratic polynomial variable and a, b and c the coefficients
- Parameters:
- afloat | 1-D ndarray
The first coefficient(s) of the quadratic polynomial
- bfloat | 1-D ndarray
The second coefficient(s) of the quadratic polynomial
- cfloat | 1-D ndarray
The third coefficient(s) of the quadratic polynomial
- Returns:
- bbool | 1-D ndarray
If the quadratic can be solved return True, else False
- x0float | None | 1-D ndarray
The first solution(s)
- x1float | None | 1-D ndarray
The second solution(s)
Notes
If There are 2 solutions x0 < x1. And if there is only one solution x0 = x1.
Examples
>>> import geoclide as gc >>> a = 2 >>> b = -5 >>> c = 0 >>> gc.quadratic(a, b, c) (True, 0.0, 2.5)