本文整理汇总了Python中sage.matrix.constructor.Matrix.solve_right方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.solve_right方法的具体用法?Python Matrix.solve_right怎么用?Python Matrix.solve_right使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.matrix.constructor.Matrix
的用法示例。
在下文中一共展示了Matrix.solve_right方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: p_adic_l_invariant_additive
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import solve_right [as 别名]
def p_adic_l_invariant_additive(logA,logB, alpha, beta, Tmatrix):
K = logA.parent()
logA, logB = K(logA), K(logB)
x,y,z,t = Tmatrix.change_ring(K).list()
M = Matrix(K,2,2,[alpha,x*alpha+z*beta,beta, y*alpha+t*beta])
n = Matrix(K,2,1,[logA, logB])
return M.solve_right(n).list()
示例2: matrix_rep
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import solve_right [as 别名]
def matrix_rep(self,B=None):
r"""
Returns a matrix representation of ``self``.
"""
#Express the element in terms of the basis B
if B is None:
B = self._parent.basis()
A=Matrix(self._parent._R,self._parent.dimension(),self._parent.dimension(),[[b._val[ii,0] for b in B] for ii in range(self._depth)])
tmp=A.solve_right(self._val)
return tmp
示例3: __init__
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import solve_right [as 别名]
class _FiniteBasisConverter:
def __init__(self, P, comb_mod, basis):
r"""
Basis should be a finite set of polynomials
"""
self._poly_ring = P
self._module = comb_mod
self._basis = basis
max_deg = max([self._poly_ring(b).degree() for b in self._basis])
monoms = []
for b in self._basis:
poly = self._poly_ring(b)
monoms += poly.monomials()
monoms_list = tuple(Set(monoms))
# check if the basis represented in terms of Monomials is efficient
degs = [self._poly_ring(m).degree() for m in monoms]
min_deg, max_deg = min(degs), max(degs)
monoms_obj = Monomials(self._poly_ring, (min_deg, max_deg + 1))
if monoms_obj.cardinality() < 2 * len(monoms_list):
computational_basis = monoms_obj
else:
computational_basis = monoms_list
self._monomial_module = PolynomialFreeModule(
P=self._poly_ring, basis=computational_basis)
cols = [self._monomial_module(b).to_vector() for b in self._basis]
self._basis_mat = Matrix(cols).transpose()
if self._basis_mat.ncols() > self._basis_mat.rank():
raise ValueError(
"Basis polynomials are not linearly independent")
def convert(self, p):
r"""
Algorithm is to convert all polynomials into monomials and use
linear algebra to solve for the appropriate coefficients in this
common basis.
"""
try:
p_vect = self._monomial_module(p).to_vector()
decomp = self._basis_mat.solve_right(p_vect)
except ValueError:
raise ValueError(
"Value %s is not spanned by the basis polynomials" % p)
polys = [v[1] * self._module.monomial(v[0])
for v in zip(self._basis, decomp)]
module_p = sum(polys, self._module.zero())
return module_p
示例4: matrix_rep
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import solve_right [as 别名]
def matrix_rep(self,B=None):
r"""
EXAMPLES:
This example illustrates ...
::
"""
#Express the element in terms of the basis B
if(B is None):
B=self._parent.basis()
A=Matrix(self._parent._R,self._parent.dimension(),self._parent.dimension(),[[b._val[ii,0] for b in B] for ii in range(self._depth)])
tmp=A.solve_right(self._val)
return tmp
示例5: linear_relation
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import solve_right [as 别名]
def linear_relation(self, List, Psi, verbose=True, prec=None):
for Phi in List:
assert Phi.valuation() >= 0, "Symbols must be integral"
assert Psi.valuation() >= 0
R = self.base()
Rbase = R.base()
w = R.gen()
d = len(List)
if d == 0:
if Psi.is_zero():
return [None, R(1)]
else:
return [None, 0]
if prec is None:
M, var_prec = Psi.precision_absolute()
else:
M, var_prec = prec
p = self.prime()
V = R**d
RSR = LaurentSeriesRing(Rbase, R.variable_name())
VSR = RSR**self.source().ngens()
List_TMs = [VSR(Phi.list_of_total_measures()) for Phi in List]
Psi_TMs = VSR(Psi.list_of_total_measures())
A = Matrix(RSR, List_TMs).transpose()
try:
sol = V([vv.power_series() for vv in A.solve_right(Psi_TMs)])
except ValueError:
#try "least squares"
if verbose:
print "Trying least squares."
sol = (A.transpose() * A).solve_right(A.transpose() * Psi_TMs)
#check precision (could make this better, checking each power of w)
p_prec = M
diff = Psi_TMs - sum([sol[i] * List_TMs[i] for i in range(len(List_TMs))])
for i in diff:
for j in i.list():
if p_prec > j.valuation():
p_prec = j.valuation()
if verbose:
print "p-adic precision is now", p_prec
#Is this right?
sol = V([R([j.add_bigoh(p_prec) for j in i.list()]) for i in sol])
return [sol, R(-1)]
示例6: solve_coefficient_system
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import solve_right [as 别名]
def solve_coefficient_system(Q, equations, vars):
# NOTE: to make things easier (and uniform) in the univariate case a dummy
# variable is added to the polynomial ring. See compute_bd()
a = Q.gens()[:-1]
B = Q.base_ring()
# construct the coefficient system and right-hand side
system = [[e.coefficient({ai:1}) for ai in a] for e in equations]
rhs = [-e.constant_coefficient() for e in equations]
system = Matrix(B, system)
rhs = Matrix(B, rhs).transpose()
# we only allow unique solutions. return None if there are infinitely many
# solutions or if no solution exists. Sage will raise a ValueError in both
# circumstances
try:
sol = system.solve_right(rhs)
except ValueError:
return None
return sol