#NEWLINE# def _entry( self , i , j ) : #NEWLINE# #INDENT# A = self . doit ( ) #NEWLINE# if isinstance ( A , MatPow ) : #NEWLINE# #INDENT# if ( not A . base . is_square ) : #NEWLINE# #INDENT# raise ShapeError ( ( 'Power of non-square matrix %s' % A . base ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( A . exp . is_Integer and A . exp . is_positive ) : #NEWLINE# #INDENT# A = MatMul ( * [ self . base for k in range ( A . exp ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise NotImplementedError ( ( ( '(%d, %d) entry' % ( int ( i ) , int ( j ) ) ) + ' of matrix power either not defined or not implemented' ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return A . _entry ( i , j )