transform_inits_impl generates z = in__.read<local_scalar_t__>(); to read in a complex number z, but this should be z = in__.read<std::complex<local_scalar_t__>>();
The result is that z has a 0 imaginary component and subsequent parameters are read in from the wrong part of the buffer.
transform_inits_impl
generatesz = in__.read<local_scalar_t__>();
to read in a complex numberz
, but this should bez = in__.read<std::complex<local_scalar_t__>>();
The result is that z has a
0
imaginary component and subsequent parameters are read in from the wrong part of the buffer.I have a partial fix (for scalars) in a branch https://github.com/stan-dev/stanc3/tree/fix/deserializer-read-containers. Containers requires some additional logic in one of the overloads of
transform_inits
Model Code
Model which exhibits the issue
```stan parameters { complex_vector[2] z ;//= [1+2i,3+4i]'; } model { print(z); } ``` ```json {"z":[[1,2], [3,4]]} ``` ```shell ./test_model sample num_warmup=1 num_samples=1 init=params.json ``` prints `[(1,0),(3,0)]`Environment:
Stan 2.31.0