add a unit test for rpem based on the commit 137b156eab9903268713f7f80d8597066639a32f
[scilab.git] / scilab / modules / signal_processing / tests / unit_tests / rpem.dia.ref
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 nbPoints = 5; // Number of points computed
9 // Real parameters a,b,c: here, y=u
10 a=cat(2,1,zeros(1,nbPoints - 1));
11 b=cat(2,1,zeros(1,nbPoints - 1));
12 c=zeros(1,nbPoints);
13 // Generate input signal
14 t=linspace(0,50,1000);
15 w=%pi/4;
16 u=cos(w*t);
17 // Generate output signal
18 Arma=armac(a,b,c,1,1,0);
19 y=arsimul(Arma,u);
20 // Arguments of rpem
21 phi=zeros(1,nbPoints*3);
22 psi=zeros(1,nbPoints*3);
23 l=zeros(1,nbPoints*3);
24 p=1*eye(nbPoints*3,nbPoints*3);
25 theta=[0*a 0*b 0*c];
26 w0=list(theta,p,l,phi,psi);
27 [w0, v]=rpem(w0,u,y);
28 assert_checkequal(size(w0), 5);
29 assert_checkequal(size(v,"*"), 1);
30 assert_checkalmostequal(v, 0.57451013690216091);
31 assert_checkequal(size(w0(1)), [1, 15]);
32 assert_checkequal(size(w0(2)), [15, 15]);
33 assert_checkequal(size(w0(3)), [1, 15]);
34 assert_checkequal(size(w0(4)), [1, 15]);
35 assert_checkequal(size(w0(5)), [1, 15]);
36 assert_checkalmostequal(sum(w0(1)),  - 1.6187817562697728);
37 assert_checkalmostequal(sum(w0(2)), 925.971144340439537);
38 assert_checkalmostequal(sum(w0(3)), 0.06147492702030416);
39 assert_checkalmostequal(sum(w0(4)), 0.19515684603135780);
40 assert_checkalmostequal(sum(w0(5)), 0.22685582794021467);