本文整理汇总了Python中sage.matrix.constructor.Matrix.__pow__方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.__pow__方法的具体用法?Python Matrix.__pow__怎么用?Python Matrix.__pow__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.matrix.constructor.Matrix
的用法示例。
在下文中一共展示了Matrix.__pow__方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FiniteDimensionalAlgebraElement
# 需要导入模块: from sage.matrix.constructor import Matrix [as 别名]
# 或者: from sage.matrix.constructor.Matrix import __pow__ [as 别名]
#.........这里部分代码省略.........
sage: C.basis()[1] * C.basis()[2]
e1
"""
return self.__class__(self.parent(), self._vector * other._matrix)
def _lmul_(self, other):
"""
TESTS::
sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,1,0], [0,0,1]])])
sage: c = C.random_element()
sage: c * 2 == c + c
True
"""
if not self.parent().base_ring().has_coerce_map_from(other.parent()):
raise TypeError("unsupported operand parent(s) for '*': '{}' and '{}'"
.format(self.parent(), other.parent()))
return self.__class__(self.parent(), self._vector * other)
def _rmul_(self, other):
"""
TESTS::
sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,0,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,1,0], [0,0,1]])])
sage: c = C.random_element()
sage: 2 * c == c + c
True
"""
if not self.parent().base_ring().has_coerce_map_from(other.parent()):
raise TypeError("unsupported operand parent(s) for '*': '{}' and '{}'"
.format(self.parent(), other.parent()))
return FiniteDimensionalAlgebraElement(self.parent(), other * self._vector) # Note the different order
def __pow__(self, n):
"""
Return ``self`` raised to the power ``n``.
EXAMPLES::
sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0,0], [0,1,0], [0,0,0]]), Matrix([[0,1,0], [0,0,0], [0,0,0]]), Matrix([[0,0,0], [0,0,0], [0,0,1]])])
sage: b = B(vector(QQ, [2,3,4]))
sage: b^6
64*e0 + 576*e1 + 4096*e2
"""
A = self.parent()
if not (A._assume_associative or A.is_associative()):
raise TypeError("algebra is not associative")
if n > 0:
return self.__class__(A, self.vector() * self._matrix.__pow__(n - 1))
if not A.is_unitary():
raise TypeError("algebra is not unitary")
if n == 0:
return A.one()
a = self.inverse()
return self.__class__(A, a.vector() * a.matrix().__pow__(-n - 1))
def is_invertible(self):
"""
Return ``True`` if ``self`` has a two-sided multiplicative
inverse.
.. NOTE::
If an element of a unitary finite-dimensional algebra over a field
admits a left inverse, then this is the unique left
inverse, and it is also a right inverse.