Class FpMulHardToDRoundIterator

  • All Implemented Interfaces:
    Iterator<GeneratorResult<FpNumber>>

    public final class FpMulHardToDRoundIterator
    extends java.lang.Object
    implements Iterator<GeneratorResult<FpNumber>>
    FpMulHardToDRoundIterator implements an iterator of hard-to-round test cases for the multiplication operation operating in the directed round modes (toward zero, toward plus infinity, and toward minus infinity).

    The implementation is based on the following work of Michael Parks:

    • M. Parks. Number-Theoretic Test Generation for Directed Rounding. IEEE Transactions on Computers, Volume 49. 2000.

    We seek n-bit integers x and y from 2^(n-1) + 1 to 2^n-1 whose product is as close as possible to a directed rounding boundary: x*y = 2^(n-i)*p + k, where i = 0 or 1, k is a small integer (positive or negative), and p is an n-bit integer.

    Given an odd y in [2^(n-1)+1, 2^n-1] and small k > 0 the algorithm is as follows:

    
     if k is even
       x_1 = 0
       p_1 = (1/2)*k
     else
       x_1 = 1
       p_1 = (1/2)*(y + k)
     end
    
     for j = 2 to n
       if p_(j-1) is even
         x_j = x_(j-1)
         p_j = (1/2)*p_(j-1)
       else
         x_j = 2^(j-1) + x_(j-1)
         p_j = (1/2) * (y + p_(j-1))
       end
    
     if (p_(n-1) <= 2^n - 1 - y) or (p_(n-1) is odd)
       x = 2^(n-1) + x_(n-1) // CASE 0
     end
    
     if p_(n-1) >= 2*y - 2^n + 1
       x = 2^n - x_(n-1) // CASE 1
     else if p_(n-1) is even
       x = 2^n - x_n // CASE 2
     end
     
    • Constructor Detail

      • FpMulHardToDRoundIterator

        public FpMulHardToDRoundIterator​(FpFormat format,
                                         long minY,
                                         long maxY,
                                         int numY,
                                         int maxK,
                                         int maxT)
        Constructs a square root hard-to-round iterator.
        Parameters:
        format - the format.
        minY - the minimal y value.
        maxY - the maximal y value.
        numY - the number of y values.
        maxK - the maximal k value.
        maxT - the maximal t value.
      • FpMulHardToDRoundIterator

        public FpMulHardToDRoundIterator​(FpFormat format)
        Constructs a square root hard-to-round iterator.
        Parameters:
        format - the format.