symforce.logic module¶
Functions for dealing with logical operations represented by scalars
- is_positive(x)[source]¶
Returns 1 if x is positive, 0 otherwise
- Parameters:
x (
float
) –- Return type:
float
- is_negative(x)[source]¶
Returns 1 if x is negative, 0 otherwise
- Parameters:
x (
float
) –- Return type:
float
- is_nonnegative(x)[source]¶
Returns 1 if x is >= 0, 0 if x is negative
- Parameters:
x (
float
) –- Return type:
float
- is_nonpositive(x)[source]¶
Returns 1 if x is <= 0, 0 if x is positive
- Parameters:
x (
float
) –- Return type:
float
- less_equal(x, y)[source]¶
Returns 1 if x <= y, 0 otherwise
- Parameters:
x (
float
) –y (
float
) –
- Return type:
float
- greater_equal(x, y)[source]¶
Returns 1 if x >= y, 0 otherwise
- Parameters:
x (
float
) –y (
float
) –
- Return type:
float
- less(x, y)[source]¶
Returns 1 if x < y, 0 otherwise
- Parameters:
x (
float
) –y (
float
) –
- Return type:
float
- greater(x, y)[source]¶
Returns 1 if x > y, 0 otherwise
- Parameters:
x (
float
) –y (
float
) –
- Return type:
float
- logical_and(*args, unsafe=False)[source]¶
Logical and of two or more Scalars
Input values are treated as true if they are positive, false if they are 0 or negative. The returned value is 1 for true, 0 for false.
If unsafe is True, the resulting expression is fewer ops but assumes the inputs are exactly 0 or 1; results for other (finite) inputs will be finite, but are otherwise undefined.
- Parameters:
args (
float
) –unsafe (
bool
) –
- Return type:
float
- logical_or(*args, unsafe=False)[source]¶
Logical or of two or more Scalars
Input values are treated as true if they are positive, false if they are 0 or negative. The returned value is 1 for true, 0 for false.
If unsafe is True, the resulting expression is fewer ops but assumes the inputs are exactly 0 or 1; results for other (finite) inputs will be finite, but are otherwise undefined.
- Parameters:
args (
float
) –unsafe (
bool
) –
- Return type:
float
- logical_not(a, unsafe=False)[source]¶
Logical not of a Scalar
Input value is treated as true if it is positive, false if it is 0 or negative. The returned value is 1 for true, 0 for false.
If unsafe is True, the resulting expression is fewer ops but assumes the inputs are exactly 0 or 1; results for other (finite) inputs will be finite, but are otherwise undefined.
- Parameters:
a (
float
) –unsafe (
bool
) –
- Return type:
float