add a unit test for rpem based on the commit 137b156eab9903268713f7f80d8597066639a32f
[scilab.git] / scilab / modules / signal_processing / tests / unit_tests / rpem.tst
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2013 - Scilab Enterprises - Charlotte Hecquet
4 // Copyright (C) 2013 - Scilab Enterprises - Sylvestre Ledru
5 //
6 //  This file is distributed under the same license as the Scilab package.
7 // =============================================================================
8
9 nbPoints = 5; // Number of points computed
10
11 // Real parameters a,b,c: here, y=u
12 a=cat(2,1,zeros(1,nbPoints - 1));
13 b=cat(2,1,zeros(1,nbPoints - 1));
14 c=zeros(1,nbPoints);
15
16 // Generate input signal
17 t=linspace(0,50,1000);
18 w=%pi/4;
19 u=cos(w*t);
20
21 // Generate output signal
22 Arma=armac(a,b,c,1,1,0);
23 y=arsimul(Arma,u);
24
25 // Arguments of rpem
26 phi=zeros(1,nbPoints*3);
27 psi=zeros(1,nbPoints*3);
28 l=zeros(1,nbPoints*3);
29 p=1*eye(nbPoints*3,nbPoints*3);
30 theta=[0*a 0*b 0*c];
31 w0=list(theta,p,l,phi,psi);
32 [w0, v]=rpem(w0,u,y);
33
34 assert_checkequal(size(w0), 5);
35 assert_checkequal(size(v,"*"), 1);
36 assert_checkalmostequal(v, 0.57451013690216091);
37
38 assert_checkequal(size(w0(1)), [1, 15]);
39 assert_checkequal(size(w0(2)), [15, 15]);
40 assert_checkequal(size(w0(3)), [1, 15]);
41 assert_checkequal(size(w0(4)), [1, 15]);
42 assert_checkequal(size(w0(5)), [1, 15]);
43 assert_checkalmostequal(sum(w0(1)),  - 1.6187817562697728);
44 assert_checkalmostequal(sum(w0(2)), 925.971144340439537);
45 assert_checkalmostequal(sum(w0(3)), 0.06147492702030416);
46 assert_checkalmostequal(sum(w0(4)), 0.19515684603135780);
47 assert_checkalmostequal(sum(w0(5)), 0.22685582794021467);