Opened 4 years ago
Last modified 4 years ago
#6268 closed defect
Array[1,dim] get's changed to Array[dim,1] — at Version 5
Reported by: | Andreas Heuermann | Owned by: | Per Östlund |
---|---|---|---|
Priority: | high | Milestone: | NeedsInput |
Component: | Frontend | Version: | 1.16.0 |
Keywords: | array, newFrontend | Cc: | Mahder Alemseged Gebremedhin |
Description (last modified by )
I have a model that calls a built-in function point-wise on a vector input with dimension [1,dim]
, but the output of that function is of dimension [dim,1]
.
setCommandLineOptions("-d=newInst,optdaedump"); loadString(" model mwe Real vectorA[1,4]; equation vectorA = tanh( {{10,20,30,40}} ); end mwe; "); getErrorString(); simulate(mwe); getErrorString();
When I dump the equation at the first point in the frontend with optdaedump I'll get
Equations (1, 4) ======================================== 1/1 (4): vectorA = {{tanh(10.0)}, {tanh(20.0)}, {tanh(30.0)}, {tanh(40.0)}} [dynamic |0|0|0|0|]
but I would expect to get the same dimension as the input was, so:
vectorA = {{tanh(10.0), tanh(20.0), tanh(30.0), tanh(40.0)}}
This prevents me from solving related ticket #6266.
@mahge930, @perost Any idea where to look at for this?
By the way, if I use the old frontend it gets flattened out is completely wrong.
Change History (5)
comment:1 by , 4 years ago
comment:2 by , 4 years ago
I guess it is just transposed. When looking at a second test case
model mwe2 Real vectorA[2,4]; function testFunc input Real x_in; output Real x_out; algorithm x_out := tanh(x_in); end testFunc; equation vectorA = testFunc( {{10,20,30,40}, {11,21,31,41}} ); end mwe2;
I get
vectorA = {{mwe2.testFunc(10.0), mwe2.testFunc(11.0)}, {mwe2.testFunc(20.0), mwe2.testFunc(21.0)}, {mwe2.testFunc(30.0), mwe2.testFunc(31.0)}, {mwe2.testFunc(40.0), mwe2.testFunc(41.0)}}
comment:3 by , 4 years ago
The input to the function is a matrix (1x4). So vectorization of the function call will give you back a matrix (also 1x4).
I think this is the expected behavior. Right?
comment:4 by , 4 years ago
Ahh nvm. You are getting a 4x1 matrix. I see now. Maybe a listReverse missing somewhere.
comment:5 by , 4 years ago
Description: | modified (diff) |
---|
Using
works (when using the newFrontend) as expected.