@@ -221,7 +221,7 @@ cdef class Matrix(Matrix1):
221221 return matrix([a.subs(*args, **kwds) for a in self.list()],
222222 nrows=self._nrows, ncols=self._ncols, sparse=False)
223223
224- def solve_left(self, B, check=True, *, integral=False ):
224+ def solve_left(self, B, check=True, *, extend=True ):
225225 r"""
226226 Try to find a solution `X` to the equation `X A = B`.
227227
@@ -239,11 +239,12 @@ cdef class Matrix(Matrix1):
239239
240240 - ``B`` -- a matrix or vector
241241
242- - ``integral`` -- boolean (default: ``False``); When the base
243- ring is a PID, request that a solution over the that ring
244- be returned. If there is no such solution, a ``ValueError``
245- is raised. A typical case are systems of non-full rank over
246- the integers.
242+ - ``extend`` -- boolean (default: ``True``); When set to ``True``,
243+ some solvers will return solutions over a larger ring than the
244+ base ring of the inputs (a typical case are rational solutions
245+ for integer linear systems). When set to ``False``, a solution
246+ over the base ring is returned, with a ``ValueError`` being
247+ raised if none exists.
247248
248249 - ``check`` -- boolean (default: ``True``); verify the answer
249250 if the system is non-square or rank-deficient, and if its
@@ -446,16 +447,16 @@ cdef class Matrix(Matrix1):
446447 """
447448 if is_Vector(B):
448449 try:
449- return self.transpose().solve_right(B, check=check, integral=integral )
450+ return self.transpose().solve_right(B, check=check, extend=extend )
450451 except ValueError as e:
451452 raise e.__class__(str(e).replace('row', 'column'))
452453 else:
453454 try:
454- return self.transpose().solve_right(B.transpose(), check=check, integral=integral ).transpose()
455+ return self.transpose().solve_right(B.transpose(), check=check, extend=extend ).transpose()
455456 except ValueError as e:
456457 raise e.__class__(str(e).replace('row', 'column'))
457458
458- def solve_right(self, B, check=True, *, integral=False ):
459+ def solve_right(self, B, check=True, *, extend=True ):
459460 r"""
460461 Try to find a solution `X` to the equation `A X = B`.
461462
@@ -473,11 +474,12 @@ cdef class Matrix(Matrix1):
473474
474475 - ``B`` -- a matrix or vector
475476
476- - ``integral`` -- boolean (default: ``False``); When the base
477- ring is a PID, request that a solution over the that ring
478- be returned. If there is no such solution, a ``ValueError``
479- is raised. A typical case are systems of non-full rank over
480- the integers.
477+ - ``extend`` -- boolean (default: ``True``); When set to ``True``,
478+ some solvers will return solutions over a larger ring than the
479+ base ring of the inputs (a typical case are rational solutions
480+ for integer linear systems). When set to ``False``, a solution
481+ over the base ring is returned, with a ``ValueError`` being
482+ raised if none exists.
481483
482484 - ``check`` -- boolean (default: ``True``); verify the answer
483485 if the system is non-square or rank-deficient, and if its
@@ -897,7 +899,7 @@ cdef class Matrix(Matrix1):
897899 L = B.base_ring()
898900 # first coerce both elements to parent over same base ring
899901 P = K if L is K else coercion_model.common_parent(K, L)
900- if P not in _Fields and P.is_integral_domain() and not integral :
902+ if P not in _Fields and P.is_integral_domain() and extend :
901903 # the non-integral-domain case is handled separatedly below
902904 P = P.fraction_field()
903905 if L is not P:
@@ -944,7 +946,7 @@ cdef class Matrix(Matrix1):
944946
945947 C = B.column() if b_is_vec else B
946948
947- if integral :
949+ if not extend :
948950 X = self._solve_right_smith_form(C)
949951 return X.column(0) if b_is_vec else X
950952
@@ -1084,12 +1086,12 @@ cdef class Matrix(Matrix1):
10841086 [ 2 12 2 17 16 37 32]
10851087 [32 37 16 17 2 12 2]
10861088 sage: y = vector(ZZ, [-4, -1, 1, 5, 14, 31, 4])
1087- sage: A.solve_left(y, integral=True ) # implicit doctest
1089+ sage: A.solve_left(y, extend=False ) # indirect doctest
10881090 (-1, 0, 1, 1, -1)
10891091 sage: z = vector(ZZ, [1, 2, 3, 4, 5])
1090- sage: A.solve_right(z, integral=True ) # implicit doctest
1092+ sage: A.solve_right(z, extend=False ) # indirect doctest
10911093 (10, 1530831087980480, -2969971929450215, -178745029498097, 2320752168397186, -806846536262381, -520939892126393)
1092- sage: A.solve_right(identity_matrix(ZZ,5), integral=True ) # implicit doctest
1094+ sage: A.solve_right(identity_matrix(ZZ,5), extend=False ) # indirect doctest
10931095 [ -1 0 2 0 1]
10941096 [-156182670342972 -2199494166584 310625144000132 1293916 151907461896112]
10951097 [ 303010665531453 4267248023008 -602645168043247 -2510332 -294716315371323]
0 commit comments