def _remainder_matrix_power_triu(T, t):
m_to_theta = {<EOL><NUM_LIT:1>: <NUM_LIT>,<EOL><NUM_LIT:2>: <NUM_LIT>,<EOL><NUM_LIT:3>: <NUM_LIT>,<EOL><NUM_LIT:4>: <NUM_LIT>,<EOL><NUM_LIT:5>: <NUM_LIT>,<EOL><NUM_LIT:6>: <NUM_LIT>,<EOL><NUM_LIT:7>: <NUM_LIT>,<EOL>}<EOL>n, n = T.shape<EOL>T0 = T<EOL>T0_diag = np.diag(T0)<EOL>if np.array_equal(T0, np.diag(T0_diag)):<EOL><INDENT>U = np.diag(T0_diag ** t)<EOL><DEDENT>else:<EOL><INDENT>R, s, m = _inverse_squaring_helper(T0, m_to_theta)<EOL>U = _fractional_power_pade(-R, t, m)<EOL>eivals = np.diag(T0)<EOL>has_principal_branch = all(x.real > <NUM_LIT:0> or x.imag != <NUM_LIT:0> for x in eivals)<EOL>for i in range(s, -<NUM_LIT:1>, -<NUM_LIT:1>):<EOL><INDENT>if i < s:<EOL><INDENT>U = U.dot(U)<EOL><DEDENT>else:<EOL><INDENT>if has_principal_branch:<EOL><INDENT>p = t * np.exp2(-i)<EOL>U[np.diag_indices(n)] = T0_diag ** p<EOL>for j in range(n-<NUM_LIT:1>):<EOL><INDENT>l1 = T0[j, j]<EOL>l2 = T0[j+<NUM_LIT:1>, j+<NUM_LIT:1>]<EOL>t12 = T0[j, j+<NUM_LIT:1>]<EOL>f12 = _fractional_power_superdiag_entry(l1, l2, t12, p)<EOL>U[j, j+<NUM_LIT:1>] = f12<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>if not np.array_equal(U, np.triu(U)):<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>return U<EOL>
Compute a fractional power of an upper triangular matrix.

The fractional power is restricted to fractions -1 < t < 1.
This uses algorithm (3.1) of [1]_.
The Pade approximation itself uses algorithm (4.1) of [2]_.

Parameters
----------
T : (N, N) array_like
    Upper triangular matrix whose fractional power to evaluate.
t : float
    Fractional power between -1 and 1 exclusive.

Returns
-------
X : (N, N) array_like
    The fractional power of the matrix.

References
----------
.. [1] Nicholas J. Higham and Lijing Lin (2013)
       "An Improved Schur-Pade Algorithm for Fractional Powers
       of a Matrix and their Frechet Derivatives."

.. [2] Nicholas J. Higham and Lijing lin (2011)
       "A Schur-Pade Algorithm for Fractional Powers of a Matrix."
       SIAM Journal on Matrix Analysis and Applications,
       32 (3). pp. 1056-1078. ISSN 0895-4798