How to output variable in generated quantities without renaming it

Is there a way to output b without renaming it to b_?

data { 
  int a; 
}

transformed data {
  real b = 2*a;
}

generated quantities {
  // Is there something like export b?
  real b_ = b;
}

This works

data { 
  int a; 
}
transformed parameters {
  real b = 2*a;
}
1 Like

Thanks, but the calculation is costly, and transformed parameters would run it for every iteration.

I guess the easiest solution is to rename.

Ah, you missed that piece of information from your question! (I assume you don’t mean that 2*a would be that costly calculation)