TorchLean API

FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.Runtime

Mixed-format P3109 arithmetic #

The source types select exact decoders; finite values are embedded into Rat. Thus a configured IEEE accumulator, a P3109 operand, and an exact rational can occur in one expression. IEEE negative zero loses its sign in this domain, as required by §4.8.1. Every exceptional observation becomes the report's one NaN.

Destination supplies the final report projection. Destination.p3109 selects any P3109 descriptor. External destinations are provided separately, so importing this module installs no alternative IEEE arithmetic or conversion instances. The operation always evaluates the whole closed expression before projecting, including fused add-add and scaled arithmetic.

Reference: P3109 unapproved interim report 4.0.3, revision 34f5964, §§4.5, 4.8–4.10 and 5.8.

Canonicalize exceptions to the report's sole NaN datum.

Instances For

    An explicit final report projection, kept separate from ordinary destination conversion.

    Instances For

      A P3109 result format with its complete report projection policy.

      Instances For
        @[inline]
        def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.decode {Source SourceExact : Type} [ExecFloat.ExactDecoder Source SourceExact] [ExecFloat.ExactMap SourceExact ] (value : Source) :

        Decode through the source's exact interface and discard IEEE zero signs and NaN metadata.

        Instances For
          @[inline]
          def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.convert {Source SourceExact Result : Type} [ExecFloat.ExactDecoder Source SourceExact] [ExecFloat.ExactMap SourceExact ] (destination : Destination Result) (policy : ProjectionPolicy) (value : Source) :
          Result

          Conversion from an independently typed source through one destination projection.

          Instances For
            @[inline]
            def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.unary {Source SourceExact Result : Type} [ExecFloat.ExactDecoder Source SourceExact] [ExecFloat.ExactMap SourceExact ] (destination : Destination Result) (policy : ProjectionPolicy) (operation : Numerics.NumericalValue Numerics.NumericalValue ) (value : Source) :
            Result

            Apply a closed unary operation before the destination projection.

            Instances For
              @[inline]
              def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.binary {Left LeftExact Right RightExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] (destination : Destination Result) (policy : ProjectionPolicy) (operation : Numerics.NumericalValue Numerics.NumericalValue Numerics.NumericalValue ) (left : Left) (right : Right) :
              Result

              Apply a closed binary operation to independently typed operands, then project once.

              Instances For
                @[inline]
                def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.ternary {Left LeftExact Right RightExact Third ThirdExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] [ExecFloat.ExactDecoder Third ThirdExact] [ExecFloat.ExactMap ThirdExact ] (destination : Destination Result) (policy : ProjectionPolicy) (operation : Numerics.NumericalValue Numerics.NumericalValue Numerics.NumericalValue Numerics.NumericalValue ) (left : Left) (right : Right) (third : Third) :
                Result

                Evaluate a complete ternary closed expression before the sole destination projection.

                Instances For
                  @[inline]
                  def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.recip {Source SourceExact Result : Type} [ExecFloat.ExactDecoder Source SourceExact] [ExecFloat.ExactMap SourceExact ] (destination : Destination Result) (policy : ProjectionPolicy) (value : Source) :
                  Result

                  Mixed reciprocal; zero maps to NaN before projection.

                  Instances For
                    @[inline]
                    def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.add {Left LeftExact Right RightExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] (destination : Destination Result) (policy : ProjectionPolicy) (left : Left) (right : Right) :
                    Result

                    Mixed addition, retaining closed-domain infinities and NaN.

                    Instances For
                      @[inline]
                      def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.sub {Left LeftExact Right RightExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] (destination : Destination Result) (policy : ProjectionPolicy) (left : Left) (right : Right) :
                      Result

                      Mixed subtraction with no intermediate rounding.

                      Instances For
                        @[inline]
                        def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.mul {Left LeftExact Right RightExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] (destination : Destination Result) (policy : ProjectionPolicy) (left : Left) (right : Right) :
                        Result

                        Mixed multiplication with no intermediate rounding.

                        Instances For
                          @[inline]
                          def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.div {Left LeftExact Right RightExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] (destination : Destination Result) (policy : ProjectionPolicy) (left : Left) (right : Right) :
                          Result

                          Mixed division with the report's zero-denominator rule.

                          Instances For
                            @[inline]
                            def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.fma {Left LeftExact Right RightExact Third ThirdExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] [ExecFloat.ExactDecoder Third ThirdExact] [ExecFloat.ExactMap ThirdExact ] (destination : Destination Result) (policy : ProjectionPolicy) (left : Left) (right : Right) (addend : Third) :
                            Result

                            Mixed fused multiply-add, including an independently typed accumulator.

                            Instances For
                              @[inline]
                              def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.faa {Left LeftExact Right RightExact Third ThirdExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] [ExecFloat.ExactDecoder Third ThirdExact] [ExecFloat.ExactMap ThirdExact ] (destination : Destination Result) (policy : ProjectionPolicy) (left : Left) (middle : Right) (right : Third) :
                              Result

                              Mixed fused add-add; neither addition is rounded before the result projection.

                              Instances For
                                @[inline]
                                def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.scaledBinary {Left LeftExact Right RightExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] {LeftScale LeftScaleExact RightScale RightScaleExact : Type} [ExecFloat.ExactDecoder LeftScale LeftScaleExact] [ExecFloat.ExactMap LeftScaleExact ] [ExecFloat.ExactDecoder RightScale RightScaleExact] [ExecFloat.ExactMap RightScaleExact ] (destination : Destination Result) (policy : ProjectionPolicy) (operation : Numerics.NumericalValue Numerics.NumericalValue Numerics.NumericalValue ) (leftScale : LeftScale) (left : Left) (rightScale : RightScale) (right : Right) :
                                Result

                                Scaled binary operation from §5.8, with an implicit exact result scale of one.

                                Input scaling is closed multiplication: a zero scale times infinity is NaN, and a NaN scale propagates even when its element is zero. The complete scaled expression is projected once.

                                Instances For
                                  @[inline]
                                  def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.scaledAdd {Left LeftExact Right RightExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] {LeftScale LeftScaleExact RightScale RightScaleExact : Type} [ExecFloat.ExactDecoder LeftScale LeftScaleExact] [ExecFloat.ExactMap LeftScaleExact ] [ExecFloat.ExactDecoder RightScale RightScaleExact] [ExecFloat.ExactMap RightScaleExact ] (destination : Destination Result) (policy : ProjectionPolicy) (leftScale : LeftScale) (left : Left) (rightScale : RightScale) (right : Right) :
                                  Result

                                  Add two exactly scaled operands and project once.

                                  Instances For
                                    @[inline]
                                    def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.scaledSub {Left LeftExact Right RightExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] {LeftScale LeftScaleExact RightScale RightScaleExact : Type} [ExecFloat.ExactDecoder LeftScale LeftScaleExact] [ExecFloat.ExactMap LeftScaleExact ] [ExecFloat.ExactDecoder RightScale RightScaleExact] [ExecFloat.ExactMap RightScaleExact ] (destination : Destination Result) (policy : ProjectionPolicy) (leftScale : LeftScale) (left : Left) (rightScale : RightScale) (right : Right) :
                                    Result

                                    Subtract two exactly scaled operands and project once.

                                    Instances For
                                      @[inline]
                                      def FloatLib.Floats.Formats.P3109.Arithmetic.Mixed.scaledMul {Left LeftExact Right RightExact Result : Type} [ExecFloat.ExactDecoder Left LeftExact] [ExecFloat.ExactMap LeftExact ] [ExecFloat.ExactDecoder Right RightExact] [ExecFloat.ExactMap RightExact ] {LeftScale LeftScaleExact RightScale RightScaleExact : Type} [ExecFloat.ExactDecoder LeftScale LeftScaleExact] [ExecFloat.ExactMap LeftScaleExact ] [ExecFloat.ExactDecoder RightScale RightScaleExact] [ExecFloat.ExactMap RightScaleExact ] (destination : Destination Result) (policy : ProjectionPolicy) (leftScale : LeftScale) (left : Left) (rightScale : RightScale) (right : Right) :
                                      Result

                                      Multiply two exactly scaled operands and project once.

                                      Instances For