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

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

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

Postby cfp » Thu Apr 29, 2010 4:21 pm

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;
cfp
 
Posts: 60
Joined: Mon Mar 15, 2010 9:18 pm

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

Postby SébastienVillemot » Wed May 12, 2010 10:04 am

Hi,

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

Best,
Sébastien Villemot
Economist at OFCE – Sciences Po
SébastienVillemot
 
Posts: 706
Joined: Fri Dec 07, 2007 2:29 pm
Location: Paris, France


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 13 guests