def _ell(A, m):
 if ((len(A.shape) != 2) or (A.shape[0] != A.shape[1])):
  raise ValueError('expected A to be like a square matrix')
 p = ((2 * m) + 1)
 choose_2p_p = scipy.special.comb((2 * p), p, exact=True)
 abs_c_recip = float((choose_2p_p * math.factorial(((2 * p) + 1))))
 u = (2 ** (-53))
 A_abs_onenorm = _onenorm_matrix_power_nnm(abs(A), p)
 if (not A_abs_onenorm):
  return 0
 alpha = (A_abs_onenorm / (_onenorm(A) * abs_c_recip))
 log2_alpha_div_u = np.log2((alpha / u))
 value = int(np.ceil((log2_alpha_div_u / (2 * m))))
 return max(value, 0)

def _ell ( A , m ) : if ( ( len ( A . shape ) != 2 ) or ( A . shape [ 0 ] != A . shape [ 1 ] ) ) : raise ValueError ( 'expected A to be like a square matrix' ) p = ( ( 2 * m ) + 1 ) choose_2p_p = scipy . special . comb ( ( 2 * p ) , p , exact = True ) abs_c_recip = float ( ( choose_2p_p * math . factorial ( ( ( 2 * p ) + 1 ) ) ) ) u = ( 2 ** ( - 53 ) ) A_abs_onenorm = _onenorm_matrix_power_nnm ( abs ( A ) , p ) if ( not A_abs_onenorm ) : return 0 alpha = ( A_abs_onenorm / ( _onenorm ( A ) * abs_c_recip ) ) log2_alpha_div_u = np . log2 ( ( alpha / u ) ) value = int ( np . ceil ( ( log2_alpha_div_u / ( 2 * m ) ) ) ) return max ( value , 0 )
a helper function for expm_2009 .