diff --git a/GPy/inference/scg.py b/GPy/inference/scg.py index 252f348e..57a81542 100644 --- a/GPy/inference/scg.py +++ b/GPy/inference/scg.py @@ -1,4 +1,4 @@ -# Copyright I. Nabney, N.Lawrence and James Hensman (1996 - 2012) +# Copyright I. Nabney, N.Lawrence and James Hensman (1996 - 2014) # Scaled Conjuagte Gradients, originally in Matlab as part of the Netlab toolbox by I. Nabney, converted to python N. Lawrence and given a pythonic interface by James Hensman @@ -154,9 +154,9 @@ def SCG(f, gradf, x, optargs=(), maxiters=500, max_f_eval=np.inf, display=True, break else: # Update variables for new position + gradold = gradnew gradnew = gradf(x, *optargs) current_grad = np.dot(gradnew, gradnew) - gradold = gradnew fold = fnew # If the gradient is zero then we are done. if current_grad <= gtol: diff --git a/GPy/util/misc.py b/GPy/util/misc.py index 1cb4c182..2b825597 100644 --- a/GPy/util/misc.py +++ b/GPy/util/misc.py @@ -86,7 +86,6 @@ def kmm_init(X, m = 10): def fast_array_equal(A, B): - if config.getboolean('parallel', 'openmp'): pragma_string = '#pragma omp parallel for private(i, j)' else: @@ -174,6 +173,50 @@ def fast_array_equal(A, B): return value +def fast_array_equal2(A, B): + if (A == None) and (B == None): + return True + elif ((A == None) and (B != None)) or ((A != None) and (B == None)): + return False + elif not (A.shape == B.shape): + return False + + if config.getboolean('parallel', 'openmp'): + pragma_string = '#include ' + weave_options = {'headers' : [''], + 'extra_compile_args': ['-fopenmp -O3'], + 'extra_link_args' : ['-lgomp'], + 'libraries' : ['gomp']} + else: + weave_options = {'extra_compile_args': ['-O3']} + pragma_string = '' + + support_code = """ + %s + #include + """ % pragma_string + + code = """ + int i; + return_val = 1; + + %s + for(i=0;i