"Rakesh Kumar" wrote in message <firstname.lastname@example.org>... > "Toan Cao" <email@example.com> wrote in message <firstname.lastname@example.org>... > > "Eric Sampson" wrote in message <email@example.com>... > > > "Toan Cao" <firstname.lastname@example.org> wrote in message <email@example.com>... > > > > > > > > > > What about the profiler report? Can you post the profiler report for top 10 self-time for functions and how many times they are called? > > > > > > > > Hi Rakesh, > > > > Here my profiler when i run two optimization processes, where testCM is m-file storing program of optimization, the object function in m-file is MydeformfuncSub7Ext, and in C mex file is MydeformfuncSub7ExtC. > > > > Profiler of optimzation using m-file: > > > > http://i906.photobucket.com/albums/ac264/toancv3010/Mtime_zps92ae907a.jpg > > > > Profiler of optimzation using C mexfile: > > > > http://i906.photobucket.com/albums/ac264/toancv3010/Ctime_zpsbbbc5fb3.jpg > > > > As seen, subfunction LevenbergMarquardt consumes almost time of optimization process. > > > > Is there any solution to reduce computation time for LevenbergMarquardt ? > > > > > > > > Toan > > > > > > Can you post some more images from clicking on the Profiler report for the LevenbergMarquardt.m function, and its slowest lines/function calls/etc? Maybe there is a way to speed it up. > > > > Hi Eric Sampson, > > here is spending time of levenberg-marquardt function: > > http://i906.photobucket.com/albums/ac264/toancv3010/levenbergTime_zps2f500238.jpg > > I hope to receive some comments from you. Thank you. > > > > Toan > > The backslash operator (where ~99% of the time is spent) has some heuristics to analyze and decide what method (and pre-processing) to use for solving the equation. It is likely that in these two cases, the backslash operator thinks the matrix structure (probably symmetry) is different and ends up with a different and expensive step. This is just a guess without looking at the actual matrices. > > Rakesh
I agree with Rakesh. If you want to pursue this matter further, then what I would suggest is to put a debugging breakpoint on line 178 of the LM function, run the code with the original M file objective function and then with the MEX objective function, and in each case when it stops at the breakpoint save the AugJac and AugRes variables to a .mat file. Then create a support request at The Mathworks, include the two M files, and tell them to run 'tic, AugJac \ AugRes;, toc' with the contents of each .mat file and ask for their help in explaining the difference. Good luck!