Opened 9 years ago

Last modified 3 years ago

#3592 assigned defect

Eigen values fails with error

Reported by: Adeel Asghar Owned by: Karim Adbdelhak
Priority: high Milestone:
Component: Code Generation Version: v1.14.0-dev-nightly
Keywords: Cc: dma@…, davide.bazzi@…

Description

Using Matrices.eigenValues results in following error,

[CodegenCFunctions.tpl: 4698:15-4698:15]: Template error: This should have been handled in indexed assign and should not have gotten here. eigenvalues[:,2]

Use the attached file. If a parameter prefix is added to Real A then it works fine.

Attachments (1)

EigenTest.mo (217 bytes ) - added by Adeel Asghar 9 years ago.

Download all attachments as: .zip

Change History (21)

by Adeel Asghar, 9 years ago

Attachment: EigenTest.mo added

comment:1 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:2 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

comment:3 by Martin Sjölund, 8 years ago

Milestone: 1.10.01.11.0

Ticket retargeted after milestone closed

comment:4 by Martin Sjölund, 8 years ago

Milestone: 1.11.01.12.0

Milestone moved to 1.12.0 due to 1.11.0 already being released.

comment:5 by kgkhoroshev, 8 years ago

The bug is still actual(ver. 1.12.0 on Ubuntu 16.04). Thanks to adeas31 for "a parameter prefix" solution.

comment:6 by Francesco Casella, 7 years ago

Milestone: 1.12.0Future

The milestone of this ticket has been reassigned to "Future".

If you think the issue is still valid and relevant for you, please select milestone 1.13.0 for back-end, code generation and run-time issues, or 2.0.0 for front-end issues.

If you are aware that the problem is no longer present, please select the milestone corresponding to the version of OMC you used to check that, and set the status to "worksforme".

In both cases, a short informative comment would be welcome.

comment:7 by Francesco Casella, 6 years ago

Milestone: Future1.14.0

This is actually also relevant for work we are carrying out at Politecnico.

I did some analysis. If A is defined as a parameter, the old frontend evaluates the eigenValues() function during flattening, so that the code generation is trivial (BTW, the new frontend doesn't do that, therefore the model also fails with parameter A).

Apparently, something goes wrong with the code generation when the eigenValues function is involved.

comment:8 by Francesco Casella, 6 years ago

This model shows that the problem is with code generation for the external function dgeev()

model M
  Real A[3,3] = {{1, 0, 0}, {0,1,0}, {0,0,1}};
  Real eigval[3,2];
  Integer info;
  Real eigvec[3,3];
equation
 (eigval[:,1], eigval[:,2], eigvec, info) = Modelica.Math.Matrices.LAPACK.dgeev(A);
end M;

The error output is:

[CodegenCFunctions.tpl: 4978:15-4978:15]: Template error: daeExpCrefLhsSimContext:
This should have been handled in indexed assign and should not have gotten here 
eigval[:,2].

comment:9 by Francesco Casella, 6 years ago

Cc: davide.bazzi@… added
Owner: changed from Per Östlund to Karim Adbdelhak
Status: newassigned
Version: v1.14.0-dev-nightly

@Karim.Abdelhak, I tentatively assign this to you, feel free to reassign it to somebody else if you deem it appropriate.

comment:10 by Francesco Casella, 6 years ago

From what I understand, it is a problem with external functions returning more than one output

in reply to:  8 ; comment:11 by Karim Adbdelhak, 6 years ago

Replying to casella:

The error output is:

[CodegenCFunctions.tpl: 4978:15-4978:15]: Template error: daeExpCrefLhsSimContext:
This should have been handled in indexed assign and should not have gotten here 
eigval[:,2].

Just to a question to clarify it for me:
Is it expected to be flattened out to eigval[1,2],eigval[2,2],... or is the code generation expected to generate arrays in the target code?

As it seems we flattened it out before, but generally we want to avoid flattening as much as possible in the future. I will try to recover the old behaviour, but i guess we have to think about it in general.

in reply to:  11 comment:12 by Francesco Casella, 6 years ago

Replying to Karim.Abdelhak:

Just to a question to clarify it for me:
Is it expected to be flattened out to eigval[1,2],eigval[2,2],... or is the code generation expected to generate arrays in the target code?

I guess for the time being our strategy is to get omc to deal with as many models as possible using the old strategy (-> full flattening to scalars).

As a medium-long term goal we should implement a vector-preserving backend, but that's another story, we need to get all valid Modelica models to work ASAP, even if the efficiency is not optimal.

As it seems we flattened it out before, but generally we want to avoid flattening as much as possible in the future. I will try to recover the old behaviour, but i guess we have to think about it in general.

Agreed. BTW, which old behaviour do you refer to? This ticket has been open for three years, so I guess this function never worked at all so far in OMC.

comment:13 by Francesco Casella, 6 years ago

@karim, your PR #2979 apparently didn't solve the problem, I'm still getting

[CodegenCFunctions.tpl: 5030:15-5030:15]: Template error: This should have been handled in indexed assign and should not have gotten here. eigenvalues[:,2].

if I run the test attached to this ticket

comment:14 by Francesco Casella, 6 years ago

@karim, can you have a look at this issue?

in reply to:  14 comment:15 by Karim Adbdelhak, 6 years ago

Replying to casella:

@karim, can you have a look at this issue?

I have quite some work to do at the moment, but when i start to work on tickets again i will look deeper into this issue.

comment:16 by Francesco Casella, 6 years ago

OK, no problem :)

comment:17 by Francesco Casella, 5 years ago

Milestone: 1.14.01.16.0

Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0

comment:18 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:19 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:20 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.