def spectral_radius_bound(X, log2_exponent):
 if (X.type.ndim != 2):
  raise TypeError('spectral_radius_bound requires a matrix argument', X)
 if (not isinstance(log2_exponent, integer_types)):
  raise TypeError('spectral_radius_bound requires an integer exponent', log2_exponent)
 if (log2_exponent <= 0):
  raise ValueError('spectral_radius_bound requires a strictly positive exponent', log2_exponent)
 XX = X
 for i in xrange(log2_exponent):
  XX = tensor.dot(XX, XX)
 return tensor.pow(trace(XX), (2 ** (- log2_exponent)))

def spectral_radius_bound ( X , log2_exponent ) : if ( X . type . ndim != 2 ) : raise TypeError ( 'spectral_radius_bound requires a matrix argument' , X ) if ( not isinstance ( log2_exponent , integer_types ) ) : raise TypeError ( 'spectral_radius_bound requires an integer exponent' , log2_exponent ) if ( log2_exponent <= 0 ) : raise ValueError ( 'spectral_radius_bound requires a strictly positive exponent' , log2_exponent ) XX = X for i in xrange ( log2_exponent ) : XX = tensor . dot ( XX , XX ) return tensor . pow ( trace ( XX ) , ( 2 ** ( - log2_exponent ) ) )
returns upper bound on the largest eigenvalue of square symmetrix matrix x .