Is there anything an UnsizedType
can do that a SizedType
couldn't do?
#884
Unanswered
SteveBronder
asked this question in
Q&A
Replies: 1 comment 1 reply
-
The sizes of function arguments are not specified in the Stan language.
If we knew no one outside of Stan would call these functions we could
attempt to infer their sizes in certain cases, but they are also exposed
externally.
…On Thu, Apr 15, 2021 at 15:42 Steve Bronder ***@***.***> wrote:
I'm messing with the for loop stuff of #877
<#877> and right now the
goal is to take
vector[N] x;vector[N] y = // fill thisfor (i in 1:N) {
x[i] = exp(y[i]);
}
and transform it to
x[1:N] = exp(y[1:N]);
That's fine, integer sequence subsetting and assignment in the C++ can
have a trick that just looks if the sequence start and end is the same size
as the input to make this pretty cheap. We could even write an
index_positive_min_max for this special case to make this very trivial.
But it would be nice to be able to do
x = exp(y);
But the problem is that functions only hold an UnsizedType as the
arguments and so we lose size information for checking that the rhs is of
size N so we can't do the above. I think it would be a lot of effort so
not sure if worth it, but is there any reason we have an UnsizedType here
instead of a SizedType? Is it just that it is much easier to not have to
worry about how to represent the dims?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#884>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGET3AHR6GJ2JF25AHF3ALTI46Q5ANCNFSM43AEG67A>
.
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm messing with the for loop stuff of #877 and right now the goal is to take
and transform it to
That's fine, integer sequence subsetting and assignment in the C++ can have a trick that just looks if the sequence start and end is the same size as the input to make this pretty cheap. We could even write an
index_positive_min_max
for this special case to make this very trivial.But it would be nice to be able to do
But the problem is that functions only hold an
UnsizedType
as the arguments and so we lose size information for checking that the rhs is of sizeN
so we can't do the above. I think it would be a lot of effort so not sure if worth it, but is there any reason we have anUnsizedType
here instead of aSizedType
? Is it just that it is much easier to not have to worry about how to represent the dims?Beta Was this translation helpful? Give feedback.
All reactions