[Developers] Template functions and documentation

dave fournier davef at otter-rsch.com
Fri Jun 27 11:11:15 PDT 2014


On 06/27/2014 11:04 AM, Mark Maunder wrote:

Its hard to believe that Schnute and I figured out how to do this 
properly almost 34 years ago
using punch cards on a machine with 18K user memory.  Someone really 
should figure out how to teach
people the importance of parameterizing nonlinear models in a stable 
fashion.




> Hi developers,
>
> I am in the process or putting together a model that will be used to 
> evaluate several growth equations so I thought I better try to use the 
> ADMB project "approved" approach for writing the functions. Below is a 
> template function and documentation for the von Bertalanffy growth 
> equation. I would appreciate any advice on doing this "correctly".
>
> Thanks,
>
> Mark
>
> /**
>
> \defgroup CONTRIB Contributed libraries
>
> */
>
> /**
>
> \ingroup CONTRIB
>
> \defgroup CAPAM CAPAM created functions
>
> */
>
> #include <admodel.h>
>
> /**  von Bertalanffy growth equation; constant objects.
>
>   \ingroup CAPAM
>
>   \brief Calculate the length from a given age based on the von 
> Bertalanffy equation. Written by Mark Maunder.
>
>   \param age age of individual, \f$a\f$.
>
>   \param Linf asymptotic length, \f$L_inf\f$.
>
>   \param K growth rate, \f$K\f$.
>
>   \param t0 age at zero length, \f$t_0\f$.
>
>   \return length predicted length of individual. 
> \f$L_inf*(1-exp(-K*(a-t0)))\f$.
>
>   */
>
> template <typename type1, typename type1>
>
> //can have multiple types so that they are used below in variable 
> definitions, they can differ between function calls, but remain the 
> same within a function call
>
> //type1 is probably a long
>
> //type2 is probably a dvariable (either a model parameter (Linf K t0) 
> or a derived variable (length))
>
> //may need a type3, which is a dvar_vector if age and length are 
> vectors, where type 1 will be a vector
>
> type1 vonB(const type1 &age, const type2 &Linf, const type2 &K, const 
> type2 &t0)
>
> {
>
>   type2 length = Linf*(1.-mfexp(-K*(age-t0)));
>
>   return (length);
>
> }
>
> //is length a bad word to use
>
> //do we use ingroup for both groups and subgroups in doxygen documentation
>
> //should we use mfexp?
>
> //what if age and length are vectors, but age is a vector and length 
> is a dvar_vector, do we need to overload the type with one with three 
> variable types
>
> //I couldn't work out how to put in the detailed description
>
> //The equations did not work on my computer
>
>
>
> _______________________________________________
> Developers mailing list
> Developers at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/developers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/developers/attachments/20140627/ef816bc6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f80-172.pdf
Type: application/pdf
Size: 1520370 bytes
Desc: not available
URL: <http://lists.admb-project.org/pipermail/developers/attachments/20140627/ef816bc6/attachment-0001.pdf>


More information about the Developers mailing list