本文整理汇总了Python中sage.matrix.constructor.Matrix.block方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.block方法的具体用法?Python Matrix.block怎么用?Python Matrix.block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.matrix.constructor.Matrix
的用法示例。
在下文中一共展示了Matrix.block方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import block [as 别名]
def __init__(self, X, varNames="x", externalBasisMatrix=None):
if externalBasisMatrix is None:
externalBasisMatrix = X.column_space().basis_matrix().transpose()
else:
if X.column_space() != externalBasisMatrix.column_space():
raise ValueError(
"ExternalZonotopalAlgebra: externalBasisMatrix must have"
" the same column space as X")
AbstractZonotopalAlgebra.__init__(self, X, varNames)
self._ext_basis_matrix = externalBasisMatrix
self._ext_block_matrix = Matrix.block([[X, self._ext_basis_matrix]])
self._embedding_central_za = CentralZonotopalAlgebra(
self._ext_block_matrix, varNames)
示例2: __getitem__
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import block [as 别名]
def __getitem__(self, key):
r"""
Return a slice of the sequence.
EXAMPLES::
sage: C.<x> = CFiniteSequences(QQ)
sage: r = C.from_recurrence([3,3],[2,1])
sage: r[2]
9
sage: r[101]
16158686318788579168659644539538474790082623100896663971001
sage: r = C(1/(1-x))
sage: r[5]
1
sage: r = C(x)
sage: r[0]
0
sage: r[1]
1
sage: r = C(0)
sage: r[66]
0
sage: lucas = C.from_recurrence([1,1],[2,1])
sage: lucas[5:10]
[11, 18, 29, 47, 76]
sage: r = C((2-x)/x/(1-x-x*x))
sage: r[0:4]
[1, 3, 4, 7]
sage: r = C(1-2*x^2)
sage: r[0:4]
[1, 0, -2, 0]
sage: r[-1:4] # not tested, python will not allow this!
[0, 1, 0 -2, 0]
sage: r = C((-2*x^3 + x^2 + 1)/(-2*x + 1))
sage: r[0:5] # handle ogf > 1
[1, 2, 5, 8, 16]
sage: r[-2]
0
sage: r = C((-2*x^3 + x^2 - x + 1)/(2*x^2 - 3*x + 1))
sage: r[0:5]
[1, 2, 5, 9, 17]
sage: s=C((1-x)/(-x^2 - x + 1))
sage: s[0:5]
[1, 0, 1, 1, 2]
sage: s=C((1+x^20+x^40)/(1-x^12)/(1-x^30))
sage: s[0:20]
[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0]
sage: s=C(1/((1-x^2)*(1-x^6)*(1-x^8)*(1-x^12)))
sage: s[999998]
289362268629630
"""
if isinstance(key, slice):
m = max(key.start, key.stop)
return [self[ii] for ii in xrange(*key.indices(m + 1))]
elif isinstance(key, (int, Integer)):
from sage.matrix.constructor import Matrix
d = self._deg
if self._off <= key and key < self._off + len(self._a):
return self._a[key - self._off]
elif d == 0:
return 0
(quo, rem) = self.numerator().quo_rem(self.denominator())
wp = quo[key - self._off]
if key < self._off:
return wp
A = Matrix(QQ, 1, d, self._c)
B = Matrix.identity(QQ, d - 1)
C = Matrix(QQ, d - 1, 1, 0)
if quo == 0:
V = Matrix(QQ, d, 1, self._a[:d][::-1])
else:
V = Matrix(QQ, d, 1, self._aa[:d][::-1])
M = Matrix.block([[A], [B, C]], subdivide=False)
return wp + list(M ** (key - self._off) * V)[d - 1][0]
else:
raise TypeError("invalid argument type")