DWT/Wavelet/Haar.pm

filter: Statementstmt 27.1% 16 / 59 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 22.2% 2 / 9 Podpod 100% 7 / 7 totaltotal 27.7% 25 / 90 CC 8 SCAR 16.8
CC
8
Cov
22%
new
6.0
vars
6.0
filters
6.0
CRAP 5.4
« DWT.pm ↑ Summary DWT/Wavelet/DiscreteMeyer.pm »
1 package Math::DWT::Wavelet::Haar;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
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 1 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<< <kroh at cpan.org> >>
68  
69 =head1 BUGS
70  
71  
72 Please report any bugs or feature requests to C<bug-math-dwt-wavelet-haar at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Math-DWT-Wavelet-Haar>. 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<http://wavelets.pybytes.com/>.
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<http://www.perlfoundation.org/artistic_license_2_0>
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 1 my @vars=qw//;
126  
127 1 my %lo_d; my %hi_d; my %lo_r; my %hi_r;
128  
129  
130 1 $lo_d{""}=[qw/0.7071067811865476 0.7071067811865476/];
131 1 $lo_r{""}=[qw/0.7071067811865476 0.7071067811865476/];
132 1 $hi_d{""}=[qw/-0.7071067811865476 0.7071067811865476/];
133 1 $hi_r{""}=[qw/0.7071067811865476 -0.7071067811865476/];
134 ;
135  
136 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod documented
137 0 my $class=shift;
138 0 my $self={};
139 0 ▶ my $var=shift || "";
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
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 0 ▶sub vars {
Subroutine vars: not called CC=2 SCAR=17.9
Pod documented
152 0 my $self=shift;
153 0 ▶ if (wantarray()) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
154 0 return (@vars);
155 };
156 0 return \@vars;
157 };
158  
159 0 ▶sub filters {
Subroutine filters: not called CC=2 SCAR=17.9
Pod documented
160 0 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 ▶ if (wantarray()) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
167 0 return (@a);
168 };
169 0 return \@a;
170 };
171  
172 0 ▶sub lo_d {
Subroutine lo_d: not called CC=2 SCAR=17.9
Pod documented
173 0 my $self=shift;
174 0 my $a=$self->{lo_d};
175 0 ▶ if (wantarray()) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
176 0 return (@{$a});
177 };
178 0 return $a;
179 };
180 0 ▶sub hi_d {
Subroutine hi_d: not called CC=2 SCAR=17.9
Pod documented
181 0 my $self=shift;
182 0 my $a=$self->{hi_d};
183 0 ▶ if (wantarray()) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
184 0 return (@{$a});
185 };
186 0 return $a;
187 };
188 0 ▶sub lo_r {
Subroutine lo_r: not called CC=2 SCAR=17.9
Pod documented
189 0 my $self=shift;
190 0 my $a=$self->{lo_r};
191 0 ▶ if (wantarray()) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
192 0 return (@{$a});
193 };
194 0 return $a;
195 };
196 0 ▶sub hi_r {
Subroutine hi_r: not called CC=2 SCAR=17.9
Pod documented
197 0 my $self=shift;
198 0 my $a=$self->{hi_r};
199 0 ▶ if (wantarray()) {
Branch: 1 branch
BranchTrueFalseTotal
if (wantarray) 0 0 0
200 0 return (@{$a});
201 };
202 0 return $a;
203 };
204  
205
206 1 1;
« DWT.pm ↑ Summary DWT/Wavelet/DiscreteMeyer.pm »