Executable complex numbers over an arbitrary binary format #
ExecComplex fmt stores one Model fmt for each Cartesian component. The format parameter is
not fixed to binary32: the same definition supports binary16, bfloat16, binary64, binary128,
binary256, and custom exponent/fraction widths.
Complex multiplication uses four scalar multiplications followed by one subtraction and one
addition. This explicit evaluation order matters in floating-point arithmetic and is reflected by
the semantic theorem in Complex.Semantics.
Division uses the larger denominator component to form a ratio. Magnitude scales both components before squaring. These evaluation orders avoid squaring large unscaled components, but do not guarantee finite intermediates or correct rounding of the exact complex operation.
A complex value whose real and imaginary components share the binary format fmt.
Instances For
Instances For
Instances For
A complex value is finite exactly when both encoded components are finite.
Instances For
Componentwise sign negation.
Instances For
Componentwise floating-point addition.
Instances For
Componentwise floating-point subtraction.
Instances For
Real component of the specified non-fused complex product.
Instances For
Imaginary component of the specified non-fused complex product.
Instances For
Floating-point complex multiplication with an explicit non-fused evaluation order.
Each of the four component products is rounded in fmt; the real subtraction and imaginary
addition are then rounded once more in the same format.
Instances For
Conjugation negates the imaginary component using the format's zero and NaN conventions.
Instances For
Squared magnitude with two rounded squares followed by a rounded sum.
Instances For
Exchange the real and imaginary coordinates.
Instances For
The strict comparison chooses the real component on a tie or an unordered comparison.
Instances For
Ratio division with the real denominator component as pivot.
Every multiplication, sum, difference, and quotient is rounded separately.
Instances For
Larger component magnitude, with the real component selected on ties.
Instances For
Components divided by their common magnitude scale, each rounded once.
Instances For
Complex division by a component-ratio formula.
When the imaginary denominator component is larger, both inputs exchange coordinates and the computed quotient is conjugated. This includes an exact sign change after the final imaginary division. Scalar kernels determine exceptional results; there is no complex infinity recovery. Finite inputs alone do not exclude overflow, underflow, or a zero rounded denominator.
Instances For
Magnitude computed by scaling before squaring and restoring the scale after square root.
A zero scale returns positive zero on finite IEEE inputs. All finite arithmetic uses the component kernels; the result need not be one rounding of the exact norm. An infinite component gives positive infinity even when the other component is a quiet NaN. If either component is a signaling NaN, or neither is infinite, nonfinite inputs use the scalar sum of absolute components and its NaN selection and quieting policy.
The format must also have enough range for the normalized intermediate sum. For example,
FloatFormat.custom 2 2 2 .ieee maps (0.5, 0.5) to infinity because the normalized sum 2
overflows, although the nearest rounded exact norm is 0.75. This custom bias also fails
fmt.isIEEE; the finite rounded-semantics theorem does not apply.