File Coverage

blib/lib/Math/DWT/Wavelet/Haar.pm
Criterion Covered Total %
statement 6 49 12.2
branch 0 12 0.0
condition 0 2 0.0
subroutine 2 9 22.2
pod 7 7 100.0
total 15 79 18.9


line stmt bran cond sub pod time code
1             package Math::DWT::Wavelet::Haar;
2 1     1   2376 use strict;
  1         2  
  1         22  
3 1     1   3 use warnings;
  1         1  
  1         309  
4              
5             =head1 NAME
6              
7             Math::DWT::Wavelet::Haar - FIR lo- & hi-pass filter coefficients for the Haar wavelet.
8              
9             =head1 VERSION
10              
11             Version 0.022
12              
13             =cut
14              
15             our $VERSION = '0.022';
16              
17             =head1 SYNOPSIS
18              
19             This module provides the lo- and hi-pass decomposition and reconstruction filter coefficients for the Haar wavelet. It is meant to be used with other Math::DWT modules:
20              
21             use Math::DWT;
22             use Math::DWT::UDWT;
23            
24             my $dwt = Math::DWT->new('Haar');
25             my $udwt = Math::DWT::UDWT->new('Haar');
26              
27              
28             =cut
29              
30             =head1 SUBROUTINES/METHODS
31              
32             =head2 new()
33              
34             The Haar wavelet module is unique among the other wavelet modules in that there is no "VAR" argument to new(). This method returns a Math::DWT::Wavelet::Haar object;
35              
36             =head2 vars()
37              
38             This method returns a list of possible choices for VAR when creating a new object, e.g.:
39              
40             my @v = Math::DWT::Wavelet::Daubechies->vars();
41             print scalar(@v); # 20
42              
43             This method returns an empty array/arrayref for the Haar wavelet, since there are no options for VAR.
44              
45             =head2 filters()
46              
47             Depending on the context in which it is called, returns an array or an arrayref containing (lo_d, hi_d, lo_r, hi_r) - the set of filters which are defined with the instantiated object.
48              
49             =head2 lo_d()
50              
51             =head2 hi_d()
52              
53             =head2 lo_r()
54              
55             =head2 hi_r()
56              
57             Returns the requested set of filter coefficients as either an array or arrayref, depending on calling context.
58              
59             =head1 SEE ALSO
60              
61             Math::DWT(3pm), Math::DWT::UDWT(3pm), Math::DWT::Wavelet::Daubechies(3pm), Math::DWT::Wavelet::Coiflet(3pm), Math::DWT::Wavelet::Symlet(3pm), Math::DWT::Wavelet::Biorthogonal(3pm), Math::DWT::Wavelet::ReverseBiorthogonal(3pm), Math::DWT::Wavelet::DiscreteMeyer(3pm), perl(1)
62              
63              
64             =head1 AUTHOR
65              
66              
67             Mike Kroh, C<< >>
68              
69             =head1 BUGS
70              
71              
72             Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
73              
74              
75              
76             =head1 ACKNOWLEDGEMENTS
77              
78             These wavelet filter coefficients were scraped from this site: L.
79              
80             =head1 LICENSE AND COPYRIGHT
81              
82              
83             Copyright 2016 Mike Kroh.
84              
85             This program is free software; you can redistribute it and/or modify it
86             under the terms of the the Artistic License (2.0). You may obtain a
87             copy of the full license at:
88              
89             L
90              
91             Any use, modification, and distribution of the Standard or Modified
92             Versions is governed by this Artistic License. By using, modifying or
93             distributing the Package, you accept this license. Do not use, modify,
94             or distribute the Package, if you do not accept this license.
95              
96             If your Modified Version has been derived from a Modified Version made
97             by someone other than you, you are nevertheless required to ensure that
98             your Modified Version complies with the requirements of this license.
99              
100             This license does not grant you the right to use any trademark, service
101             mark, tradename, or logo of the Copyright Holder.
102              
103             This license includes the non-exclusive, worldwide, free-of-charge
104             patent license to make, have made, use, offer to sell, sell, import and
105             otherwise transfer the Package with respect to any patent claims
106             licensable by the Copyright Holder that are necessarily infringed by the
107             Package. If you institute patent litigation (including a cross-claim or
108             counterclaim) against any party alleging that the Package constitutes
109             direct or contributory patent infringement, then this Artistic License
110             to you shall terminate on the date that such litigation is filed.
111              
112             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
113             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
114             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
115             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
116             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
117             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
118             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
119             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
120              
121              
122             =cut
123              
124              
125             my @vars=qw//;
126              
127             my %lo_d; my %hi_d; my %lo_r; my %hi_r;
128              
129              
130             $lo_d{""}=[qw/0.7071067811865476 0.7071067811865476/];
131             $lo_r{""}=[qw/0.7071067811865476 0.7071067811865476/];
132             $hi_d{""}=[qw/-0.7071067811865476 0.7071067811865476/];
133             $hi_r{""}=[qw/0.7071067811865476 -0.7071067811865476/];
134             ;
135              
136             sub new {
137 0     0 1   my $class=shift;
138 0           my $self={};
139 0   0       my $var=shift || "";
140              
141             $self={lo_d=>$lo_d{$var},
142             hi_d=>$hi_d{$var},
143             lo_r=>$lo_r{$var},
144 0           hi_r=>$hi_r{$var}
145             };
146            
147 0           bless $self,$class;
148 0           return $self;
149             };
150              
151             sub vars {
152 0     0 1   my $self=shift;
153 0 0         if (wantarray()) {
154 0           return (@vars);
155             };
156 0           return \@vars;
157             };
158              
159             sub filters {
160 0     0 1   my $self=shift;
161 0           my $lo_d=$self->lo_d;
162 0           my $hi_d=$self->hi_d;
163 0           my $lo_r=$self->lo_r;
164 0           my $hi_r=$self->hi_r;
165 0           my @a=( $lo_d,$hi_d,$lo_r,$hi_r);
166 0 0         if (wantarray()) {
167 0           return (@a);
168             };
169 0           return \@a;
170             };
171              
172             sub lo_d {
173 0     0 1   my $self=shift;
174 0           my $a=$self->{lo_d};
175 0 0         if (wantarray()) {
176 0           return (@{$a});
  0            
177             };
178 0           return $a;
179             };
180             sub hi_d {
181 0     0 1   my $self=shift;
182 0           my $a=$self->{hi_d};
183 0 0         if (wantarray()) {
184 0           return (@{$a});
  0            
185             };
186 0           return $a;
187             };
188             sub lo_r {
189 0     0 1   my $self=shift;
190 0           my $a=$self->{lo_r};
191 0 0         if (wantarray()) {
192 0           return (@{$a});
  0            
193             };
194 0           return $a;
195             };
196             sub hi_r {
197 0     0 1   my $self=shift;
198 0           my $a=$self->{hi_r};
199 0 0         if (wantarray()) {
200 0           return (@{$a});
  0            
201             };
202 0           return $a;
203             };
204              
205            
206             1;