Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

C++ compiler help

  • 14-03-2005 7:05pm
    #1
    Closed Accounts Posts: 2


    Hello all,

    I am sure this error has come across the board before, but could not find it through searching. I am using the borland 5.5 compiler along with a program called admodel builder to run non-linear regression models. When converting my base template file which looks like this:
    DATA_SECTION
    init_int nobs;
    init_matrix data(1,nobs,1,2)
    vector SSB(1,nobs);
    vector R(1,nobs);
    PARAMETER_SECTION
    init_number a;
    init_number b;
    vector pred_R(1,nobs)
    objective_function_value f;
    PRELIMINARY_CALCS_SECTION
    // get the data out of the columns of the data matrix 
    SSB=column(data,1);
    R=column(data,2);
    PROCEDURE_SECTION
    pred_R=((a*SSB)/(1+b*SSB));
    f=regression(R,pred_R);
    

    into a cpp file I get an error saying:

    "operator/ not implemented in type dvar_vector for arguments of the same type in function model_parameters::user function()"
    it is referring to a problem with my division (/) operator in my function? The resulting cpp file looks like this:
    #include <admodel.h>
    
    #include <bh.htp>
    
    model_data::model_data(void)
    {
    nobs.allocate("nobs");
    data.allocate(1,nobs,1,2,"data");
    SSB.allocate(1,nobs);
    R.allocate(1,nobs);
    }
    
    model_parameters::model_parameters(int sz,int argc,char * argv[]) : 
    ad_comm(argc,argv), model_data() , function_minimizer(sz)
    {
    initializationfunction();
    a.allocate("a");
    b.allocate("b");
    pred_R.allocate(1,nobs,"pred_R");
    #ifndef NO_AD_INITIALIZE
    pred_R.initialize();
    #endif
    f.allocate("f");
    }
    
    void model_parameters::preliminary_calculations(void)
    {
    // get the data out of the columns of the data matrix 
    SSB=column(data,1);
    R=column(data,2);
    }
    
    void model_parameters::userfunction(void)
    {
    pred_R=((a*SSB)/(1+b*SSB));
    f=regression(R,pred_R);
    }
    
    model_data::~model_data()
    {}
    
    model_parameters::~model_parameters()
    {}
    
    void model_parameters::report(void){}
    
    void model_parameters::final_calcs(void){}
    
    void model_parameters::set_runtime(void){}
    
    #ifdef _BORLANDC_
    extern unsigned _stklen=10000U;
    #endif
    
    
    #ifdef __ZTC__
    extern unsigned int _stack=10000U;
    #endif
    
    long int arrmblsize=0;
    
    int main(int argc,char * argv[])
    {
    gradient_structure::set_NO_DERIVATIVES();
    gradient_structure::set_YES_SAVE_VARIABLES_VALUES();
    #if defined(__GNUDOS__) || defined(DOS386) || defined(__DPMI32__) || \
    defined(__MSVC32__)
    if (!arrmblsize) arrmblsize=150000;
    #else
    if (!arrmblsize) arrmblsize=25000;
    #endif
    model_parameters mp(arrmblsize,argc,argv);
    mp.iprint=10;
    mp.preliminary_calculations();
    mp.computations(argc,argv);
    return 0;
    }
    

    Thanks for any help offered.

    Mako


Comments

  • Closed Accounts Posts: 423 ✭✭Dizz


    Why don't you split the troublesome line up to confirm your suspicisons?

    from:
    pred_R=((a*SSB)/(1+b*SSB));

    to:
    x = a*SSB;
    y = 1+b*SSB;
    pred_R = x/y

    where x,y are the correct types ;). If x and y are integer types then to have the problems is surprising - if not the operator needs overriding and implementing.

    Dizz


  • Closed Accounts Posts: 2 awood11@mail.co


    I have determined that my / operator needs to be overloaded. Can someone tell me where and what I would insert into my code to do this? Thanks,


  • Closed Accounts Posts: 423 ✭✭Dizz


    Have a look here (courtesy of google ;)) http://gethelp.devx.com/techtips/cpp_pro/10min/2001/august/10min0801.asp
    As for where to do it - you'll prob have to modify the generated code by your backend.

    Dizz


Advertisement