def _fractional_power_pade(R, t, m):
 if ((m < 1) or (int(m) != m)):
  raise ValueError('expected a positive integer m')
 if (not ((-1) < t < 1)):
  raise ValueError('expected -1 < t < 1')
 R = np.asarray(R)
 if ((len(R.shape) != 2) or (R.shape[0] != R.shape[1])):
  raise ValueError('expected an upper triangular square matrix')
 (n, n) = R.shape
 ident = np.identity(n)
 Y = (R * _fractional_power_pade_constant((2 * m), t))
 for j in range(((2 * m) - 1), 0, (-1)):
  rhs = (R * _fractional_power_pade_constant(j, t))
  Y = solve_triangular((ident + Y), rhs)
 U = (ident + Y)
 if (not np.array_equal(U, np.triu(U))):
  raise Exception('internal inconsistency')
 return U

def _fractional_power_pade ( R , t , m ) : if ( ( m < 1 ) or ( int ( m ) != m ) ) : raise ValueError ( 'expected a positive integer m' ) if ( not ( ( - 1 ) < t < 1 ) ) : raise ValueError ( 'expected -1 < t < 1' ) R = np . asarray ( R ) if ( ( len ( R . shape ) != 2 ) or ( R . shape [ 0 ] != R . shape [ 1 ] ) ) : raise ValueError ( 'expected an upper triangular square matrix' ) ( n , n ) = R . shape ident = np . identity ( n ) Y = ( R * _fractional_power_pade_constant ( ( 2 * m ) , t ) ) for j in range ( ( ( 2 * m ) - 1 ) , 0 , ( - 1 ) ) : rhs = ( R * _fractional_power_pade_constant ( j , t ) ) Y = solve_triangular ( ( ident + Y ) , rhs ) U = ( ident + Y ) if ( not np . array_equal ( U , np . triu ( U ) ) ) : raise Exception ( 'internal inconsistency' ) return U
evaluate the pade approximation of a fractional matrix power .