Interface roadmap - last draft before ratification vote

(I wrote something here: the point of this is just say that things can get hard. I’m not saying we need to go with explicit order)

Stan code

parameters {
vector[3] arr1;
row_vector[3] arr2;
}

1D arrays

arr1 = np.array([1,2,3])
arr2 = np.array([1,2,3])

print(arr1.dot(arr2), arr1.dot(arr2.T), arr1.T.dot(arr2), arr1.T.dot(arr2.T))
# (14, 14, 14, 14)

2D array

arr1 = np.array([[1],[2],[3]])
arr2 = np.array([[1,2,3]])

print(arr1.dot(arr2))
# [[1 2 3]
#  [2 4 6]
#  [3 6 9]]

print("Shape:", arr1.dot(arr2).shape)
# Shape: (3, 3)

print(arr1.T.dot(arr2.T))
# [[14]]

print("Shape:", arr1.T.dot(arr2.T).shape)
# Shape: (1, 1)

Broadcasting

arr1 = np.repeat(np.expand_dims(np.array([[1],[2],[3]]), axis=2), 200, axis=2)
arr1.shape
# (3, 1, 200)

arr2 = np.repeat(np.expand_dims(np.array([[1,2,3]]), axis=2), 200, axis=2)
arr2.shape
# (1, 3, 200)

print(np.einsum("ijn,jkn->ikn", arr1, arr2)[:, :, 0])
# [[1 2 3]
#  [2 4 6]
#  [3 6 9]

print("Shape:", np.einsum("ijn,jkn->ikn", arr1, arr2).shape)
# Shape: (3, 3, 200)

And then

vector[3] arr1[10];
row_vector[3] arr2[10];

Should the output shape be
(10,3) & (10,3)
or
(10,3,1) & (10,1,3)

Also, truncating dimensions is not cool with complex models :)