diff options
author | Pierre Marechal <pierre.marechal@scilab.org> | 2007-06-25 14:47:27 +0000 |
---|---|---|
committer | Pierre Marechal <pierre.marechal@scilab.org> | 2007-06-25 14:47:27 +0000 |
commit | 36d09c1c26e0350d30a2e9a142ec540be5e7a69a (patch) | |
tree | a7112005a7034e09f225b3e3731bde93b985d4de /tests | |
parent | 33ac9be1a00ba63547b34f328ff1e8aa06640d3d (diff) | |
download | scilab-36d09c1c26e0350d30a2e9a142ec540be5e7a69a.zip scilab-36d09c1c26e0350d30a2e9a142ec540be5e7a69a.tar.gz |
Add tests for ricatti() function, thx to Sabine Gauzere
Diffstat (limited to 'tests')
-rw-r--r-- | tests/basic_tests/slicot.dia.ref | 69 | ||||
-rw-r--r-- | tests/basic_tests/slicot.tst | 38 |
2 files changed, 107 insertions, 0 deletions
diff --git a/tests/basic_tests/slicot.dia.ref b/tests/basic_tests/slicot.dia.ref index 03d971e..58038b5 100644 --- a/tests/basic_tests/slicot.dia.ref +++ b/tests/basic_tests/slicot.dia.ref | |||
@@ -1694,3 +1694,72 @@ X = linmeq(3,A,C,flag); | |||
1694 | if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then bugmes();quit;end | 1694 | if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then bugmes();quit;end |
1695 | 1695 | ||
1696 | 1696 | ||
1697 | |||
1698 | // ============================================================================ | ||
1699 | |||
1700 | // Tests for riccati() function | ||
1701 | |||
1702 | // Added : 25/06/2007 | ||
1703 | |||
1704 | // Thanks to Sabine GAUZERE | ||
1705 | |||
1706 | // ============================================================================ | ||
1707 | |||
1708 | |||
1709 | n = 10; | ||
1710 | |||
1711 | A = rand(n,n); | ||
1712 | |||
1713 | B = rand(n,n); | ||
1714 | |||
1715 | C = rand(n,n); | ||
1716 | |||
1717 | C = C*C'; | ||
1718 | |||
1719 | R = rand(n,n); | ||
1720 | |||
1721 | R = R*R'+eye(); | ||
1722 | |||
1723 | B = B*inv(R)*B'; | ||
1724 | |||
1725 | |||
1726 | // Test de l'équation en temps continu | ||
1727 | |||
1728 | X = riccati(A,B,C,'c','eigen'); | ||
1729 | |||
1730 | |||
1731 | // Vérification | ||
1732 | |||
1733 | C_cont = A'*X+X*A-X*B*X; | ||
1734 | |||
1735 | |||
1736 | // Test de l'équation en temps discret | ||
1737 | |||
1738 | F = A; | ||
1739 | |||
1740 | B = rand(n,n); | ||
1741 | |||
1742 | G1 = B; | ||
1743 | |||
1744 | G2 = R; | ||
1745 | |||
1746 | G = G1/G2*G1'; | ||
1747 | |||
1748 | H = C; | ||
1749 | |||
1750 | [X1,X2]= riccati(F,G,H,'d','schur'); | ||
1751 | |||
1752 | |||
1753 | // Vérification | ||
1754 | |||
1755 | X = X1/X2; | ||
1756 | |||
1757 | C_disc = F'*X*F-(F'*X*G1/(G2+G1'*X*G1))*(G1'*X*F)-X; | ||
1758 | |||
1759 | |||
1760 | // Comparaison des différents résultats obtenus | ||
1761 | |||
1762 | if norm(C_cont+C,1) > (10000*%eps) then bugmes();quit;end | ||
1763 | |||
1764 | if norm(C_disc+H,1) > (10000*%eps) then bugmes();quit;end | ||
1765 | |||
diff --git a/tests/basic_tests/slicot.tst b/tests/basic_tests/slicot.tst index 0d3f529..dd3d9ed 100644 --- a/tests/basic_tests/slicot.tst +++ b/tests/basic_tests/slicot.tst | |||
@@ -885,3 +885,41 @@ flag=[1,2]; | |||
885 | X = linmeq(3,A,C,flag); | 885 | X = linmeq(3,A,C,flag); |
886 | if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then pause,end | 886 | if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then pause,end |
887 | 887 | ||
888 | |||
889 | // ============================================================================ | ||
890 | // Tests for riccati() function | ||
891 | // Added : 25/06/2007 | ||
892 | // Thanks to Sabine GAUZERE | ||
893 | // ============================================================================ | ||
894 | |||
895 | n = 10; | ||
896 | A = rand(n,n); | ||
897 | B = rand(n,n); | ||
898 | C = rand(n,n); | ||
899 | C = C*C'; | ||
900 | R = rand(n,n); | ||
901 | R = R*R'+eye(); | ||
902 | B = B*inv(R)*B'; | ||
903 | |||
904 | // Test de l'équation en temps continu | ||
905 | X = riccati(A,B,C,'c','eigen'); | ||
906 | |||
907 | // Vérification | ||
908 | C_cont = A'*X+X*A-X*B*X; | ||
909 | |||
910 | // Test de l'équation en temps discret | ||
911 | F = A; | ||
912 | B = rand(n,n); | ||
913 | G1 = B; | ||
914 | G2 = R; | ||
915 | G = G1/G2*G1'; | ||
916 | H = C; | ||
917 | [X1,X2]= riccati(F,G,H,'d','schur'); | ||
918 | |||
919 | // Vérification | ||
920 | X = X1/X2; | ||
921 | C_disc = F'*X*F-(F'*X*G1/(G2+G1'*X*G1))*(G1'*X*F)-X; | ||
922 | |||
923 | // Comparaison des différents résultats obtenus | ||
924 | if norm(C_cont+C,1) > (10000*%eps) then pause,end | ||
925 | if norm(C_disc+H,1) > (10000*%eps) then pause,end | ||