def _compute_lwork(routine, *args, **kwargs):
 wi = routine(*args, **kwargs)
 if (len(wi) < 2):
  raise ValueError('')
 info = wi[(-1)]
 if (info != 0):
  raise ValueError(('Internal work array size computation failed: %d' % (info,)))
 lwork = [w.real for w in wi[:(-1)]]
 dtype = getattr(routine, 'dtype', None)
 if ((dtype == _np.float32) or (dtype == _np.complex64)):
  lwork = _np.nextafter(lwork, _np.inf, dtype=_np.float32)
 lwork = _np.array(lwork, _np.int64)
 if _np.any(_np.logical_or((lwork < 0), (lwork > _np.iinfo(_np.int32).max))):
  raise ValueError('Too large work array required -- computation cannot be performed with standard 32-bit LAPACK.')
 lwork = lwork.astype(_np.int32)
 if (lwork.size == 1):
  return lwork[0]
 return lwork

def _compute_lwork ( routine , * args , ** kwargs ) : wi = routine ( * args , ** kwargs ) if ( len ( wi ) < 2 ) : raise ValueError ( '' ) info = wi [ ( - 1 ) ] if ( info != 0 ) : raise ValueError ( ( 'Internal work array size computation failed: %d' % ( info , ) ) ) lwork = [ w . real for w in wi [ : ( - 1 ) ] ] dtype = getattr ( routine , 'dtype' , None ) if ( ( dtype == _np . float32 ) or ( dtype == _np . complex64 ) ) : lwork = _np . nextafter ( lwork , _np . inf , dtype = _np . float32 ) lwork = _np . array ( lwork , _np . int64 ) if _np . any ( _np . logical_or ( ( lwork < 0 ) , ( lwork > _np . iinfo ( _np . int32 ) . max ) ) ) : raise ValueError ( 'Too large work array required -- computation cannot be performed with standard 32-bit LAPACK.' ) lwork = lwork . astype ( _np . int32 ) if ( lwork . size == 1 ) : return lwork [ 0 ] return lwork
round floating-point lwork returned by lapack to integer .