[ADMB Users] dvariable vs. prevariable

60 views
Skip to first unread message

James Thorson

unread,
May 21, 2012, 2:33:10 PM5/21/12
to ADMB Users
Hi all,

I had a quick coding question that I couldn't answer online.  What is the difference between dvariables and prevariables?  They seem to be used interchangably in calls to SEPARABLE_FUNCTIONS, and it appears that dvariables are defined based on prevariables.  Is one faster to use than the other, or more appropriate for particular uses?

Seems like a useful question to have documented on the redmine (where I understand, perhaps mistakenly, that any answers to this inquiry will be stored)..

Cheers,
Jim

dave fournier

unread,
May 23, 2012, 7:09:30 PM5/23/12
to us...@admb-project.org
prevariable is better for separable_functions.

The difference is between say x(i) when x is a dvar_vector. then x(i) is a prevariable.
If you pass x(i) to a function which takes a dvariable a constructor is invoked to change
it to a dvariable. This incurs a bit of overhead. Also if you changed the value of argument
corresponding to x(i) inside the function the original x(i) would not be changed
since you are actually changing a different object.

If this seems bizarre it was done so that
the access functions x(i) and x[i] which involve a copy
constructor would not incur extra overhead.




_______________________________________________
Users mailing list
Us...@admb-project.org
http://lists.admb-project.org/mailman/listinfo/users
Reply all
Reply to author
Forward
0 new messages