[Developers] libraries of functions
Mark Maunder
mmaunder at iattc.org
Mon Aug 11 16:22:17 PDT 2014
One of the problems is I did not remove "model_parameters::" from the function I took from the cpp generated by tpl2cpp. The other problem is that templates don't work when there is a different "dvariable". A dvariable cab be both a named_dvariable& and a param_init_number&, but they are not the same in terms of a template. So the following are not the same in the external hpp file
dvariable Richards(const dvariable &age, const dvariable &Linf, const dvariable &K, const dvariable &t0, const dvariable &p)
{
{
dvariable Length=Linf*pow((1+(1/p)*exp(-K*(age-t0))),-p);
return(Length);
}
}
template <typename type1>
dvariable Richards(const dvariable &age, const type1 &Linf, const type1 &K, const type1 &t0, const type1 &p)
{
dvariable Length=Linf*pow((1+(1/p)*exp(-K*(age-t0))),-p);
return(Length);
}
In the latter I get the errors
igm.cpp: In member function 'virtual void model_parameters::userfunction()':
igm.cpp:127:46: error: no matching function for call to 'Richards(prevariable, named_dvariable&, named_dvariable&, param_init_number&, named_dvariable&)'
igm.cpp:128:58: error: no matching function for call to 'Richards(prevariable&, named_dvariable&, named_dvariable&, param_init_number&, named_dvariable&)'
igm.cpp:139:49: error: no matching function for call to 'Richards(double&, named_dvariable&, named_dvariable&, param_init_number&, named_dvariable&)'
From: dave fournier [mailto:davef at otter-rsch.com]
Sent: Monday, August 11, 2014 3:58 PM
To: Mark Maunder; developers at admb-project.org; admb-users at googlegroups.com
Subject: Re: [Developers] libraries of functions
On 08/11/2014 03:49 PM, Mark Maunder wrote:
Because part of the "job" of tpl2cpp or tpl2rem is to take a declaration wiht the FUNCTION keyword and
put the appropriate declaration for the class member function into th htp file.
Why do I get an error if I put the following function in the file CAPAM_Growth.hpp and include it using #include<CAPAM_Growth.hpp> but if I put it in the tpl using the FUNCTION section I do not? The translator appears to just put it in the cpp with no changes
dvariable model_parameters::Richards(const dvariable &age, const dvariable &Linf, const dvariable &K, const dvariable &t0, const dvariable &p)
{
{
dvariable Length=Linf*pow((1+(1/p)*exp(-K*(age-t0))),-p);
return(Length);
}
}
The errors I get are
In file included from igm.cpp:3:0:
./CAPAM_Growth.hpp:130:142: error: invalid use of incomplete type 'struct model_parameters'
c:/ADMB/admb101-gcc452-win32\include/admodel.h:107:9: error: forward declaration of 'struct model_parameters'
igm.cpp: In member function 'virtual void model_parameters::userfunction()':
igm.cpp:127:46: error: no matching function for call to 'Richards(prevariable, named_dvariable&, named_dvariable&, param_init_number&, named_dvariable&)'
igm.cpp:128:58: error: no matching function for call to 'Richards(prevariable&, named_dvariable&, named_dvariable&, param_init_number&, named_dvariable&)'
igm.cpp:139:49: error: no matching function for call to 'Richards(double&, named_dvariable&, named_dvariable&, param_init_number&, named_dvariable&)'
The selectivity special issue of the journal Fisheries Research is now published
http://www.sciencedirect.com/science/journal/01657836/158/supp/C
The Stock Synthesis special issue of the journal Fisheries Research
http://www.sciencedirect.com/science/journal/01657836/142
Mark Maunder
Head of the Stock Assessment Program
Inter-American Tropical Tuna Commission
8901 La Jolla Shores Dr.
La Jolla, CA 92037-1508, USA
Tel: (858) 546-7027
Fax: (858) 546-7133
mmaunder at iattc.org<mailto:mmaunder at iattc.org>
http://www.fisheriesstockassessment.com/TikiWiki/tiki-index.php?page=Mark+Maunder
Visit the Center for the Advancement of Population Assessment Methodology at
http://www.capamresearch.org/
Visit the AD Model Builder project at
http://admb-project.org/
See the following website for information on fisheries stock assessment http://www.fisheriesstockassessment.com/
_______________________________________________
Developers mailing list
Developers at admb-project.org<mailto: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/20140811/aba57b12/attachment-0001.html>
More information about the Developers
mailing list