Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
6590 Discussions

Passing extra parameters to nonlinear least square routine


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.

Operating System: Windows OS

0 Kudos
1 Reply
Black Belt
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.