TorchLean API

NN.Core.Numeric.Quotient

Arithmetic for nested quotient rules #

Checked operations retain range-loss information until the complete quotient has been evaluated. The cold path evaluates the original finite coefficient trees over Rat, then rounds each coefficient through FloatLib to the requested format. This is scoped to one quotient: it cannot recover information lost before its inputs were formed.

Coefficients in the algebra generated by n commuting square-zero variables.

Instances For

    The caller checks that the denominator's primal is nonzero before entering this recursion.

    Instances For

      Operations used inside one complete quotient, together with finite coefficient conversion.

      Internal byte flags record nonfinite or subnormal results, including a nonzero product or quotient rounded to zero. Zero means no range loss; recursive carriers combine flags with bitwise OR. The checked-operation entrypoints expose the same Boolean result without converting at each internal node. Unsupported carriers use the ordinary operations and do not supply a conversion.

      Instances
        @[instance_reducible, instance 100]
        @[inline]
        Instances For
          @[inline]
          Instances For
            @[inline]
            Instances For
              @[inline]
              Instances For
                @[noinline]
                def TorchLean.Numeric.QuotientArithmetic.replay? {α : Type} {depth : } (encode : αOption (QuotientCoefficients depth)) (decode : QuotientCoefficients depthOption α) (x y : α) :

                Replay only finite input trees with an invertible denominator.

                Only coefficient conversion crosses this cold boundary, leaving the checked arithmetic operations available for specialization in the caller.

                Instances For
                  @[noinline, specialize #[0]]
                  Instances For
                    @[noinline, specialize #[0]]

                    Range flags for the actual native product z = x * y, using native zero equality. The open subnormal interval includes zero; nonzero inputs detect a product rounded to zero. This formula requires the actual product, not an independently supplied third value.

                    Instances For
                      @[noinline, specialize #[0]]

                      Range flags for the actual native quotient z = x / y, using native zero equality. A zero denominator already makes the result nonfinite. A zero or subnormal result with a nonzero numerator requires replay. This formula assumes z is the actual division result.

                      Instances For
                        @[noinline, specialize #[0]]
                        Instances For
                          @[noinline, specialize #[0]]

                          Range flags for the actual native product z = x * y, using native zero equality. The open subnormal interval includes zero; nonzero inputs detect a product rounded to zero. This formula requires the actual product, not an independently supplied third value.

                          Instances For
                            @[noinline, specialize #[0]]

                            Range flags for the actual native quotient z = x / y, using native zero equality. A zero denominator already makes the result nonfinite. A zero or subnormal result with a nonzero numerator requires replay. This formula assumes z is the actual division result.

                            Instances For

                              FloatLib exception status plus the stricter range predicate needed by a nested quotient.

                              IEEE underflow requires inexactness. An exact subnormal intermediate must also trigger replay, since subsequent multiplication or division can lose coefficients. Ordinary inexact rounding alone does not trigger replay.

                              Instances For
                                @[instance_reducible]

                                Configured IEEE values use FloatLib's nearest-even operations and exact finite decoder.

                                The complete derivative tree is replayed by the recursive Dual instance. Every coefficient is rounded independently to the original descriptor and storage plan, including formats wider than binary64. Finite-only encodings are not enabled: their saturation policy would require a separate derivative contract. True coefficients outside the IEEE range may still round to zero or infinity.