summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPierre Marechal <pierre.marechal@scilab.org>2007-06-25 14:47:27 +0000
committerPierre Marechal <pierre.marechal@scilab.org>2007-06-25 14:47:27 +0000
commit36d09c1c26e0350d30a2e9a142ec540be5e7a69a (patch)
treea7112005a7034e09f225b3e3731bde93b985d4de /tests
parent33ac9be1a00ba63547b34f328ff1e8aa06640d3d (diff)
downloadscilab-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.ref69
-rw-r--r--tests/basic_tests/slicot.tst38
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);
1694if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then bugmes();quit;end 1694if 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
1709n = 10;
1710
1711A = rand(n,n);
1712
1713B = rand(n,n);
1714
1715C = rand(n,n);
1716
1717C = C*C';
1718
1719R = rand(n,n);
1720
1721R = R*R'+eye();
1722
1723B = B*inv(R)*B';
1724
1725
1726// Test de l'équation en temps continu
1727
1728X = riccati(A,B,C,'c','eigen');
1729
1730
1731// Vérification
1732
1733C_cont = A'*X+X*A-X*B*X;
1734
1735
1736// Test de l'équation en temps discret
1737
1738F = A;
1739
1740B = rand(n,n);
1741
1742G1 = B;
1743
1744G2 = R;
1745
1746G = G1/G2*G1';
1747
1748H = C;
1749
1750[X1,X2]= riccati(F,G,H,'d','schur');
1751
1752
1753// Vérification
1754
1755X = X1/X2;
1756
1757C_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
1762if norm(C_cont+C,1) > (10000*%eps) then bugmes();quit;end
1763
1764if 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];
885X = linmeq(3,A,C,flag); 885X = linmeq(3,A,C,flag);
886if norm(A'*(X'*X)*A-X'*X+C'*C,1)>100000*%eps then pause,end 886if 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
895n = 10;
896A = rand(n,n);
897B = rand(n,n);
898C = rand(n,n);
899C = C*C';
900R = rand(n,n);
901R = R*R'+eye();
902B = B*inv(R)*B';
903
904// Test de l'équation en temps continu
905X = riccati(A,B,C,'c','eigen');
906
907// Vérification
908C_cont = A'*X+X*A-X*B*X;
909
910// Test de l'équation en temps discret
911F = A;
912B = rand(n,n);
913G1 = B;
914G2 = R;
915G = G1/G2*G1';
916H = C;
917[X1,X2]= riccati(F,G,H,'d','schur');
918
919// Vérification
920X = X1/X2;
921C_disc = F'*X*F-(F'*X*G1/(G2+G1'*X*G1))*(G1'*X*F)-X;
922
923// Comparaison des différents résultats obtenus
924if norm(C_cont+C,1) > (10000*%eps) then pause,end
925if norm(C_disc+H,1) > (10000*%eps) then pause,end