Comments (5)
This seems to be caused by the fact that you can't use a function to set vector size. Is this a "deliberate" design choice or a bug?
I was trying to use constants to set the size of my arrays instead of hard coded values (sirFunctions.stan is auto generated). The manual says the way to define constants in stan is:
Constants in Stan are nothing more than nullary (no-argument) functions. For in-
stance, the mathematical constants π and e are represented as nullary functions
named pi() and e(). See Section 41.2 for a list of built-in constants.
So I assumed this would mean you could use such constants when defining vector/array size.
from stanc3.
Thanks for reporting. Models shouldn't translate to C++ and then not compile, so that's a bug.
As far as the language design, the intention is that a function may be used to determine a size for a block variable or local variable as long as the function is constant---it can't change values based on parameters.
The situation that's failing here is using it to define a local variable in a function:
int get_state_dim() { return 13; }
...
real[] ode(real time, real[] state, real[] theta, real[] x_r, int[] x_i) {
real dydt[get_state_dim()];
...
The problem is that it's not getting a print stream passed in.
In file included from <command-line>:0:0:
./sirStrain.hpp: In member function ‘void sirStrain_model_namespace::sirStrain_model::get_dims(std::vector<std::vector<long unsigned int> >&) const’:
./sirStrain.hpp:2822:40: error: ‘pstream__’ was not declared in this scope
dims__.push_back(get_state_dim(pstream__));
^~~~~~~~~
We'll fix this.
from stanc3.
Thanks!
Just as a follow-up. This does work as expected in the transformed data
section, but not in the transformed parameters
section or within a function
.
from stanc3.
Here's a smaller example of both where I get the same failure to compile:
functions {
int sizer() {
return 5;
}
real[] foo() {
real x[sizer()];
return x;
}
}
transformed data {
real x[sizer()] = foo();
}
transformed parameters {
real z[sizer()];
z = x;
}
from stanc3.
Still an issue in stanc3. Transferring.
from stanc3.
Related Issues (20)
- [Build] Investigate Melange as an alternative to Js_of_ocaml
- [BUG] atan2 listed as vectorised in manual, vectorised sigs not in stanc3
- Stan compiler Error when using the normal_cdf function HOT 16
- [BUG] Reporting example where new compiler failed HOT 1
- [BUG] stanc3 v. 2.33.1: build error with OCaml 4.14.1 and JaneStreet 0.16.x: `Error: This expression has type [ `Use_Sys_unix ] This is not a function; it cannot be applied`; `Error: Unbound value Set.Poly.union` HOT 4
- Typechecker: Allow predicate-based typechecking of library functions HOT 3
- [BUG] SoA request is ignored with external c++ HOT 5
- Release support for building against ocaml 5 HOT 9
- [BUG] Github action doesn't build static binary for linux platform
- Improve message and handling of internal compiler errors
- [BUG] Array declaration no longer canonicalizes from deprecated format HOT 1
- Iinformative error message for expired array syntax
- CI: Switch from the ghr script to the github CLI
- Namespacing with external C++ and `--standalone-functions` causes issues HOT 4
- [BUG] Bogus parsing error with Stanc3 JS >= 2.34 - but only with QuickJS HOT 3
- #include support in stancjs HOT 1
- New stan error in R version 4.3.3 HOT 7
- Internal compiler error: TypeError: not a function HOT 2
- Expose built-in constraint transforms as _jacobian functions
- [FR] Add `lower_upper` constrain HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stanc3.