[ADMB Users] Question about vectors

John Sibert sibert at hawaii.edu
Wed Dec 10 08:18:26 PST 2014

Vectors can be indexed at the user's pleasure. The construtors take 2 
arguments, the lower and upper values of the index. Thus it you can 
declare dvector myvector(0,10); which will have 11 elements indexed from 
0 to 10l

I don't understand the second question. The data types were determined 
by the requirements of the software.

There is no difference between () and []. There protection given to the 
user or anyone else by []. Compiling in "safe mode" invokes subscript 
checking for both types operators.

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 11/27/2014 10:19 AM, bigA wrote:
> Hi Users,
> I have a few questions about vectors.
> First, was there a conscious decision by ADMB to start counting at 1 
> rather than 0?
> The second is perhaps a historical question. I know the stl was 
> probably not around when AUTODIF was written, were the datatypes based 
> on another C++ library? Most array's can be accessed by square 
> brackets, what protection is given to the user by using parenthesis?
> Thanks,
> Aaron
> Below is a FINAL_SECTION I put on the simple example.
>  for(int i=1; i<nobs;i++){cout<<i<<"\t";} // write out the index
>   cout<<"\n"<<endl; //give a bit of space
>  for(int i=1; i<nobs;i++){cout<<pred_Y[i]<<"\t";}// write out vector 
> of predicted Y's
>    cout<<"\n"<<endl;// space
>  for(int i=1; i<4;i++){ //counting from 1 works
>    cout<<pred_Y[i]<<endl; //square brackets
>    cout<<pred_Y(i)<<endl;// parenthesis
>    }
>  for(int i=0; i<4;i++){// counting from zero doesn't work
>    cout<<pred_Y[i]<<endl;
>    cout<<pred_Y(i)<<endl;
>    }
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users

More information about the Users mailing list