@@ -22,50 +22,3 @@ def solve_int(A: Tensor, B: Tensor, tol=1e-9) -> Tensor | None:
2222
2323 # TODO: Verify that the round operation cannot fail
2424 return X_rounded .to (torch .int64 )
25-
26-
27- def mod_c (t1 : Tensor , t2 : Tensor ) -> Tensor :
28- """
29- Computes the combined modulo r = t1 %c t2, such that
30- t1 = d * t2 + r with d = t1 //c t2 and
31- 0 <= r[i] <= t1[i] for all i.
32-
33- :param t1: Non-negative integer vector.
34- :param t2: Non-negative integer vector.
35-
36- Examples:
37- [8, 12]^T %c [2, 3]^T = [0, 0]^T
38- [8, 12]^T %c [2, 4]^T = [2, 0]^T
39- [8, 12]^T %c [3, 3]^T = [2, 6]^T
40- [8, 12]^T %c [2, 0]^T = [0, 12]^T
41- [8, 12]^T %c [0, 2]^T = [8, 0]^T
42- [8, 12]^T %c [0, 0]^T => ZeroDivisionError
43- """
44-
45- return t1 - intdiv_c (t1 , t2 ) * t2
46-
47-
48- def intdiv_c (t1 : Tensor , t2 : Tensor ) -> Tensor :
49- """
50- Computes the combined integer division d = t1 // t2, such that
51- t1 = d * t2 + r with r = t1 %c t2
52- 0 <= r[i] <= t1[i] for all i.
53-
54- :param t1: Non-negative integer vector.
55- :param t2: Non-negative integer vector.
56-
57- Examples:
58- [8, 12]^T //c [2, 3]^T = 4
59- [8, 12]^T //c [2, 4]^T = 3
60- [8, 12]^T //c [3, 3]^T = 2
61- [8, 12]^T //c [2, 0]^T = 4
62- [8, 12]^T //c [0, 2]^T = 6
63- [8, 12]^T //c [0, 0]^T => ZeroDivisionError
64- """
65-
66- non_zero_indices = torch .nonzero (t2 )
67- if len (non_zero_indices ) == 0 :
68- raise ZeroDivisionError ("division by zero" )
69- else :
70- min_divider = (t1 [non_zero_indices ] // t2 [non_zero_indices ]).min ()
71- return min_divider
0 commit comments