Linspaced_array returns wrong value

Consider the following:

transformed data {
  int n = 5;
  real my_array[n] = linspaced_array(n, 1.1, 5.5);

I would expect to obtain [1.1, 2.2, 3.3, 4.4, 5.5], but instead I get [1, 2, 3, 4, 5]. Is there something wrong with the function linspaced_array or am I misunderstanding something?

Thanks in advance!

1 Like

Thanks for reporting and sorry it took so long to reply. This is definitely a bug. No idea how this could’ve gotten in as there should have been unit tests covering this case.

See: linspaced_array returns int, but should return real · Issue #3022 · stan-dev/math · GitHub

1 Like

Hi Bob,

Thank you for your reply. My workaround was declaring a vector with linspaced_vector, and then converting it to an array with to_array_1d. But glad to know this is now a known problem.