stan-dev / stanc3

The Stan transpiler (from Stan to C++ and beyond).
BSD 3-Clause "New" or "Revised" License
140 stars 44 forks source link

Initialize complex types to NaN for both components #1225

Closed WardBrian closed 2 years ago

WardBrian commented 2 years ago

Submission Checklist

Release notes

This tweaks code gen slightly to initialize empty complex Eigen types to have nan for both the real and imaginary portions.

Currently, the model:

transformed data {
   complex_vector[1] Z;
}

model {
   print(Z[1]);
}

prints (nan, 0). This PR makes that (nan, nan)

Copyright and Licensing

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the BSD 3-clause license (https://opensource.org/licenses/BSD-3-Clause)

bob-carpenter commented 2 years ago

+1 to this fix. I should've caught this the first time around.

rok-cesnovar commented 2 years ago

Thanks, looks good to me.