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 22 23// wavefun2 Test 24version = getversion("scilab"); 25if (version(1)<6) then 26sz = stacksize(); 27stacksize(1e8); 28end; 29 30ITER=4; 31// dwt 32// type 1 input 33// haar 34accuracy1 = 1e-10; 35accuracy2 = 1e-10; 36 37[S,W1,W2,W3,XYVAL]=wavefun2('haar',ITER); 38assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 39assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 40assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy2 ); 41assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 42assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy2 ); 43assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 44assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy2 ); 45 46//db family 47accuracy1 = 1e-10; 48accuracy2 = 1e-10; 49db_fam=["db1","db2", "db3", "db4", "db5", "db6","db7", "db8", "db9", "db10", "db11",... 50"db12", "db13", "db14", "db15", "db16","db17", "db18", "db19", "db20", "db21", "db22",... 51 "db23", "db24", "db25", "db26", "db27", "db28", "db29", "db30", "db31", "db32", "db33",.. 52 "db34", "db35", "db36"]; 53// db1 54for i=1:max(size(db_fam)) 55 [S,W1,W2,W3,XYVAL]=wavefun2(db_fam(i),ITER); 56 assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 57 assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 58 assert_checkalmostequal ( sum(W1) , 0 , %eps,accuracy2 ); 59 assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 60 assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy2 ); 61 assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 62 assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy2 ); 63end; 64 65//coif family 66accuracy1 = 1e-10; 67accuracy2 = 1e-10; 68coif_fam=["coif1","coif2","coif3","coif4","coif5","coif6","coif7","coif8","coif9","coif10","coif11",... 69"coif12","coif13","coif14","coif15","coif16","coif17"]; 70 71for i=1:max(size(coif_fam)) 72 73 [S,W1,W2,W3,XYVAL]=wavefun2(coif_fam(i),ITER); 74 assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 75 assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 76 assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy1 ); 77 assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 78 assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy1 ); 79 assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 80 assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy1 ); 81end; 82 83//symlets family 84accuracy1 = 1e-8; 85accuracy2 = 1e-8; 86sym_fam=["sym2", "sym3", "sym4", "sym5", "sym6","sym7", "sym8", "sym9", "sym10", "sym11",... 87"sym12", "sym13", "sym14", "sym15", "sym16","sym17", "sym18", "sym19", "sym20"]; 88 89for i=1:max(size(sym_fam)) 90 [S,W1,W2,W3,XYVAL]=wavefun2(sym_fam(i),ITER); 91 assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 92 assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 93 assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy1 ); 94 assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 95 assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy1 ); 96 assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 97 assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy1 ); 98end; 99 100 101 102 103//beylkin 104accuracy1 = 1e-8; 105accuracy2 = 1e-5; 106 [S,W1,W2,W3,XYVAL]=wavefun2("beylkin",ITER); 107assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 108assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 109assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy2 ); 110assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 111assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy2 ); 112assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 113assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy2 ); 114 115accuracy1 = 1e-6; 116accuracy2 = 1e-5; 117 //vaidyanathan 118 [S,W1,W2,W3,XYVAL]=wavefun2("vaidyanathan",ITER); 119assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 120assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 121// assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy2 ); 122assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 123// assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy2 ); 124assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 125// assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy2 ); 126 //dmey 127 [S,W1,W2,W3,XYVAL]=wavefun2("dmey",ITER); 128assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, 1e-1 ); 129 assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, 1e-1 ); 130// assert_checkalmostequal ( sum(W1) , 0 , %eps, 1e-1 ); 131 assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, 1e-1 ); 132// assert_checkalmostequal ( sum(W2) , 0 , %eps, 1e-1 ); 133assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, 1e-1 ); 134// assert_checkalmostequal ( sum(W3) , 0 , %eps, 1e-1 ); 135 //bath 136 accuracy1 = 1e-2; 137 accuracy2 = 1e-1; 138 bath_fam=["bath4.0", "bath4.1", "bath4.2", "bath4.3", "bath4.4", "bath4.5",... 139"bath4.6", "bath4.7", "bath4.8", "bath4.9", "bath4.10", ... 140"bath4.11", "bath4.12", "bath4.13", "bath4.14", "bath4.15", ... 141"bath6.0", "bath6.1", "bath6.2", "bath6.3", "bath6.4", ... 142"bath6.5", "bath6.6", "bath6.7", "bath6.8", "bath6.9", ... 143"bath6.10", "bath6.11", "bath6.12", "bath6.13", "bath6.14", ... 144"bath6.15"]; 145for i=1:max(size(bath_fam)) 146 147 [S,W1,W2,W3,XYVAL]=wavefun2(bath_fam(i),ITER); 148assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1); 149assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 150assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy2 ); 151assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps,accuracy1 ); 152assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy2 ); 153assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps,accuracy1 ); 154assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy2 ); 155end; 156 //legd 157 accuracy1 = 1e-8; 158 accuracy2 = 1e-5; 159legd_fam=["legd1", "legd2", "legd3", "legd4", "legd5", "legd6", "legd7", "legd8", "legd9"]; 160 161for i=1:max(size(legd_fam)) 162 163 [S,W1,W2,W3,XYVAL]=wavefun2(legd_fam(i),ITER); 164assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy2 ); 165//assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, 1e-4 ); 166assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy2 ); 167//assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, 1e-4 ); 168assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy2 ); 169//assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, 1e-4 ); 170assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy2 ); 171end; 172 173 //fa 174 accuracy1 = 1e-8; 175 accuracy2 = 1e-5; 176 [S,W1,W2,W3,XYVAL]=wavefun2("fa1",ITER); 177assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 178assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 179assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy2 ); 180assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 181assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy2 ); 182assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 183assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy2 ); 184 [S,W1,W2,W3,XYVAL]=wavefun2("fa2",ITER); 185assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 186assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 187assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy2 ); 188assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 189assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy2 ); 190assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 191assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy2 ); 192 // ksq 193 accuracy1 = 1e-7; 194 accuracy2 = 1e-5; 195 [S,W1,W2,W3,XYVAL]=wavefun2("ksq1",ITER); 196assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 197assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 198assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy2 ); 199assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 200assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy2 ); 201assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 202assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy2 ); 203 204 [S,W1,W2,W3,XYVAL]=wavefun2("ksq2",ITER); 205assert_checkalmostequal ( sum(S)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 206assert_checkalmostequal ( sum(W1.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 207assert_checkalmostequal ( sum(W1) , 0 , %eps, accuracy2 ); 208assert_checkalmostequal ( sum(W2.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 209assert_checkalmostequal ( sum(W2) , 0 , %eps, accuracy2 ); 210assert_checkalmostequal ( sum(W3.^2)/(2^ITER)^2 , 1 , %eps, accuracy1 ); 211assert_checkalmostequal ( sum(W3) , 0 , %eps, accuracy2 ); 212 213if (version(1)<6) then 214stacksize(sz(1)); 215clear sz; 216end; 217