Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional data argument for gradient and jacobian functions #9

Open
Nicholaswogan opened this issue Mar 3, 2022 · 3 comments
Open

Comments

@Nicholaswogan
Copy link

Nicholaswogan commented Mar 3, 2022

Would be nice if the gradient and jacobian functions accepted an optional data parameter. The interface would look something like this:

  abstract interface
     function dependent_function (x, dat) result (fx)
       import :: var
       type(var), intent(in) :: x(:)
       class(*), optional, intent(in) :: dat
       type(var) :: fx
     end function dependent_function
  end interface
@yizhang-yiz
Copy link
Owner

A more flexible way to put the dependent function in a module and use whatever the module provides inside the function. This way doesn't require user to unpack data.

@Nicholaswogan Nicholaswogan changed the title Optical data argument for gradient and jacobian functions Optional data argument for gradient and jacobian functions Mar 3, 2022
@Nicholaswogan
Copy link
Author

But the module approach will make the data global. This makes the code thread-unsafe, if there are work arrays being written to in the data. It also prevents any object/class/type which uses fazang to have multiple different instantiations.

@yizhang-yiz
Copy link
Owner

I should've pointed out that fazang itself is not thread safe. Currently one cannot safely call gradient in separate threads. It's planned but not there yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants