[ADMB Users] Having trouble with this; segmenataion fault

4 views
Skip to first unread message

John Sibert

unread,
Dec 8, 2014, 1:25:04 PM12/8/14
to ADMB Users
template <typename SCALAR> SCALAR alogit(const SCALAR& a)
{
SCALAR p = 1.0/(1.0+exp(-a));
return p;
}
template df1b2variable alogit(const df1b2variable& a);

--
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/

_______________________________________________
Users mailing list
Us...@admb-project.org
http://lists.admb-project.org/mailman/listinfo/users

Steve Martell

unread,
Dec 8, 2014, 1:41:42 PM12/8/14
to John Sibert, ADMB Users
John,

This works for me:


DATA_SECTION

PARAMETER_SECTION
init_number dum;

objective_function_value f;
random_effects_vector re(1,3);

PROCEDURE_SECTION

df1b2variable x = 2.;
alogit(x);

GLOBALS_SECTION
template <typename SCALAR> SCALAR alogit(const SCALAR& a)
{
SCALAR p = 1.0/(1.0+exp(-a));
return p;
}
// template df1b2variable alogit(const df1b2variable& a);
________________________________

This internet e-mail message, and any files transmitted with it, contains confidential, privileged information that is intended only for the addressee. If you have received this e-mail message in error, please call us at (206) 634-1838 collect if necessary) and ask to speak to the message sender. Nothing in this e-mail or the act of transmitting it, is to be construed as a waiver of any rights or privileges enjoyed by the sender or the International Pacific Halibut Commission pursuant to the International Organizations Immunities Act, 22 U.S.C. Sec. 288 et seq.

John Sibert

unread,
Dec 8, 2014, 2:19:12 PM12/8/14
to Steve Martell, ADMB Users
Hi Steve,
Yes. That indeed works. My problem is contextual. The call is embedded
in a separable function. In the model_parameters:: member function the
return value appears to require a dvariable, and in the
df1b2_pre_parameters:: member function, the return value appears to
reqauire a df1b2variable. In both cases, I think the argument type is
a and init_parameter type.

The KISS principle applies here. The code I originally wrote works fine.
dvariable tprop = 1.0/(1.0+exp(-LmeanPropL));

I hate templates
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/

Steve Martell

unread,
Dec 8, 2014, 3:05:46 PM12/8/14
to John Sibert, ADMB Users
Only way I could get it to work was doing something like this.

DATA_SECTION

PARAMETER_SECTION
init_number dum;

objective_function_value f;
random_effects_vector re(1,3);

number dd;
PROCEDURE_SECTION

df1b2variable x = 2.;
alogit(x);

//This seems to work. First assign prevariable to xd to dvariable.
dvariable xd = dum;
dd = alogit(xd);
Reply all
Reply to author
Forward
0 new messages