TorchLean API

NN.Floats.Calc.Operations

Exact Operations on Mantissa/Exponent Values #

These operations manipulate NeuralFloat representations without rounding. Addition aligns both operands to their smaller exponent; multiplication adds exponents. Their correctness theorems are radix-parametric counterparts of Flocq's Calc.Operations results.

Integer radix powers agree with real radix powers at nonnegative exponents.

Two integer mantissas expressed on a common exponent grid.

  • leftMantissa :

    First aligned mantissa.

  • rightMantissa :

    Second aligned mantissa.

  • exponent :

    Common exponent, equal to the smaller input exponent.

Instances For

    Align two representations to the smaller exponent without changing their real values.

    Instances For
      theorem TorchLean.Floats.NeuralFloat.align_toReal {β : NeuralRadix} (f g : NeuralFloat β) :
      neuralToReal f = neuralToReal { mantissa := (f.align g).leftMantissa, exponent := (f.align g).exponent } neuralToReal g = neuralToReal { mantissa := (f.align g).rightMantissa, exponent := (f.align g).exponent }

      Alignment preserves both represented real values.

      Alignment selects the minimum input exponent.

      Exact negation of a mantissa/exponent representation.

      Instances For

        Exact absolute value of a mantissa/exponent representation.

        Instances For

          Exact addition after exponent alignment.

          Instances For

            Exact subtraction after exponent alignment.

            Instances For

              Exact multiplication of mantissas with exponent addition.

              Instances For