Opened 11 years ago
Closed 10 years ago
#2707 closed defect (fixed)
Unparsing of expression n*(n*v) produces wrong result for vectors
Reported by: | Owned by: | Per Östlund | |
---|---|---|---|
Priority: | blocker | Milestone: | 1.9.1 |
Component: | Frontend | Version: | trunk |
Keywords: | Cc: |
Description
Unparsing destroys the following model by removing parentheses:
model TimesParentheses parameter Real[3] n = {0, 1, 0} "Normalized vector"; parameter Real[3] v = {1, 2, 3} "Vector to project on n" Real[3] x "Projection of v on n"; equation x = n * (n * v); end TimesParentheses;
After unparsing, the equation has changed to
x = n * n * v;
which evaluates as
x = (n * n) * v;
which is a totally incorrect way of computing a projection.
Change History (5)
comment:1 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:2 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:3 by , 11 years ago
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Thank you for the fast fix!
However, here is a modified model that is unparsed incorrectly:
model TimesParentheses parameter Real[3] a = {1,1,1}; parameter Real[3] b = {1,0,1}; parameter Real[3] n = {0, 1, 0}; parameter Real[3] v = {1, 2, 3}; Real[3] x; equation x = n * ((n * v)/(a*b)); end TimesParentheses;
which now is unparsed as:
model TimesParentheses parameter Real[3] a = {1, 1, 1}; parameter Real[3] b = {1, 0, 1}; parameter Real[3] n = {0, 1, 0}; parameter Real[3] v = {1, 2, 3}; Real[3] x; equation x = n * n * v / (a * b); end TimesParentheses;
leading to the same problem as before.
comment:4 by , 10 years ago
Ok, I've made another fix in r20918. The expression in the model above is now unparsed as n * (n * v / (a * b))
, which seems correct to me.
Edit: Corrected parentheses.
comment:5 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
Thanks perost, this seems to work like a charm!
Note:
See TracTickets
for help on using tickets.
Fixed in r20866.