Changeset 1092
- Timestamp:
- 02/27/08 22:34:27 (6 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/maintenance/3.0/Modelica/Math/package.mo
r1083 r1092 8 8 9 9 annotation ( 10 11 10 Invisible=true, 12 11 Icon(coordinateSystem(preserveAspectRatio=true, extent={{-100,-100},{100,100}}), … … 413 412 annotation ( 414 413 version="0.8.1", 415 versionDate="2004-08-21" 416 , 414 versionDate="2004-08-21", 417 415 Documentation(info="<HTML> 418 416 <h4>Library content</h4> … … 791 789 792 790 annotation ( 793 794 791 Documentation(info="<HTML> 795 792 <h4>Syntax</h4> … … 829 826 <a href=\"Modelica://Modelica.Math.Matrices.LU_solve\">Matrices.LU_solve</a> 830 827 </HTML>")); 828 831 829 protected 832 830 Integer info; … … 847 845 848 846 annotation ( 849 850 847 Documentation(info="<HTML> 851 848 <h4>Syntax</h4> … … 891 888 <a href=\"Modelica://Modelica.Math.Matrices.LU_solve2\">Matrices.LU_solve2</a> 892 889 </HTML>")); 890 893 891 protected 894 892 Integer info; … … 909 907 910 908 annotation ( 911 912 909 Documentation(info="<HTML> 913 910 <h4>Syntax</h4> … … 935 932 </p> 936 933 </HTML>")); 934 937 935 protected 938 936 Integer info; … … 956 954 957 955 annotation ( 958 959 956 Documentation(info="<HTML> 960 957 <h4>Syntax</h4> … … 990 987 </p> 991 988 </HTML>")); 989 992 990 protected 993 991 Integer info; … … 1377 1375 1378 1376 annotation ( 1379 1380 1377 Documentation(info="<HTML> 1381 1378 <h4>Syntax</h4> … … 1431 1428 </HTML> 1432 1429 ")); 1430 1433 1431 protected 1434 1432 Integer info; … … 1436 1434 Boolean onlyEigenvalues = false; 1437 1435 algorithm 1436 if size(A,1) > 0 then 1438 1437 if onlyEigenvalues then 1439 1438 (eigenvalues[:, 1],eigenvalues[:, 2],info) := LAPACK.dgeev_eigenValues(A); … … 1445 1444 \"Matrices.eigenvalues\" is not possible, since the 1446 1445 numerical algorithm does not converge."); 1446 end if; 1447 1447 end eigenValues; 1448 1448 … … 1457 1457 1458 1458 annotation ( 1459 1460 1459 Documentation(info="<HTML> 1461 1460 <h4>Syntax</h4> … … 1488 1487 <a href=\"Modelica://Modelica.Math.Matrices.eigenValues\">Matrices.eigenValues</a> 1489 1488 </HTML>")); 1489 1490 1490 protected 1491 1491 Integer n=size(eigenValues, 1); … … 1513 1513 input Real A[:, :] "Matrix"; 1514 1514 output Real sigma[min(size(A, 1), size(A, 2))] "Singular values"; 1515 output Real U[size(A, 1), size(A, 1)]= zeros(size(A, 1),size(A, 1))1515 output Real U[size(A, 1), size(A, 1)]=identity(size(A, 1)) 1516 1516 "Left orthogonal matrix"; 1517 output Real VT[size(A, 2), size(A, 2)]= zeros(size(A, 2),size(A, 2))1517 output Real VT[size(A, 2), size(A, 2)]=identity(size(A, 2)) 1518 1518 "Transposed right orthogonal matrix "; 1519 1519 … … 1565 1565 Integer n=min(size(A, 1), size(A, 2)) "Number of singular values"; 1566 1566 algorithm 1567 (sigma,U,VT,info) := Matrices.LAPACK.dgesvd(A); 1567 if n>0 then 1568 (sigma,U,VT,info) := Modelica.Math.Matrices.LAPACK.dgesvd(A); 1568 1569 assert(info == 0, "The numerical algorithm to compute the 1569 1570 singular value decomposition did not converge"); 1571 end if; 1570 1572 end singularValues; 1571 1573 … … 1631 1633 "If eps > 0, the singular values are checked against eps; otherwise eps=max(size(A))*norm(A)*Modelica.Constants.eps is used"; 1632 1634 output Integer result "Rank of matrix A"; 1635 1636 annotation (Documentation(info="<html> 1637 1638 </html>")); 1633 1639 protected 1634 1640 Integer n=min(size(A, 1), size(A, 2)); 1635 1641 Integer i=n; 1636 Real sigma[n] =singularValues(A) "Singular values";1637 Real eps2 =if eps > 0 then eps else max(size(A))*sigma[1]*Modelica.Constants.eps;1642 Real sigma[n]; 1643 Real eps2; 1638 1644 algorithm 1639 result := n;1640 while i > 0 loop1641 if sigma[i] > eps2 then1642 result := i;1643 i := 0;1644 end if;1645 i := i - 1;1646 end while;1647 1648 annotation (Documentation(info="<html>1649 1650 </html>"));1645 result := 0; 1646 if n > 0 then 1647 sigma := Modelica.Math.Matrices.singularValues(A); 1648 eps2 := if eps > 0 then eps else max(size(A))*sigma[1]*Modelica.Constants.eps; 1649 while i > 0 loop 1650 if sigma[i] > eps2 then 1651 result := i; 1652 i := 0; 1653 end if; 1654 i := i - 1; 1655 end while; 1656 end if; 1651 1657 end rank; 1652 1658 … … 1716 1722 Implemented. 1717 1723 </li> 1718 </html>") 1719 ); 1724 </html>")); 1720 1725 algorithm 1721 1726 … … 1760 1765 1761 1766 annotation ( 1762 1763 1767 Documentation(info="<HTML> 1764 1768 <p>This function computes</p> … … 1823 1827 </ul> 1824 1828 </html>")); 1829 1825 1830 protected 1826 1831 parameter Integer nmax=21; … … 1918 1923 1919 1924 annotation ( 1920 1921 1925 Documentation(info="<HTML> 1922 1926 <p> … … 2076 2080 2077 2081 annotation ( 2078 2079 2082 Documentation(info="<HTML> 2080 2083 <p> … … 2117 2120 </ul> 2118 2121 </html>")); 2122 2119 2123 algorithm 2120 2124 F := [A, B, zeros(na, nb); zeros(2*nb, na), zeros(2*nb, nb), [identity(nb); … … 2149 2153 2150 2154 annotation ( 2151 2152 2155 Documentation(info="Lapack documentation 2153 2156 Purpose … … 2226 2229 have converged. 2227 2230 ")); 2231 2228 2232 external "Fortran 77" dgeev("N", "V", n, Awork, n, eigenReal, eigenImag, 2229 2233 eigenVectors, n, eigenVectors, n, work, size(work, 1), info) … … 2250 2254 2251 2255 annotation ( 2252 2253 2256 Documentation(info="Lapack documentation 2254 2257 Purpose … … 2529 2532 2530 2533 annotation ( 2531 2532 2534 Documentation(info="Lapack documentation 2533 2535 Purpose … … 2622 2624 < 0: if INFO = -i, the i-th argument had an illegal value 2623 2625 ")); 2626 2624 2627 end dgels_vec; 2625 2628 … … 2647 2650 2648 2651 annotation ( 2649 2650 2652 Documentation(info="Lapack documentation 2651 2653 Purpose … … 2738 2740 = 0: successful exit 2739 2741 < 0: if INFO = -i, the i-th argument had an illegal value ")); 2742 2740 2743 end dgelsx_vec; 2741 2744 … … 2794 2797 has been completed, but the factor U is exactly 2795 2798 singular, so the solution could not be computed. 2796 ") );2799 ")); 2797 2800 2798 2801 external "FORTRAN 77" dgesv(size(A, 1), size(B, 2), Awork, size(A, 1), ipiv, … … 2815 2818 Same as function LAPACK.dgesv, but right hand side is a vector and not a matrix. 2816 2819 For details of the arguments, see documentation of dgesv. 2817 ") );2820 ")); 2818 2821 2819 2822 external "FORTRAN 77" dgesv(size(A, 1), 1, Awork, size(A, 1), ipiv, x, size( … … 2925 2928 = 0: successful exit. 2926 2929 < 0: if INFO = -i, the i-th argument had an illegal value. 2927 ") );2930 ")); 2928 2931 end dgglse_vec; 2929 2932 … … 2989 2992 2990 2993 completed unless i = N. 2991 ") );2994 ")); 2992 2995 2993 2996 external "FORTRAN 77" dgtsv(size(diag, 1), size(B, 2), subdiagwork, … … 3015 3018 Same as function LAPACK.dgtsv, but right hand side is a vector and not a matrix. 3016 3019 For details of the arguments, see documentation of dgtsv. 3017 ") );3020 ")); 3018 3021 3019 3022 external "FORTRAN 77" dgtsv(size(diag, 1), 1, subdiagwork, diagwork, … … 3099 3102 Array elements marked * are not used by the routine; elements marked 3100 3103 + need not be set on entry, but are required by the routine to store 3101 elements of U because of fill-in resulting from the row interchanges.") 3102 ); 3104 elements of U because of fill-in resulting from the row interchanges.")); 3103 3105 3104 3106 external "FORTRAN 77" dgbsv(n, kLower, kUpper, size(B, 2), Awork, size( … … 3122 3124 annotation ( 3123 3125 Documentation(info="Lapack documentation: 3124 ") );3126 ")); 3125 3127 3126 3128 external "FORTRAN 77" dgbsv(n, kLower, kUpper, 1, Awork, size(Awork, 1), … … 3236 3238 did not converge to zero. See the description of WORK 3237 3239 above for details. 3238 ") );3240 ")); 3239 3241 3240 3242 external "Fortran 77" dgesvd("A", "A", size(A, 1), size(A, 2), Awork, size( … … 3351 3353 did not converge to zero. See the description of WORK 3352 3354 above for details. 3353 ") );3355 ")); 3354 3356 3355 3357 external "Fortran 77" dgesvd("N", "N", size(A, 1), size(A, 2), Awork, size( … … 3413 3415 singular, and division by zero will occur if it is used 3414 3416 to solve a system of equations. 3415 ") );3417 ")); 3416 3418 3417 3419 external "FORTRAN 77" dgetrf(size(A, 1), size(A, 2), LU, size(A, 1), pivots, … … 3478 3480 = 0: successful exit 3479 3481 < 0: if INFO = -i, the i-th argument had an illegal value 3480 ") );3482 ")); 3481 3483 3482 3484 protected … … 3546 3548 = 0: successful exit 3547 3549 < 0: if INFO = -i, the i-th argument had an illegal value 3548 ") );3550 ")); 3549 3551 3550 3552 protected … … 3607 3609 < 0: if INFO = -i, the i-th argument had an illegal value 3608 3610 > 0: if INFO = i, U(i,i) is exactly zero; the matrix is 3609 singular and its inverse could not be computed.") 3610 ); 3611 singular and its inverse could not be computed.")); 3611 3612 protected 3612 3613 Integer lwork=min(10, size(LU, 1))*size(LU, 1) "Length of work array"; … … 3683 3684 The matrix P is represented in jpvt as follows: If 3684 3685 jpvt(j) = i 3685 then the jth column of P is the ith canonical unit vector.") 3686 ); 3686 then the jth column of P is the ith canonical unit vector.")); 3687 3687 protected 3688 3688 Integer info; … … 3751 3751 = 0: successful exit 3752 3752 < 0: if INFO = -i, the i-th argument has an illegal value 3753 ") );3753 ")); 3754 3754 3755 3755 protected … … 3800 3800 3801 3801 annotation ( 3802 3803 3802 Icon(coordinateSystem( 3804 3803 preserveAspectRatio=true, … … 3873 3872 </p> 3874 3873 </html>")); 3874 3875 3875 external "C" y = sin(u); 3876 3876 annotation(Library="ModelicaExternalC"); … … 3884 3884 3885 3885 annotation ( 3886 3887 3886 Icon(coordinateSystem( 3888 3887 preserveAspectRatio=true, … … 3953 3952 </p> 3954 3953 </html>")); 3954 3955 3955 external "C" y = cos(u); 3956 3956 annotation(Library="ModelicaExternalC"); … … 3964 3964 3965 3965 annotation ( 3966 3967 3966 Icon(coordinateSystem( 3968 3967 preserveAspectRatio=true, … … 4036 4035 </p> 4037 4036 </html>")); 4037 4038 4038 external "C" y = tan(u); 4039 4039 annotation(Library="ModelicaExternalC"); … … 4047 4047 4048 4048 annotation ( 4049 4050 4049 Icon(coordinateSystem( 4051 4050 preserveAspectRatio=true, … … 4120 4119 </p> 4121 4120 </html>")); 4121 4122 4122 external "C" y = asin(u); 4123 4123 annotation(Library="ModelicaExternalC"); … … 4131 4131 4132 4132 annotation ( 4133 4134 4133 Icon(coordinateSystem( 4135 4134 preserveAspectRatio=true, … … 4200 4199 </p> 4201 4200 </html>")); 4201 4202 4202 external "C" y = acos(u); 4203 4203 annotation(Library="ModelicaExternalC"); … … 4211 4211 4212 4212 annotation ( 4213 4214 4213 Icon(coordinateSystem( 4215 4214 preserveAspectRatio=true, … … 4274 4273 </p> 4275 4274 </html>")); 4275 4276 4276 external "C" y = atan(u); 4277 4277 annotation(Library="ModelicaExternalC"); … … 4286 4286 4287 4287 annotation ( 4288 4289 4288 Icon(coordinateSystem( 4290 4289 preserveAspectRatio=true, … … 4379 4378 </HTML> 4380 4379 ")); 4380 4381 4381 external "C" y = atan2(u1, u2); 4382 4382 annotation(Library="ModelicaExternalC"); … … 4394 4394 4395 4395 annotation ( 4396 4397 4396 Icon(coordinateSystem( 4398 4397 preserveAspectRatio=true, … … 4483 4482 </HTML> 4484 4483 ")); 4484 4485 4485 protected 4486 4486 Real pi = Modelica.Constants.pi; … … 4498 4498 4499 4499 annotation ( 4500 4501 4500 Icon(coordinateSystem( 4502 4501 preserveAspectRatio=true, … … 4573 4572 </p> 4574 4573 </html>")); 4574 4575 4575 external "C" y = sinh(u); 4576 4576 annotation(Library="ModelicaExternalC"); … … 4584 4584 4585 4585 annotation ( 4586 4587 4586 Icon(coordinateSystem( 4588 4587 preserveAspectRatio=true, … … 4659 4658 </p> 4660 4659 </html>")); 4660 4661 4661 external "C" y = cosh(u); 4662 4662 annotation(Library="ModelicaExternalC"); … … 4670 4670 4671 4671 annotation ( 4672 4673 4672 Icon(coordinateSystem( 4674 4673 preserveAspectRatio=true, … … 4733 4732 </p> 4734 4733 </html>")); 4734 4735 4735 external "C" y = tanh(u); 4736 4736 annotation(Library="ModelicaExternalC"); … … 4744 4744 4745 4745 annotation ( 4746 4747 4746 Icon(coordinateSystem( 4748 4747 preserveAspectRatio=true, … … 4820 4819 </p> 4821 4820 </html>")); 4821 4822 4822 algorithm 4823 4823 y :=Modelica.Math.log(u + sqrt(u*u + 1)); … … 4832 4832 4833 4833 annotation ( 4834 4835 4834 Icon(coordinateSystem( 4836 4835 preserveAspectRatio=true, … … 4930 4929 4931 4930 annotation ( 4932 4933 4931 Icon(coordinateSystem( 4934 4932 preserveAspectRatio=true, … … 5003 5001 </p> 5004 5002 </html>")); 5003 5005 5004 external "C" y = exp(u); 5006 5005 annotation(Library="ModelicaExternalC"); … … 5014 5013 5015 5014 annotation ( 5016 5017 5015 Icon(coordinateSystem( 5018 5016 preserveAspectRatio=true, … … 5101 5099 5102 5100 annotation ( 5103 5104 5101 Icon(coordinateSystem( 5105 5102 preserveAspectRatio=true,
