Skip to main content

optionstratlib_math/geometrics/operations/
arithmetic.rs

1/// Represents mathematical or aggregation operations that can be applied
2/// during a merge or combination process of geometric objects or curves.
3///
4/// This enum defines the possible operations when merging or combining multiple
5/// data sets, such as curves or points. It is commonly used with the `Arithmetic` trait
6/// to specify how values should be combined during geometric operations.
7///
8/// # Operations
9///
10/// * `Add` - Performs addition of values (a + b)
11/// * `Subtract` - Performs subtraction of values (a - b)
12/// * `Multiply` - Performs multiplication of values (a * b)
13/// * `Divide` - Performs division of values (a / b), with appropriate error handling for division by zero
14/// * `Max` - Selects the maximum value between operands (max(a, b))
15/// * `Min` - Selects the minimum value between operands (min(a, b))
16///
17/// The operation specified will determine how values are combined when merging
18/// geometric objects that implement the `Arithmetic` trait.
19#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
20#[cfg_attr(feature = "schema", derive(utoipa::ToSchema))]
21#[repr(u8)]
22pub enum MergeOperation {
23    /// Adds values together (a + b)
24    Add,
25    /// Subtracts the second value from the first (a - b)
26    Subtract,
27    /// Multiplies values together (a * b)
28    Multiply,
29    /// Divides the first value by the second (a / b)
30    Divide,
31    /// Selects the maximum between values (max(a, b))
32    Max,
33    /// Selects the minimum between values (min(a, b))
34    Min,
35}