本文整理汇总了Python中sage.matrix.constructor.Matrix.inverse方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.inverse方法的具体用法?Python Matrix.inverse怎么用?Python Matrix.inverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.matrix.constructor.Matrix
的用法示例。
在下文中一共展示了Matrix.inverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parametrization
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import inverse [as 别名]
def parametrization(self, point=None, morphism=True):
r"""
Return a parametrization `f` of ``self`` together with the
inverse of `f`.
If ``point`` is specified, then that point is used
for the parametrization. Otherwise, use ``self.rational_point()``
to find a point.
If ``morphism`` is True, then `f` is returned in the form
of a Scheme morphism. Otherwise, it is a tuple of polynomials
that gives the parametrization.
ALGORITHM:
Uses the PARI/GP function ``qfparam``.
EXAMPLES ::
sage: c = Conic([1,1,-1])
sage: c.parametrization()
(Scheme morphism:
From: Projective Space of dimension 1 over Rational Field
To: Projective Conic Curve over Rational Field defined by x^2 + y^2 - z^2
Defn: Defined on coordinates by sending (x : y) to
(2*x*y : x^2 - y^2 : x^2 + y^2),
Scheme morphism:
From: Projective Conic Curve over Rational Field defined by x^2 + y^2 - z^2
To: Projective Space of dimension 1 over Rational Field
Defn: Defined on coordinates by sending (x : y : z) to
(1/2*x : -1/2*y + 1/2*z))
An example with ``morphism = False`` ::
sage: R.<x,y,z> = QQ[]
sage: C = Curve(7*x^2 + 2*y*z + z^2)
sage: (p, i) = C.parametrization(morphism = False); (p, i)
([-2*x*y, x^2 + 7*y^2, -2*x^2], [-1/2*x, 1/7*y + 1/14*z])
sage: C.defining_polynomial()(p)
0
sage: i[0](p) / i[1](p)
x/y
A ``ValueError`` is raised if ``self`` has no rational point ::
sage: C = Conic(x^2 + 2*y^2 + z^2)
sage: C.parametrization()
Traceback (most recent call last):
...
ValueError: Conic Projective Conic Curve over Rational Field defined by x^2 + 2*y^2 + z^2 has no rational points over Rational Field!
A ``ValueError`` is raised if ``self`` is not smooth ::
sage: C = Conic(x^2 + y^2)
sage: C.parametrization()
Traceback (most recent call last):
...
ValueError: The conic self (=Projective Conic Curve over Rational Field defined by x^2 + y^2) is not smooth, hence does not have a parametrization.
"""
if (not self._parametrization is None) and not point:
par = self._parametrization
else:
if not self.is_smooth():
raise ValueError("The conic self (=%s) is not smooth, hence does not have a parametrization." % self)
if point is None:
point = self.rational_point()
point = Sequence(point)
Q = PolynomialRing(QQ, 'x,y')
[x, y] = Q.gens()
gens = self.ambient_space().gens()
M = self.symmetric_matrix()
M *= lcm([ t.denominator() for t in M.list() ])
par1 = qfparam(M, point)
B = Matrix([[par1[i][j] for j in range(3)] for i in range(3)])
# self is in the image of B and does not lie on a line,
# hence B is invertible
A = B.inverse()
par2 = [sum([A[i,j]*gens[j] for j in range(3)]) for i in [1,0]]
par = ([Q(pol(x/y)*y**2) for pol in par1], par2)
if self._parametrization is None:
self._parametrization = par
if not morphism:
return par
P1 = ProjectiveSpace(self.base_ring(), 1, 'x,y')
return P1.hom(par[0],self), self.Hom(P1)(par[1], check = False)
示例2: is_globally_equivalent_to
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import inverse [as 别名]
#.........这里部分代码省略.........
OUTPUT:
boolean, and optionally a matrix
EXAMPLES::
sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1])
sage: M = Matrix(ZZ, 4, 4, [1,2,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1])
sage: Q1 = Q(M)
sage: Q.(Q1) # optional -- souvigner
True
sage: MM = Q.is_globally_equivalent_to(Q1, return_matrix=True) # optional -- souvigner
sage: Q(MM) == Q1 # optional -- souvigner
True
::
sage: Q1 = QuadraticForm(ZZ, 3, [1, 0, -1, 2, -1, 5])
sage: Q2 = QuadraticForm(ZZ, 3, [2, 1, 2, 2, 1, 3])
sage: Q3 = QuadraticForm(ZZ, 3, [8, 6, 5, 3, 4, 2])
sage: Q1.is_globally_equivalent_to(Q2) # optional -- souvigner
False
sage: Q1.is_globally_equivalent_to(Q3) # optional -- souvigner
True
sage: M = Q1.is_globally_equivalent_to(Q3, True) ; M # optional -- souvigner
[-1 -1 0]
[ 1 1 1]
[-1 0 0]
sage: Q1(M) == Q3 # optional -- souvigner
True
::
sage: Q = DiagonalQuadraticForm(ZZ, [1, -1])
sage: Q.is_globally_equivalent_to(Q)
Traceback (most recent call last):
...
ValueError: not a definite form in QuadraticForm.is_globally_equivalent_to()
"""
## only for definite forms
if not self.is_definite():
raise ValueError, "not a definite form in QuadraticForm.is_globally_equivalent_to()"
## Check that other is a QuadraticForm
#if not isinstance(other, QuadraticForm):
if not is_QuadraticForm(other):
raise TypeError, "Oops! You must compare two quadratic forms, but the argument is not a quadratic form. =("
## Now use the Souvigner code by default! =)
return other.is_globally_equivalent__souvigner(self, return_matrix) ## Note: We switch this because the Souvigner code has the opposite mapping convention to us. (It takes the second argument to the first!)
## ---------------------------------- Unused Code below ---------------------------------------------------------
## Check if the forms are locally equivalent
if (check_local_equivalence == True):
if not self.is_locally_equivalent_to(other):
return False
## Check that the forms have the same theta function up to the desired precision (this can be set so that it determines the cusp form)
if check_theta_to_precision != None:
if self.theta_series(check_theta_to_precision, var_str='', safe_flag=False) != other.theta_series(check_theta_to_precision, var_str='', safe_flag=False):
return False
## Make all possible matrices which give an isomorphism -- can we do this more intelligently?
## ------------------------------------------------------------------------------------------
## Find a basis of short vectors for one form, and try to match them with vectors of that length in the other one.
basis_for_self, self_lengths = self.basis_of_short_vectors(show_lengths=True)
max_len = max(self_lengths)
short_vectors_of_other = other.short_vector_list_up_to_length(max_len + 1)
## Make the matrix A:e_i |--> v_i to our new basis.
A = Matrix(basis_for_self).transpose()
Q2 = A.transpose() * self.matrix() * A ## This is the matrix of 'self' in the new basis
Q3 = other.matrix()
## Determine all automorphisms
n = self.dim()
Auto_list = []
## DIAGNOSTIC
#print "n = " + str(n)
#print "pivot_lengths = " + str(pivot_lengths)
#print "vector_list_by_length = " + str(vector_list_by_length)
#print "length of vector_list_by_length = " + str(len(vector_list_by_length))
for index_vec in mrange([len(short_vectors_of_other[self_lengths[i]]) for i in range(n)]):
M = Matrix([short_vectors_of_other[self_lengths[i]][index_vec[i]] for i in range(n)]).transpose()
if M.transpose() * Q3 * M == Q2:
if return_matrix:
return A * M.inverse()
else:
return True
## If we got here, then there is no isomorphism
return False