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

logical_and(a, b, unsafe=False)[source]

Logical and of two 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:
  • a (float) –

  • b (float) –

  • unsafe (bool) –

Return type:

float

logical_or(a, b, unsafe=False)[source]

Logical or of two 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:
  • a (float) –

  • b (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