Module safe_ops

Module safe_ops 

Source
Expand description

Safe mathematical operations that handle edge cases and validate results

This module provides safe wrappers around common mathematical operations that can produce NaN, Infinity, or other invalid results.

Functionsยง

safe_divide
Safely divide two numbers, checking for division by zero and validating the result
safe_exp
Safely compute exponential, checking for overflow
safe_mean
Safely compute the mean of a slice, handling empty slices
safe_normalize
Safely normalize a value by dividing by a norm/magnitude
safe_pow
Safely compute power, checking for domain errors and overflow
safe_sqrt
Safely compute square root, checking for negative values
safe_variance
Safely compute variance, handling numerical issues
safelog
Safely compute natural logarithm, checking for non-positive values
safelog10
Safely compute base-10 logarithm