Author: bugman Date: Tue Aug 26 19:20:48 2014 New Revision: 25315 URL: http://svn.gna.org/viewcvs/relax?rev=25315&view=rev Log: Implemented the specific_analyses.relax_fit.optimisation.d2func_wrapper() function. This converts the numpy parameter array into a Python list, calls the target_functions.relax_fit.d2func() function with this list, converts the Hessian output list of lists into a numpy rank-2 array, and returns it. This will allow Newton optimisation to be used for the relaxation curve-fitting analysis. Modified: trunk/specific_analyses/relax_fit/optimisation.py Modified: trunk/specific_analyses/relax_fit/optimisation.py URL: http://svn.gna.org/viewcvs/relax/trunk/specific_analyses/relax_fit/optimisation.py?rev=25315&r1=25314&r2=25315&view=diff ============================================================================== --- trunk/specific_analyses/relax_fit/optimisation.py (original) +++ trunk/specific_analyses/relax_fit/optimisation.py Tue Aug 26 19:20:48 2014 @@ -31,7 +31,7 @@ # C modules. if C_module_exp_fn: - from target_functions.relax_fit import setup, func, dfunc, back_calc_I + from target_functions.relax_fit import setup, func, dfunc, d2func, back_calc_I def back_calc(spin=None, relax_time_id=None): @@ -97,7 +97,10 @@ def dfunc_wrapper(params): """Wrapper function for the C module, for converting numpy arrays. - The currently does nothing. + @param params: The parameter array from the minimisation code. + @type params: numpy array + @return: The gradient generated by the C module converted to numpy format. + @rtype: numpy float64 array """ # Call the C code. @@ -110,5 +113,14 @@ def d2func_wrapper(params): """Wrapper function for the C module, for converting numpy arrays. - The currently does nothing. + @param params: The parameter array from the minimisation code. + @type params: numpy array + @return: The Hessian generated by the C module converted to numpy format. + @rtype: numpy float64 rank-2 array """ + + # Call the C code. + d2chi2 = d2func(params.tolist()) + + # Return the chi2 Hessian as a numpy array. + return array(d2chi2, float64)