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// gauswavf test
22function [psi,X] = ref_gauswavf(LB,UB,N,NumWAW);
23X = linspace(LB,UB,N);  // wavelet support.
24if or(NumWAW==(1:8))
25  X2 = X.^2;
26  F0 = (2/%pi)^(1/4)*exp(-X2);
27end
28select NumWAW
29  case 1
30    psi = -2*X.*F0;
31  case 2
32    psi = 2/(3^(1/2)) * (-1+2*X2).*F0;
33  case 3
34    psi = 4/(15^(1/2)) * X.* (3-2*X2).*F0;
35  case 4
36    psi = 4/(105^(1/2)) * (3-12*X2+4*X2.^2).*F0;
37  case 5
38    psi = 8/(3*(105^(1/2))) * X.* (-15+20*X2-4*X2.^2).*F0;
39  case 6
40    psi = 8/(3*(1155^(1/2))) * (-15+90*X2-60*X2.^2+8*X2.^3).*F0;
41  case 7
42    psi = 16/(3*(15015^(1/2))) *X.*(105-210*X2+84*X2.^2-8*X2.^3).*F0;
43  case 8
44    psi = 16/(45*(1001^(1/2))) * (105-840*X2+840*X2.^2-224*X2.^3+16*X2.^4).*F0;
45  else
46    error("1-8");
47 end
48endfunction
49LB=-5;
50UB=5;
51N=1000;
52[psi,x] = ref_gauswavf(LB,UB,N,1);
53[PSI,X]=gauswavf(LB,UB,N,1);
54assert_checkalmostequal ( real(PSI) , real(psi) , %eps, 1e-11);
55assert_checkalmostequal ( imag(PSI) , imag(psi) , %eps, 1e-11);
56assert_checkalmostequal ( X , x , %eps, %eps );
57[psi,x] = ref_gauswavf(LB,UB,N,2);
58[PSI,X]=gauswavf(LB,UB,N,2);
59assert_checkalmostequal ( real(PSI) , real(psi) , %eps, 1e-11);
60assert_checkalmostequal ( imag(PSI) , imag(psi) , %eps, 1e-11);
61assert_checkalmostequal ( X , x , %eps, %eps );
62[psi,x] = ref_gauswavf(LB,UB,N,3);
63[PSI,X]=gauswavf(LB,UB,N,3);
64assert_checkalmostequal ( real(PSI) , real(psi) , %eps, 1e-11);
65assert_checkalmostequal ( imag(PSI) , imag(psi) , %eps, 1e-11);
66assert_checkalmostequal ( X , x , %eps, %eps );
67[psi,x] = ref_gauswavf(LB,UB,N,4);
68[PSI,X]=gauswavf(LB,UB,N,4);
69assert_checkalmostequal ( real(PSI) , real(psi) , %eps, 1e-11);
70assert_checkalmostequal ( imag(PSI) , imag(psi) , %eps, 1e-11);
71assert_checkalmostequal ( X , x , %eps, %eps );
72[psi,x] = ref_gauswavf(LB,UB,N,5);
73[PSI,X]=gauswavf(LB,UB,N,5);
74assert_checkalmostequal ( real(PSI) , real(psi) , %eps, 1e-11);
75assert_checkalmostequal ( imag(PSI) , imag(psi) , %eps, 1e-11);
76assert_checkalmostequal ( X , x , %eps, %eps );
77[psi,x] = ref_gauswavf(LB,UB,N,6);
78[PSI,X]=gauswavf(LB,UB,N,6);
79assert_checkalmostequal ( real(PSI) , real(psi) , %eps, 1e-11);
80assert_checkalmostequal ( imag(PSI) , imag(psi) , %eps, 1e-11);
81assert_checkalmostequal ( X , x , %eps, %eps );
82[psi,x] = ref_gauswavf(LB,UB,N,7);
83[PSI,X]=gauswavf(LB,UB,N,7);
84assert_checkalmostequal ( real(PSI) , real(psi) , %eps, 1e-11);
85assert_checkalmostequal ( imag(PSI) , imag(psi) , %eps, 1e-11);
86assert_checkalmostequal ( X , x , %eps, %eps );
87[psi,x] = ref_gauswavf(LB,UB,N,8);
88[PSI,X]=gauswavf(LB,UB,N,8);
89assert_checkalmostequal ( real(PSI) , real(psi) , %eps, 1e-11);
90assert_checkalmostequal ( imag(PSI) , imag(psi) , %eps, 1e-11);
91assert_checkalmostequal ( X , x , %eps, %eps );
92