-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add Julia equivalent of "nargout" to docs #4227
Comments
I think Julia is not going to take the MATLAB way, that is to let the function to decide the behavior based on the number of outputs arguments. And as far as I can tell, there is no way to tell "the number of outputs" within a function. |
@lindahua So it seems. However, I think it would be a good idea to add a section to the docs with the Julian way of handling such situations. For example, in my case I am interested in the best solution to the optimization suite problem I described above. |
The standard solution is to pass additional outputs as pre-allocated inputs, and have your function modify the inputs in-place. FYI: both |
From the perspective of the docs, I think we need a |
@timholy Thanks, that's the answer I was looking for. I would love to get involved more actively with Julia, but time is a continuously depleted resource of mine. |
join the crowd :-) |
Of course there is the list at http://docs.julialang.org/en/latest/manual/getting-started/#noteworthy-differences-from-matlab but maybe we're at the point where a list like this no longer cuts it. |
It's certainly useful, and fairly complete (although this particular issue doesn't appear). Someone recently pointed out http://wiki.scipy.org/NumPy_for_Matlab_Users which has some attractive features. |
backported (squashed along with the formatting fix) in 4baf8e4 |
What are the best ways of translating MATLAB functions to Julia of which the output and its computations are based on nargout?
In my case, I would like to know the best workaround for a hypothetical optimization suite written in Julia in which the user is asked to supply a function which computes an objective function value, and as an optional second output a derivative. The advantage of a nargout approach is that the user need only write one function and, importantly, that in many cases some of the computation between the objective function and its derivative may be shared.
The text was updated successfully, but these errors were encountered: