R. Perry, July 2018 corvids/diophantine.py is modified from Diophantine-master/diophantine.py: carriage returns added at end of line, range() changed to xrange(), class and OO stuff added, self, etc., getBasis() added (similar to solve()) bug in corvids lllhermite() ? diff -w corvids/diophantine.py corvids/Diophantine-master/diophantine.py ... 142,145c125,128 < A, B, L, D = self.initialise_working_matrices(G) < if self.first_nonzero_is_negative(A): < B[m, m] = -1 < A[m, :] *= -1 --- > A, B, L, D = initialise_working_matrices(G) > if first_nonzero_is_negative(A): > B[m - 1, m - 1] = -1 > A[m - 1, :] *= -1 if self.first_nonzero_is_negative(A) returns True, B[m,m] and A[m,:] are indexed out of range ### Changes in corvids-RP/ diophantine.py modified from ../corvids/ for python3, and removed ^M xrange() -> range() zip() -> list(zip()) ### % diff -w diophantine.py ../corvids/diophantine.py 1d0 < # slightly modified copy of diophantine.py from https://github.com/katherinemwood/corvids 56c55 < return [(i, j) for i, j in product(range(m.shape[0]), range(m.shape[1])) --- > return [(i, j) for i, j in product(xrange(m.shape[0]), xrange(m.shape[1])) 103,104c102 < solutions = []; solutions.append(-P[r,:-1].T) # RP, list of Matrix < # raise NotImplementedError("Ax=B has unique solution in integers") --- > raise NotImplementedError("Ax=B has unique solution in integers") 146,147c144,145 < B[m-1, m-1] = -1 < A[m-1, :] *= -1 --- > B[m, m] = -1 > A[m, :] *= -1 159c157 < for i in reversed(range(k - 1)): --- > for i in reversed(xrange(k - 1)): 163c161 < rank = A.shape[0] - next(i for i in range(A.shape[0]) --- > rank = A.shape[0] - next(i for i in xrange(A.shape[0]) 189c187 < nonzero_columns = list(zip(*self.nonzero(A)))[1] # Should always be nonzero --- > nonzero_columns = zip(*self.nonzero(A))[1] # Should always be nonzero 199c197 < nonzero_i_elems = list(zip(*self.nonzero(A[i, :]))) --- > nonzero_i_elems = zip(*self.nonzero(A[i, :])) 208c206 < nonzero_k_elems = list(zip(*self.nonzero(A[k, :]))) --- > nonzero_k_elems = zip(*self.nonzero(A[k, :])) 263c261 < for i in range(m): --- > for i in xrange(m): 298c296 < for j in range(i, m): --- > for j in xrange(i, m): 326,327c324,325 < for i in range(m - 1): < for j in range(i + 1, m): --- > for i in xrange(m - 1): > for j in xrange(i + 1, m): 332,333c330,331 < for k in range(i + 1, m): < for l in range(k, m): --- > for k in xrange(i + 1, m): > for l in xrange(k, m): 345,346c343,344 < for i in range(m): < for j in range(m): --- > for i in xrange(m): > for j in xrange(m): 438c436 < for j in range(n): --- > for j in xrange(n): %