Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VECTOR ELM MAP with dimension name in offset generates incorrect code #128

Closed
ToddFincannon opened this issue Oct 7, 2021 · 1 comment · Fixed by #129 or #190
Closed

VECTOR ELM MAP with dimension name in offset generates incorrect code #128

ToddFincannon opened this issue Oct 7, 2021 · 1 comment · Fixed by #129 or #190
Assignees
Labels
Milestone

Comments

@ToddFincannon
Copy link
Collaborator

When a subscript name appears as a constant for the offset in VECTOR ELM MAP:

DimA: A1, A2, A3 ~~|
DimX : one, two, three, four, five ~~|
x[DimX] = 1, 2, 3, 4, 5 ~~|
y[DimA] = VECTOR ELM MAP(x[three], (DimA - 1)) ~~|

the offset appears in the wrong place in the generated code:

for (size_t i = 0; i < 3; i++) {
  _y[i] = ((i + 1) - 1.0)_x[_dimx[2 + ]];
}
@ToddFincannon ToddFincannon added this to the 0.6.0 milestone Oct 7, 2021
@ToddFincannon ToddFincannon self-assigned this Oct 7, 2021
@ToddFincannon
Copy link
Collaborator Author

To fix this we needed to detect when we are on the second argument of VECTOR ELM MAP and emit expression code to vemOffset instead of directly into the expression channel. Then it can be inserted into the RHS expression that replaces the Vensim function when the rest of the parts that go into it are ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment