Changeset 1093 for branches/maintenance/2.2.2/Modelica
- Timestamp:
- 02/27/08 22:37:35 (9 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/maintenance/2.2.2/Modelica/Math/package.mo
r573 r1093 1419 1419 "Real-valued eigenvector matrix"; 1420 1420 1421 annotation (preferedView="info", 1422 Coordsys( 1423 extent=[-100, -100; 100, 100], 1424 grid=[2, 2], 1425 component=[20, 20]), 1426 Window( 1427 x=0.4, 1428 y=0.4, 1429 width=0.6, 1430 height=0.6), 1421 annotation ( 1431 1422 Documentation(info="<HTML> 1432 1423 <h4>Syntax</h4> … … 1482 1473 </HTML> 1483 1474 ")); 1475 1484 1476 protected 1485 1477 Integer info; … … 1487 1479 Boolean onlyEigenvalues = false; 1488 1480 algorithm 1481 if size(A,1) > 0 then 1489 1482 if onlyEigenvalues then 1490 1483 (eigenvalues[:, 1],eigenvalues[:, 2],info) := LAPACK.dgeev_eigenValues(A); … … 1496 1489 \"Matrices.eigenvalues\" is not possible, since the 1497 1490 numerical algorithm does not converge."); 1491 end if; 1498 1492 end eigenValues; 1499 1493 … … 1572 1566 input Real A[:, :] "Matrix"; 1573 1567 output Real sigma[min(size(A, 1), size(A, 2))] "Singular values"; 1574 output Real U[size(A, 1), size(A, 1)]= zeros(size(A, 1),size(A, 1))1568 output Real U[size(A, 1), size(A, 1)]=identity(size(A, 1)) 1575 1569 "Left orthogonal matrix"; 1576 output Real VT[size(A, 2), size(A, 2)]= zeros(size(A, 2),size(A, 2))1570 output Real VT[size(A, 2), size(A, 2)]=identity(size(A, 2)) 1577 1571 "Transposed right orthogonal matrix "; 1578 1572 1579 annotation ( preferedView="info",Documentation(info="<HTML>1573 annotation ( Documentation(info="<HTML> 1580 1574 <h4>Syntax</h4> 1581 1575 <blockquote><pre> … … 1624 1618 Integer n=min(size(A, 1), size(A, 2)) "Number of singular values"; 1625 1619 algorithm 1626 (sigma,U,VT,info) := Matrices.LAPACK.dgesvd(A); 1620 if n>0 then 1621 (sigma,U,VT,info) := Modelica.Math.Matrices.LAPACK.dgesvd(A); 1627 1622 assert(info == 0, "The numerical algorithm to compute the 1628 1623 singular value decomposition did not converge"); 1624 end if; 1629 1625 end singularValues; 1630 1626 … … 1690 1686 "If eps > 0, the singular values are checked against eps; otherwise eps=max(size(A))*norm(A)*Modelica.Constants.eps is used"; 1691 1687 output Integer result "Rank of matrix A"; 1688 1689 annotation (Documentation(info="<html> 1690 1691 </html>")); 1692 1692 protected 1693 1693 Integer n=min(size(A, 1), size(A, 2)); 1694 1694 Integer i=n; 1695 Real sigma[n] =singularValues(A) "Singular values";1696 Real eps2 =if eps > 0 then eps else max(size(A))*sigma[1]*Modelica.Constants.eps;1695 Real sigma[n]; 1696 Real eps2; 1697 1697 algorithm 1698 result := n;1699 while i > 0 loop1700 if sigma[i] > eps2 then1701 result := i;1702 i := 0;1703 end if;1704 i := i - 1;1705 end while;1706 1707 annotation (Documentation(info="<html>1708 1709 </html>"));1698 result := 0; 1699 if n > 0 then 1700 sigma := Modelica.Math.Matrices.singularValues(A); 1701 eps2 := if eps > 0 then eps else max(size(A))*sigma[1]*Modelica.Constants.eps; 1702 while i > 0 loop 1703 if sigma[i] > eps2 then 1704 result := i; 1705 i := 0; 1706 end if; 1707 i := i - 1; 1708 end while; 1709 end if; 1710 1710 end rank; 1711 1711
