TorchLean API

NN.Floats.Calc.Arithmetic

Rounded Arithmetic on Mantissa/Exponent Values #

This module gathers the generic representation-level arithmetic. Addition, subtraction, and multiplication first use their exact NeuralFloat operations. Division and square root need not have finite radix expansions, so they are formed over the reals and rounded directly into the selected format.

These definitions model finite rounded arithmetic. IEEE exceptional behavior for zero divisors, negative square roots, infinities, and NaNs belongs to NN.Floats.IEEEExec.

noncomputable def TorchLean.Floats.NeuralFloat.addRounded {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) (f g : NeuralFloat β) :

Exact addition followed by rounding into the selected format.

Instances For
    noncomputable def TorchLean.Floats.NeuralFloat.subRounded {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) (f g : NeuralFloat β) :

    Exact subtraction followed by rounding into the selected format.

    Instances For
      noncomputable def TorchLean.Floats.NeuralFloat.mulRounded {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) (f g : NeuralFloat β) :

      Exact multiplication followed by rounding into the selected format.

      Instances For
        noncomputable def TorchLean.Floats.NeuralFloat.divRounded {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) (f g : NeuralFloat β) :

        Exact real division followed by rounding into the selected format.

        Instances For
          noncomputable def TorchLean.Floats.NeuralFloat.sqrtRounded {β : NeuralRadix} {fexp : } [NeuralValidExp fexp] (rnd : ) (f : NeuralFloat β) :

          Exact real square root followed by rounding into the selected format.

          Instances For

            A nonzero mantissa gives a nonzero represented real value.

            Squaring the exact quantity supplied to sqrtRounded recovers a nonnegative input.