Register to reply 
Minimizing function in Matlab and C 
Share this thread: 
#73
Aug2211, 05:03 PM

HW Helper
P: 6,189

double *Actual_Data = (double *)adata; What is info[1], which is the found SSE? To be honest, I'm not sure LevenbergMarquardt will work as intended with your function, since it is not intended for a sum of absolute errors, but for a sum of squared errors. I believe it should still work, but it may not find an optimal solution. NelderMead may be a better choice for this problem (minimizing the sum of absolute errors). 


#74
Aug2411, 09:31 AM

P: 153

Hi so I have integrated the levmar and neldermead into one program so that I can use levmar to solve function1 and neldermead to solve function 2.What about prototypes tho? When do you need them and when do you not. For instance my functions function() and function2() dont have prototypes, however some other functions do have prototypes.
My third function:
It is called like:



#75
Aug2411, 11:50 AM

HW Helper
P: 6,189

If you need a prototype, you'll know, because the compiler will complain he doesn't know the function. But if it doesn't have a "void *data" pointer as a parameter, you need to use a different mechanism, which is as follows. The way to do it, is to define a global variable to pass your Actual_Data[] array. You use this global variable in your function. And just before you call NelderMead, you copy your Actual_Data[] array into the global variable. 


#76
Aug2411, 12:33 PM

P: 153

Neldermead function is like this:



#77
Aug2411, 12:40 PM

P: 153

I found the problem. z is getting there howere the maths is going haywire! v0 is not being calculated correctly  is this because of a problem with multiplying floats and doubles?



#78
Aug2411, 02:42 PM

HW Helper
P: 6,189

It's weird to see a parameter like "float ti[6]".
I suspect it should be "double ti[6]". The mismatch could cause your problems. Don't you get a compiler warning? What is the prototype of your NelderMead function, and what function prototype does it expect exactly as a parameter? 


#79
Sep911, 08:34 AM

P: 153

Hey how are you, been a while.
I am working more with the levenberg marquardt code now. I am trying to get it to use just single precision  this is an option in levmar.h Out of interest, what happens if a variable has been declared as double but in levmar.h i state i want single precision? when I choose single precision I get an error  a strange one at that. Axb_core.c1103error: 'FLT_EPSILON' undeclared (first use in this function) It works fine with double but not with single. I find this odd considering the author offeres single precision accuracy. Any ideas what the problem could be? 


Register to reply 
Related Discussions  
Minimizing cost function Statistics  Calculus & Beyond Homework  9  
Minimizing a function with a minimum constraint...  Calculus & Beyond Homework  0  
Minimizing error function > sloving linear system of equations  Calculus & Beyond Homework  2  
Minimizing a Function  Calculus & Beyond Homework  2  
Minimizing, function fit...  General Math  0 