TorchLean API

FloatLib.Floats.Formats.FixedPoint.Bounded.Core

Bounded fixed-point execution #

A bounded fixed-point code stores its coefficient in FixedInt width and interprets that signed integer at a fixed radix scale. Arithmetic names state their overflow policy explicitly:

Multiplication composes scales: operands with p and q fractional digits produce p + q fractional digits. The destination width is independent of the two input widths.

@[reducible]
def FloatLib.Floats.Formats.FixedPoint.Bounded.Code (_radix : Numerics.Radix) (_fractionalDigits width : ) :

A signed width-bit coefficient interpreted with a fixed radix scale.

This is a transparent type definition rather than an abbreviation. It has exactly the FixedInt width runtime representation, while retaining the radix and scale in elaborated type expressions so proof-aware tooling can identify the numerical format.

Instances For
    @[reducible, inline]

    Natural scaling denominator of a fixed-point format.

    Instances For
      @[inline]

      Signed integer coefficient stored by a bounded fixed-point code.

      Instances For
        @[inline]

        Exact rational value of a bounded fixed-point code.

        Instances For
          @[inline]

          Encode an integer coefficient modulo 2 ^ width.

          Instances For
            @[inline]

            Addition modulo 2 ^ width.

            Instances For
              @[inline]

              Subtraction modulo 2 ^ width.

              Instances For
                @[inline]

                Multiplication modulo 2^outWidth.

                Both coefficients are resized in two's-complement form before the native BitVec product. This implements exact multiplication followed by centered reduction at the destination width.

                Instances For
                  @[inline]

                  Return the exact same-scale sum when it fits the signed coefficient width.

                  Instances For
                    @[inline]

                    Return the exact same-scale difference when it fits the signed coefficient width.

                    Instances For
                      @[inline]

                      Return the exact product when its coefficient fits outWidth signed bits.

                      Instances For
                        @[inline]

                        Same-scale addition with saturation at the signed coefficient bounds.

                        Instances For
                          @[inline]

                          Same-scale subtraction with saturation at the signed coefficient bounds.

                          Instances For
                            @[inline]

                            Product with its exact coefficient saturated to outWidth signed bits.

                            Instances For