Ticket #2031: TestSolve.mo

File TestSolve.mo, 816 bytes (added by Christian Schubert, 12 years ago)
Line 
1model TestSolve
2 Real A[5,5]={{-725/100,-875/100,0,-5,0},{-875/100,-125/10,0,-56/10,8/10},{0,0,-5,24/10,-32/10},{-5,-56/10,24/10,0,0},{0,8/10,-32/10,0,0}};
3 Real B[5,7]={{-15/10,0,2,0,-875/100,0,-1762/100},{-3,0,2,0,-125/10,0,-1762/100},{-2,0,0,0,-5,0,0},{0,0,0,0,0,0,6/10},{0,0,0,0,0,0,45/100}};
4 Real X1[5,7];
5 Real X2[5,7];
6 Real XRef[5,7]={{-(32/41),0,0,0,-(80/41),0,-(15/41)},{32/41,0,0,0,80/41,0,117/656},{8/41,0,0,0,20/41,0,-(63/656)},{27/410,0,-(2/5),0,191/164,0,1227497/328000},{303/820,0,-(3/10),0,549/328,0,1939683/656000}};
7 Real d1[5,7]=X1-XRef;
8 Real d2[5,7]=X2-XRef;
9 Real err1=sum(d1.*d1) "Error 1";
10 Real err2=sum(d2.*d2) "Error 2";
11algorithm
12 for i in 1:7 loop
13 X1[:,i]:=Modelica.Math.Matrices.solve(A,B[:,i]);
14 end for;
15 X2 := Modelica.Math.Matrices.solve2(A,B);
16end TestSolve;
17