Passing empty matrix as data in JSON file

How can I create an empty matrix when passing a JSON data file to cmd-stan?

I have the following in my stan file

data {
    int n_inputs;
    int n_samples;
    matrix[n_inputs,n_samples] U;
    ...
}

My JSON file contains:

{ "U": [], "n_inputs": 0, "n_samples": 100, ... }

but I get the error variable: U, error: empty array not allowed.

I am using Stan-2.19.

Why would you want to do that?

Couldn’t you use the generated data or generated quantities block for what you are trying to do?

Hi Max_Mantei

Thanks for taking the time to reply to my question.
I would like my code to work with any size of U, including when U is empty.
This is working fine for me in pystan (and I think it is also allowed in R-stan, see this thread). I am now trying the same code in cmd-stan 2.19 because I want to try the new offset-multiplier feature, which isn’t yet available in pystan (still at 2.18).
I was wondering how one could pass an empty array. I agree one could use a number of tricks (e.g. having U with rows_U (>0) rows but only reading its first n_inputs rows) but I am sure there must be a cleaner way.

Best,
Luca