Opened 11 years ago

Closed 11 years ago

#2639 closed defect (invalid)

Tuple Assignment Error while compiling SVD from LAPACK

Reported by: salmanfar@… Owned by: probably noone
Priority: high Milestone: 1.9.1
Component: Backend Version: trunk
Keywords: Cc:

Description (last modified by sjoelund.se)

I want to use SVD from LAPACK but get this error about tuples assignment. I compiled on OM version 1.8.1

function SVDRLS
  import Modelica.Math.Matrices;
  input Real A[3,2];
  output Real sigmasvd[3,2];
  output Real Usvd[3,3];
  output Real VTsvd[2,2];
algorithm
(sigmasvd,Usvd,VTsvd):=Matrices.singularValues(A);
end SVDRLS;
[<interactive>:10:1-10:50:writable] Error: Type mismatch in assignment in (sigmasvd,Usvd,VTsvd) := Modelica.Math.Matrices.singularValues({{A[1,1],A[1,2]},{A[2,1],A[2,2]},{A[3,1],A[3,2]}}) of (Real[3, 2], Real[3, 3], Real[2, 2]) := (Real[:], Real[:, :], Real[:, :]) 
[<interactive>:10:1-10:50:writable] Error: Tuple assignment only allowed when rhs is function call (in Modelica.Math.Matrices.singularValues({{A[1,1],A[1,2]},{A[2,1],A[2,2]},{A[3,1],A[3,2]}}))

Change History (2)

comment:1 Changed 11 years ago by sjoelund.se

  • Description modified (diff)

comment:2 Changed 11 years ago by perost

  • Resolution set to invalid
  • Status changed from new to closed

My apologies, it seems like my first assessment on the forum was wrong, the type mismatch error message is actually correct. When I had a closer look I noticed that the first output of singularValues is:

output Real[min(size(A, 1), size(A, 2))] sigma;

I missed the call to min when I first looked at it, and thought sigma had two dimensions due to the separating comma. So the correct declaration of sigmasvd in your function would be sigmasvd[2] or sigmasvd[min(size(A, 1), size(A, 2))].

Note: See TracTickets for help on using tickets.