def power(a: AbstractMatrix, b: B.Numeric): if structured(a): warn_upmodule( f"Taking an element-wise power of {a}: converting to dense.", category=ToDenseWarning, ) return Dense(B.power(B.dense(a), b))
def power(a: Kronecker, b: B.Numeric): return Kronecker(B.power(a.left, b), B.power(a.right, b))
def power(a: UpperTriangular, b: B.Numeric): return UpperTriangular(B.power(a.mat, b))
def power(a: Constant, b: B.Numeric): return Constant(B.power(a.const, b), a.rows, a.cols)
def power(a: Diagonal, b: B.Numeric): return Diagonal(B.power(a.diag, b))
def __pow__(self, power, modulo=None): # TODO: Implement this. assert modulo is None, "Modulo in powers is not yet supported." return B.power(self, power)
def power2(x): return B.power(x, 2)