move GoldschmidtDivState
authorJacob Lifshay <programmerjake@gmail.com>
Thu, 28 Apr 2022 05:52:41 +0000 (22:52 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Thu, 28 Apr 2022 05:52:41 +0000 (22:52 -0700)
src/soc/fu/div/experiment/goldschmidt_div_sqrt.py

index e17f64c7280c1a30f9ba0c400e8fbbcd2888a202..c3837e9afc2f661ffc864d088d3ead1a3b0cd2ab 100644 (file)
@@ -315,35 +315,6 @@ class FixedPoint:
         return retval
 
 
-@dataclass
-class GoldschmidtDivState:
-    orig_n: int
-    """original numerator"""
-
-    orig_d: int
-    """original denominator"""
-
-    n: FixedPoint
-    """numerator -- N_prime[i] in the paper's algorithm 2"""
-
-    d: FixedPoint
-    """denominator -- D_prime[i] in the paper's algorithm 2"""
-
-    f: "FixedPoint | None" = None
-    """current factor -- F_prime[i] in the paper's algorithm 2"""
-
-    quotient: "int | None" = None
-    """final quotient"""
-
-    remainder: "int | None" = None
-    """final remainder"""
-
-    n_shift: "int | None" = None
-    """amount the numerator needs to be left-shifted at the end of the
-    algorithm.
-    """
-
-
 class ParamsNotAccurateEnough(Exception):
     """raised when the parameters aren't accurate enough to have goldschmidt
     division work."""
@@ -1005,6 +976,35 @@ class GoldschmidtDivOp(enum.Enum):
             assert False, f"unimplemented GoldschmidtDivOp: {self}"
 
 
+@dataclass
+class GoldschmidtDivState:
+    orig_n: int
+    """original numerator"""
+
+    orig_d: int
+    """original denominator"""
+
+    n: FixedPoint
+    """numerator -- N_prime[i] in the paper's algorithm 2"""
+
+    d: FixedPoint
+    """denominator -- D_prime[i] in the paper's algorithm 2"""
+
+    f: "FixedPoint | None" = None
+    """current factor -- F_prime[i] in the paper's algorithm 2"""
+
+    quotient: "int | None" = None
+    """final quotient"""
+
+    remainder: "int | None" = None
+    """final remainder"""
+
+    n_shift: "int | None" = None
+    """amount the numerator needs to be left-shifted at the end of the
+    algorithm.
+    """
+
+
 def goldschmidt_div(n, d, params):
     """ Goldschmidt division algorithm.