Proof of concept: Binary output format for cmdstan

This is a subset of the models we test the output of in stanio’s tests:

parameters {
  real mu;
}
model {
  mu ~ normal(0, 1);
}
generated quantities {
  matrix[2, 3] m = mu * to_matrix(linspaced_vector(6, 5, 11), 2, 3);
  array[4] matrix[2, 3] threeD;
  for (i in 1 : 4) {
    threeD[i] = i * mu * to_matrix(linspaced_vector(6, 5, 11), 2, 3);
  }
  
  real nu = normal_rng(mu, 1);
  complex z = nu + nu * 2.0i;
  complex_vector[2] zv = to_complex([3 * nu, 5 * nu]', [nu * 4, nu * 6]');
  complex_matrix[2, 3] zm = to_complex(m, m + 1);
  array[4] complex_matrix[2, 3] z3D;
  for (i in 1 : 4) {
    z3D[i] = to_complex(threeD[i], threeD[i] + 1);
  }
  
  real base = normal_rng(0, 1);
  int base_i = to_int(normal_rng(10, 10));
  
  tuple(real, real) pair = (base, base * 2);
  
  tuple(real, tuple(int, complex)) nested = (base * 3, (base_i, base * 4.0i));
  array[2] tuple(real, real) arr_pair = {pair, (base * 5, base * 6)};
}

Besides just testing that the naming is correct, it’s also worth testing that the correct pieces are labeled as the real/imaginary parts. cmdstanpy had a bug in its initial handling of these