[Developers] Help on traits

John Sibert sibert at hawaii.edu
Wed Jul 23 13:54:28 PDT 2014


Mark,
My two cents:
Several years ago we rewrote our tag diffusion model using template 
classes like
template <typename D3_ARRAY, typename MATRIX, typename VECTOR, typename 
DOUBLE>
class par_t : public Model_area
{
public:
   par_t();
};

Member functions are instantiated like

template par_t<d3_array,dmatrix,dvector,double>::par_t();
template par_t<dvar3_array,dvar_matrix,dvar_vector,dvariable>::par_t();

for constant and variable types.

It all works well and is fairly easy to maintain. But the code gets 
ugly, especially if you derive a class from a template base class. Plus 
I find it difficult to develop new functions.

All in all, I wouldn't do it again. I'm in the process of rewriting all  
the code using variable types and
gradient_structure::set_NO_DERIVATIVES();
for simulations where I don't need derivatives.
John



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 07/23/2014 08:40 AM, Mark Maunder wrote:
> Thanks Dave, I think I am going to follow your advice.
>
> Mark
>
> -----Original Message-----
> From: developers-bounces at admb-project.org [mailto:developers-bounces at admb-project.org] On Behalf Of dave fournier
> Sent: Wednesday, July 23, 2014 9:41 AM
> To: developers at admb-project.org
> Subject: Re: [Developers] Help on traits
>
>
>     I think it is a bit premature for Mark to take an application that is not quite well defined and a technique that he does not quite understand and combine the two. What I would do is to write all the functions without any templates, and then figure out how they might be simplified using templates.
> _______________________________________________
> 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