thank you very much. you and another person were very kind to take the
time out to help me. I really needed it.
-----Original Message-----
From: Christopher F Baum <[log in to unmask]>
To: Mark Leeds <[log in to unmask]>; [log in to unmask]
<[log in to unmask]>
Date: Thursday, October 07, 1999 7:16 PM
Subject: Re: a simple function
>How's this?
>
>$ cat t.ox
>#include <oxstd.h>
>
>crzz1( const invec)
>
>{
> decl i;
> decl outvec = new matrix[rows(invec)][1];
> for ( i =0; i < rows(invec); ++i )
> {
> if ( i == 0 )
> {
> outvec[i][0] = invec[i][0];
> }
> else
> {
> outvec[i] = outvec[i-1] + invec[i];
> }
> }
> return outvec;
>}
>
>main()
>{
> decl a,b,i;
>
> a = <1,2,3,4,5,6,7,8,9,10>';
> b = crzz1(a);
> for(i=0;i<rows(b);i++){
> print("b[",i,"] = ",b[i],"\n");
> }
>}
>
>$ r o
>ox t.ox
>
>Ox version 2.10 (AIX) (C) J.A. Doornik, 1994-99
>b[0] = 1
>b[1] = 3
>b[2] = 6
>b[3] = 10
>b[4] = 15
>b[5] = 21
>b[6] = 28
>b[7] = 36
>b[8] = 45
>b[9] = 55
>
>
>Kit Baum
>Boston College Economics
>
>--On Thu, Oct 7, 1999 18:20 -0700 Mark Leeds <[log in to unmask]> wrote:
>
>>
>> if anyone could help me out with this I would really appreciate it. I
>> wrote a really simple function to take a invec which say is a 10 by 1
>> matrix with elements 1,2,3,4,5,6,7,8,9,10 say and then have outvec to be
>> the 9 by 1 forward addition of invec so that the first element is 1+2
>> =3, the next element is 1+2+3 = 6. then next element is 1+2+3+4 = 10
>> etc. I keep
>> getting an error "index out of range "but i don't see why". I put print
>> statements everywhere but still can't figure it out. The program
>> is only like 12 lines and I am attaching it. If anyone could explain this
>> to me, it would be great because I have to do much more complex things
>> than this so if i can't do this, I am in trouble. I have a c background
>> and it seems like pointers are similar in ox but maybe not exactly ?
>> Thank you very much. I think anyone who is decent at ox can
>> figure this out in 5 minutes ? I have been at it for 4 hours.
>>
>> Ma
>> rk
>>
>>
>
>
>
>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|