(self)
return type(self)(ret)
Return the exponentiation of a square matrix.
Return the exponentiation of a square matrix.
Return the exponentiation of a square matrix .
def exp(self):
        """Return the exponentiation of a square matrix."""
        if not self.is_square:
            raise NonSquareMatrixError(
                "Exponentiation is valid only for square matrices")
        try:
            P, cells = self.jordan_cells()
        except MatrixError:
            raise NotImplementedError("Exponentiation is implemented only for matrices for which the Jordan normal form can be computed")

        def _jblock_exponential(b):
            # This function computes the matrix exponential for one single Jordan block
            nr = b.rows
            l = b[0, 0]
            if nr == 1:
                res = C.exp(l)
            else:
                from sympy import eye
                # extract the diagonal part
                d = b[0, 0]*eye(nr)
                #and the nilpotent part
                n = b-d
                # compute its exponential
                nex = eye(nr)
                for i in range(1, nr):
                    nex = nex+n**i/factorial(i)
                # combine the two parts
                res = exp(b[0, 0])*nex
            return(res)

        blocks = list(map(_jblock_exponential, cells))
        from sympy.matrices import diag
        eJ = diag(* blocks)
        # n = self.rows
        ret = P*eJ*P.inv()
        return type(self)(ret)
def exp ( self ) : if not self . is_square : raise NonSquareMatrixError ( "Exponentiation is valid only for square matrices" ) try : P , cells = self . jordan_cells ( ) except MatrixError : raise NotImplementedError ( "Exponentiation is implemented only for matrices for which the Jordan normal form can be computed" ) def _jblock_exponential ( b ) : # This function computes the matrix exponential for one single Jordan block nr = b . rows l = b [ 0 , 0 ] if nr == 1 : res = C . exp ( l ) else : from sympy import eye # extract the diagonal part d = b [ 0 , 0 ] * eye ( nr ) #and the nilpotent part n = b - d # compute its exponential nex = eye ( nr ) for i in range ( 1 , nr ) : nex = nex + n ** i / factorial ( i ) # combine the two parts res = exp ( b [ 0 , 0 ] ) * nex return ( res ) blocks = list ( map ( _jblock_exponential , cells ) ) from sympy . matrices import diag eJ = diag ( * blocks ) # n = self.rows ret = P * eJ * P . inv ( ) return type ( self ) ( ret )