Page 1 of 1

Bug: pre-processor ranges which should be empty are not

PostPosted: Thu Apr 29, 2010 4:21 pm
by cfp
The range 2:1 should be empty. Instead, the pre-processor treats it as equal to the range 1:2. This is a real problem for nested for loops, as in the snippet below.

Pre-processor input:

Code: Select all
shocks;
   @#for index in 0:subdivisions
      var scripte@{index} = 1;

      @#for index2 in ( index + 1 ):subdivisions
         var scripte@{index}, scripte@{index2} = exp( -varrho * abs( @{index} - @{index2} ) / @{subdivisions} );
      @#endfor
   @#endfor
end;


Pre-processor output:

Code: Select all
shocks;

@#line "dseg1.mod" 221
      var scripte0 = 1;


@#line "dseg1.mod" 224
         var scripte0, scripte1 = exp( -varrho * abs( 0 - 1 ) / 2 );

@#line "dseg1.mod" 224
         var scripte0, scripte2 = exp( -varrho * abs( 0 - 2 ) / 2 );

@#line "dseg1.mod" 226

@#line "dseg1.mod" 221
      var scripte1 = 1;


@#line "dseg1.mod" 224
         var scripte1, scripte2 = exp( -varrho * abs( 1 - 2 ) / 2 );

@#line "dseg1.mod" 226

@#line "dseg1.mod" 221
      var scripte2 = 1;


@#line "dseg1.mod" 224
         var scripte2, scripte2 = exp( -varrho * abs( 2 - 2 ) / 2 );

@#line "dseg1.mod" 224
         var scripte2, scripte3 = exp( -varrho * abs( 2 - 3 ) / 2 );

@#line "dseg1.mod" 226

@#line "dseg1.mod" 227
end;

Re: Bug: pre-processor ranges which should be empty are not

PostPosted: Wed May 12, 2010 10:04 am
by SébastienVillemot
Hi,

Thanks for reporting this. It will be fixed in the next release of Dynare, and is already fixed in the unstable version.

Best,