Passing extra parameters to nonlinear least square routine

Passing extra parameters to nonlinear least square routine

Hi,
I am using nonlinear least square routine as shown in Reference Manual Chapter 14. And I follow the example "ex_nlsqp_c.c".
The routine "djacobi" in Line 206 calls a fcn which should be the user defined objective function. And this fcn takes 4 inputs: m, n, x, f, where output is f=f(x). What if I want to pass an extra array double *T into this fcn,just like the Matlab function ”lsqnonlin“ does? My fcn value is defined as f=(T*x)^2, where the T is huge and need only to be calculated somewhere else only once.

Although I can always calculate the T matrix inside my fcn each time when fcn is called., it is time-consuming and not necessary to do so.

Thanks
Dazhao
Operating System: Windows OS

2 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de mecej4

If T is initialized once and reused many times without any changes, why not make it global in scope and use it in the function as needed, instead of trying to pass it as yet another function argument?

Since the MKL solver calls your user-defined function with a fixed and pre-defined argument list, you cannot add items to the argument list.

Faça login para deixar um comentário.