Opened 11 years ago

Closed 5 years ago

#2530 closed defect (fixed)

translation error of model in comment1: "model MatricesExp...."

Reported by: carlj@… Owned by: Martin Sjölund
Priority: high Milestone: 1.16.0
Component: Backend Version: trunk
Keywords: Cc:

Description

When trying to instantiate Modelica.Math.exp in MSL 3.2.1, one gets the following errors:

Error: Internal error Cannot vectorize call with dimension [size(A, 1)]
Error: No matching function found for abs in component <NO COMPONENT>
candidates are .SystemModeler.Internal.intAbs<function>(Integer v) => Integer
 -.SystemModeler.Internal.realAbs<function>(Real v) => Real
Error: Failed to elaborate expression: abs(B[:,i]).
Error: Wrong type or wrong number of arguments to sum(abs(B[:,i]))'.
 (in component <NO COMPONENT>).
Error: Failed to elaborate expression: sum(abs(B[:,i])).
Error: Failed to elaborate expression: sum(abs(B[:,i])) - abs(B[i,i]).
Error: Internal error Cannot vectorize call with dimension [size(A, 1)]
Error: No matching function found for abs in component <NO COMPONENT>
candidates are .SystemModeler.Internal.intAbs<function>(Integer v) => Integer
 -.SystemModeler.Internal.realAbs<function>(Real v) => Real
Error: Failed to elaborate expression: abs(B[:,i]).
Error: Wrong type or wrong number of arguments to sum(abs(B[:,i]))'.
 (in component <NO COMPONENT>).
Error: Failed to elaborate expression: sum(abs(B[:,i])).
Error: Failed to elaborate expression: sum(abs(B[:,i])) - abs(B[i,i]).
Error: Failed to elaborate rhs of CO:=sum(abs(B[:,i])) - abs(B[i,i]);.
Error: Failed to instantiate statement:
  CO:=sum(abs(B[:,i])) - abs(B[i,i]);
Error: Failed to instantiate statement:
  for i in 1:na loop
      CO:=sum(abs(B[:,i])) - abs(B[i,i]);
    RO:=sum(abs(B[i,:])) - abs(B[i,i]);
    G:=RO / radix;
    F:=1;
    S:=CO + RO;
    while (not (CO >= G or CO == 0)) loop
          F:=F * radix;
      CO:=CO * radix2;
    end while;
    G:=RO * radix;
    while (not (CO < G or RO == 0)) loop
          F:=F / radix;
      CO:=CO / radix2;
    end while;
    if not (CO + RO) / F >= 0.95 * S then 
      G:=1 / F;
      D[i]:=D[i] * F;
      B[i,:]:=B[i,:] * G;
      B[:,i]:=B[:,i] * F;
      noconv:=true;
    else

    end if;
  end for;
Error: Failed to instantiate statement:
  while (noconv) loop
      noconv:=false;
    for i in 1:na loop
          CO:=sum(abs(B[:,i])) - abs(B[i,i]);
      RO:=sum(abs(B[i,:])) - abs(B[i,i]);
      G:=RO / radix;
      F:=1;
      S:=CO + RO;
      while (not (CO >= G or CO == 0)) loop
              F:=F * radix;
        CO:=CO * radix2;
      end while;
      G:=RO * radix;
      while (not (CO < G or RO == 0)) loop
              F:=F / radix;
        CO:=CO / radix2;
      end while;
      if not (CO + RO) / F >= 0.95 * S then 
        G:=1 / F;
        D[i]:=D[i] * F;
        B[i,:]:=B[i,:] * G;
        B[:,i]:=B[:,i] * F;
        noconv:=true;
      else

      end if;
    end for;
  end while;
Error: Failed to instantiate function .Modelica.Math.Matrices.balance in scope Modelica.Math.Matrices.exp.
Error: Failed to elaborate expression: balance(A).
Error: Failed to instantiate statement:
  (Diag,Atransf):=balance(A);
Error: Failed to instantiate function .Modelica.Math.Matrices.exp in scope MatricesExp.
Error: Failed to elaborate expression: Modelica.Math.Matrices.exp(A).
Error: Error occurred while flattening model MatricesExp
Error: Internal error Instantiation of MatricesExp failed with no error message.

Change History (9)

comment:1 by carlj@…, 11 years ago

Here is a model:

model MatricesExp
  Real A[2,2] = [1,2;3,4];
  Real B[2,2] = Modelica.Math.Matrices.exp(A);
end MatricesExp;

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

I get a different error (the bug described in the messages above is a duplicate of #2529):

[Modelica 3.2.1/Math/package.mo:3259:5-3259:22:writable] Error: Wrong type or wrong number of arguments to identity(na)'.

I will keep it open until we fix the rest though.

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

Owner: changed from somebody to Martin Sjölund
Status: newassigned

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

Resolution: fixed
Status: assignedclosed

Fixed in r18627.

comment:5 by anonymous, 7 years ago

Component: FrontendBackend
Milestone: 1.9.11.13.0
Resolution: fixed
Status: closedreopened
Summary: Can not instantiate Modelica.Math.exptranslation error of model in comment1: "model MatricesExp...."

comment:6 by Francesco Casella, 6 years ago

Milestone: 1.13.01.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:7 by Francesco Casella, 6 years ago

The issue reported in comment:2 is still there.

Is it because na is a protected parameter with binding

na = size(A, 1)

where A is a variable?

comment:8 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:9 by anonymous, 5 years ago

Resolution: fixed
Status: reopenedclosed

works now on
Windows: OpenModelica v1.16.0-dev-232-g98b88856b (64-bit)
Linux: OpenModelica v1.16.0-dev-246-g46500237 (64-bit)

OM result verified with

  1. Julia exp([1 2; 3 4])
  2. WolframAlpha

https://www.wolframalpha.com/input/?i=exponential+of+matrix&assumption=%7B%22F%22%2C+%22MatrixExponentialCalculator%22%2C+%22matrixexp%22%7D+-%3E%22%7B%7B1%2C+2%7D%2C+%7B3%2C+4%7D%7D%22

Note: See TracTickets for help on using tickets.