def _solve_P_Q(U, V, structure=None):
 P = (U + V)
 Q = ((- U) + V)
 if isspmatrix(U):
  return spsolve(Q, P)
 elif (structure is None):
  return solve(Q, P)
 elif (structure == UPPER_TRIANGULAR):
  return solve_triangular(Q, P)
 else:
  raise ValueError(('unsupported matrix structure: ' + str(structure)))

def _solve_P_Q ( U , V , structure = None ) : P = ( U + V ) Q = ( ( - U ) + V ) if isspmatrix ( U ) : return spsolve ( Q , P ) elif ( structure is None ) : return solve ( Q , P ) elif ( structure == UPPER_TRIANGULAR ) : return solve_triangular ( Q , P ) else : raise ValueError ( ( 'unsupported matrix structure: ' + str ( structure ) ) )
a helper function for expm_2009 .