1// -------------------------------------------------------------------------
2// SWT - Scilab wavelet toolbox
3// Copyright (C) 2010-2014  Holger Nahrstaedt
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18//-------------------------------------------------------------------------
19//
20//  <-- NO CHECK ERROR OUTPUT -->
21// appcoef2
22version = getversion("scilab");
23if (version(1)<6) then
24	sz=stacksize();
25	stacksize(1e7);
26end;
27a=rand(500,501,'normal');
28[c,s]=wavedec2(a,3,'sym5');
29[Lo_R,Hi_R]=wfilters('sym5','r');
30[cA1,cH1,cV1,cD1]=dwt2(a,'sym5');
31[cA2,cH2,cV2,cD2]=dwt2(cA1,'sym5');
32[cA3,cH3,cV3,cD3]=dwt2(cA2,'sym5');
33ca3=cA3;
34ca2=idwt2(cA3,cH3,cV3,cD3,'sym5',size(cA2));
35ca1=idwt2(ca2,cH2,cV2,cD2,'sym5',size(cA1));
36ca0=idwt2(ca1,cH1,cV1,cD1,'sym5',size(a));
37A0=appcoef2(c,s,'sym5',0);
38A00=appcoef2(c,s,Lo_R,Hi_R,0);
39A1=appcoef2(c,s,'sym5',1);
40A11=appcoef2(c,s,Lo_R,Hi_R,1);
41A2=appcoef2(c,s,'sym5',2);
42A22=appcoef2(c,s,Lo_R,Hi_R,2);
43A3=appcoef2(c,s,'sym5',3);
44A33=appcoef2(c,s,Lo_R,Hi_R,3);
45A333=appcoef2(c,s,'sym5');
46A3333=appcoef2(c,s,Lo_R,Hi_R);
47assert_checkalmostequal ( ca0 , A0 , %eps );
48assert_checkalmostequal ( ca0 , A00 , %eps );
49assert_checkalmostequal ( ca1 , A1 , %eps );
50assert_checkalmostequal ( ca1 , A11 , %eps );
51assert_checkalmostequal ( ca2 , A2 , %eps );
52assert_checkalmostequal ( ca2 , A22 , %eps );
53assert_checkalmostequal ( ca3 , A3 , %eps );
54assert_checkalmostequal ( ca3 , A33 , %eps );
55assert_checkalmostequal ( ca3 , A333 , %eps );
56clear ca1;
57clear ca2;
58clear ca3;
59clear A1;
60clear A11;
61clear A2;
62clear A22;
63clear A3;
64clear A33;
65clear A333;
66clear A0;
67clear A00;
68clear ca0;
69clear c;
70clear s;
71clear Lo_R;
72clear Hi_R;
73clear cA1;
74clear cA2;
75clear cA3;
76clear cH1;
77clear cH2;
78clear cH3;
79clear cV1;
80clear cV2;
81clear cV3;
82clear cD1;
83clear cD2;
84clear cD3;
85if (version(1)<6) then
86	stacksize(sz(1));
87	clear sz;
88end;
89