Opened 9 years ago
Last modified 9 years ago
#3538 new discussion
function outputs array slice
Reported by: | Volker Waurich | Owned by: | somebody |
---|---|---|---|
Priority: | normal | Milestone: | Future |
Component: | Backend | Version: | |
Keywords: | Cc: | Lennart Ochel, Mahder Alemseged Gebremedhin, Per Östlund, Willi Braun |
Description
Hi,
A model of mine has a function call that outputs an array slice, which is part of a 2-dimensional array. This call is inside a for-loop:
Something like: (_,x[:,i],_) := f(a);
When compiling, I get the template-error from daeExpCrefLhsSimContext:
Template error: This should have been handled in indexed assign and should not have gotten here x[:,i]
Can anybody explain where exactly these things have to be handled?
I dont know what is meant with "indexed assign".
Thanks.
Change History (5)
comment:1 by , 9 years ago
comment:2 by , 9 years ago
These are the template functions from where this message comes from. But I would like to know how and especially where array slices as lhs-crefs should have been processed as indicated by this message.
follow-up: 4 comment:3 by , 9 years ago
You need to create a temporary array for these variables and handle it either by rewriting the expression, or making the template do the temporary array+copy. You can't simply pass the contiguous memory for these assignments since the slice might not be contiguous.
comment:4 by , 9 years ago
Replying to sjoelund.se:
You need to create a temporary array for these variables and handle it either by rewriting the expression, or making the template do the temporary array+copy. You can't simply pass the contiguous memory for these assignments since the slice might not be contiguous.
I see.Thanks for the answer.
comment:5 by , 9 years ago
I think the problem is in the FrontEnd or BackEnd somewhere. I put that error message there to just remind you to check what is actually causing the assignment to reach that point.
That specific assignemtn should have been handled differently. Normally you generate the lhs (daeExpCrefLhs*) and rhs (daeExpCrefLhs*) separately and assign them. However assignments involving slices are handled differently since we need to generate extra code handling the slices.
If you could give me a simplified version of your model I can take a look.
I'm not sure if the following helps: