def correlate(in1, in2, mode='full', method='auto'):
 in1 = asarray(in1)
 in2 = asarray(in2)
 if (in1.ndim == in2.ndim == 0):
  return (in1 * in2)
 elif (in1.ndim != in2.ndim):
  raise ValueError('in1 and in2 should have the same dimensionality')
 try:
  val = _modedict[mode]
 except KeyError:
  raise ValueError("Acceptable mode flags are 'valid', 'same', or 'full'.")
 if (method in ('fft', 'auto')):
  return convolve(in1, _reverse_and_conj(in2), mode, method)
 if _np_conv_ok(in1, in2, mode):
  return np.correlate(in1, in2, mode)
 swapped_inputs = (((mode == 'full') and (in2.size > in1.size)) or _inputs_swap_needed(mode, in1.shape, in2.shape))
 if swapped_inputs:
  (in1, in2) = (in2, in1)
 if (mode == 'valid'):
  ps = [((i - j) + 1) for (i, j) in zip(in1.shape, in2.shape)]
  out = np.empty(ps, in1.dtype)
  z = sigtools._correlateND(in1, in2, out, val)
 else:
  ps = [((i + j) - 1) for (i, j) in zip(in1.shape, in2.shape)]
  in1zpadded = np.zeros(ps, in1.dtype)
  sc = [slice(0, i) for i in in1.shape]
  in1zpadded[sc] = in1.copy()
  if (mode == 'full'):
   out = np.empty(ps, in1.dtype)
  elif (mode == 'same'):
   out = np.empty(in1.shape, in1.dtype)
  z = sigtools._correlateND(in1zpadded, in2, out, val)
 if swapped_inputs:
  z = _reverse_and_conj(z)
 return z

def correlate ( in1 , in2 , mode = 'full' , method = 'auto' ) : in1 = asarray ( in1 ) in2 = asarray ( in2 ) if ( in1 . ndim == in2 . ndim == 0 ) : return ( in1 * in2 ) elif ( in1 . ndim != in2 . ndim ) : raise ValueError ( 'in1 and in2 should have the same dimensionality' ) try : val = _modedict [ mode ] except KeyError : raise ValueError ( "Acceptable mode flags are 'valid', 'same', or 'full'." ) if ( method in ( 'fft' , 'auto' ) ) : return convolve ( in1 , _reverse_and_conj ( in2 ) , mode , method ) if _np_conv_ok ( in1 , in2 , mode ) : return np . correlate ( in1 , in2 , mode ) swapped_inputs = ( ( ( mode == 'full' ) and ( in2 . size > in1 . size ) ) or _inputs_swap_needed ( mode , in1 . shape , in2 . shape ) ) if swapped_inputs : ( in1 , in2 ) = ( in2 , in1 ) if ( mode == 'valid' ) : ps = [ ( ( i - j ) + 1 ) for ( i , j ) in zip ( in1 . shape , in2 . shape ) ] out = np . empty ( ps , in1 . dtype ) z = sigtools . _correlateND ( in1 , in2 , out , val ) else : ps = [ ( ( i + j ) - 1 ) for ( i , j ) in zip ( in1 . shape , in2 . shape ) ] in1zpadded = np . zeros ( ps , in1 . dtype ) sc = [ slice ( 0 , i ) for i in in1 . shape ] in1zpadded [ sc ] = in1 . copy ( ) if ( mode == 'full' ) : out = np . empty ( ps , in1 . dtype ) elif ( mode == 'same' ) : out = np . empty ( in1 . shape , in1 . dtype ) z = sigtools . _correlateND ( in1zpadded , in2 , out , val ) if swapped_inputs : z = _reverse_and_conj ( z ) return z
correlate vectors using method .