[Developers] libraries of functions
Mark Maunder
mmaunder at iattc.org
Tue Aug 12 11:36:36 PDT 2014
The use of RETURN_ARRAYS_INCREMENT is unclear. I have heard that it is no longer necessary.
-----Original Message-----
From: developers-bounces at admb-project.org [mailto:developers-bounces at admb-project.org] On Behalf Of John Sibert
Sent: Tuesday, August 12, 2014 11:33 AM
To: William Stockhausen - NOAA Federal; admb-users at googlegroups.com; developers at admb-project.org
Subject: Re: [Developers] libraries of functions
Yes, that would be standard practice. At one time a runtime error was generated if there was insufficient memory allocated for these kinds of return objects.
John Sibert
Emeritus Researcher, SOEST
University of Hawaii at Manoa
Honolulu HI (GMT-10)
808-294-3842 (mobile)
Visit the ADMB project http://admb-project.org/
On 08/12/2014 04:44 AM, William Stockhausen - NOAA Federal wrote:
> Regarding Mark's Richardson function: should the interior of the
> function be "sandwiched" between RETURN_ARRAYS_INCREMENT and
> RETURN_ARRAYS_DECREMENT macros because the function creates and
> returns a dvariable?
>
> Buck Stockhausen
>
> ***************************************************
> * Dr. William T. Stockhausen *
> ***************************************************
> * Resource Ecology and Fisheries Management *
> * Alaska Fisheries Science Center *
> * National Marine Fisheries Service *
> * National Oceanic and Atmospheric Administration *
> * 7600 Sand Point Way N.E. *
> * Seattle, Washington 98115-6349 *
> ***************************************************
> * email: William.Stockhausen at noaa.gov
> <mailto:William.Stockhausen at noaa.gov> *
> * voice: 206-526-4241 fax: 206-526-6723 *
> * web : http://www.afsc.noaa.gov *
> ***************************************************
> All models are wrong, some are useful.--G.E.P. Box
> Beware of geeks bearing equations. --W. Buffett
> ***************************************************
> Disclaimer: The opinions expressed above are personal and do not
> necessarily reflect official NOAA policy.
>
>
>
>
> On Mon, Aug 11, 2014 at 4:26 PM, John Sibert <johnrsibert at gmail.com
> <mailto:johnrsibert at gmail.com>> wrote:
>
> The message is caused because the compiler does not know anything
> about class model_parameters, as would be the case if
> #include<CAPAM_Growth.hpp> were included in the GLOBALS_SECTION of
> a tpl file.
>
> If I read your function correctly, there is no need for
> Richards(...) to be a member of the model_parameters class. All of
> the required variables are passed as arguments. So I would suggest
> simply making it a global function.
> dvariable Richards(const dvariable &age, const dvariable &Linf,
> const dvariable &K, const dvariable &t0, const dvariable &p)
>
> If you want to be a more restrictive (and perhaps a bit safer in
> case there is some other function with the same protoype), you
> might consider using a namespace. For instance
> namespace CAPAM
> {
> dvariable Richards(const dvariable &age, const dvariable &Linf,
> const dvariable &K, const dvariable &t0, const dvariable &p)
> {
>
> }
>
> }
>
> To invoke it your could call
> dvariable y = CAPAM::Richards(...)
>
> Or insert a using statement in the GLOBALS_SECTION of your tpl like
> using namesapce CAPAM;
>
> and simply call the function without the namespace qualifier.
> dvariable y = Richards(...)
>
> The innertube has information on the use of namespace.
> http://www.cplusplus.com/doc/tutorial/namespaces/
>
>
>
> On 08/11/2014 12:49 PM, Mark Maunder wrote:
>
>
> 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 <tel:%28858%29%20546-7027>
>
> Fax: (858) 546-7133 <tel:%28858%29%20546-7133>
>
> mmaunder at iattc.org <mailto:mmaunder at iattc.org>
> <mailto:mmaunder at iattc.org <mailto:mmaunder at iattc.org>>
>
>
>
> http://www.fisheriesstockassessment.com/TikiWiki/tiki-index.php?page=M
> ark+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/
>
> --
> You received this message because you are subscribed to the
> Google Groups "admb-users" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to admb-users+unsubscribe at googlegroups.com
> <mailto:admb-users%2Bunsubscribe at googlegroups.com>
> <mailto:admb-users+unsubscribe at googlegroups.com
> <mailto:admb-users%2Bunsubscribe at googlegroups.com>>.
> To post to this group, send email to
> admb-users at googlegroups.com
> <mailto:admb-users at googlegroups.com>
> <mailto:admb-users at googlegroups.com
> <mailto:admb-users at googlegroups.com>>.
> Visit this group at http://groups.google.com/group/admb-users.
> For more options, visit https://groups.google.com/d/optout.
>
>
> _______________________________________________
> Developers mailing list
> Developers at admb-project.org <mailto:Developers at admb-project.org>
> http://lists.admb-project.org/mailman/listinfo/developers
>
>
>
>
> _______________________________________________
> Developers mailing list
> Developers at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/developers
_______________________________________________
Developers mailing list
Developers at admb-project.org
http://lists.admb-project.org/mailman/listinfo/developers
More information about the Developers
mailing list