| 1 | package PDL::DSP::Windows; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | our $VERSION = '0.100'; | |||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use PDL::Bad (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use PDL::Basic (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use PDL::Core (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use PDL::FFT (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use PDL::Math (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use PDL::MatrixOps (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use PDL::Ops (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use PDL::Options (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 7 | ▶ | use PDL::Primitive (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 7 | ▶ | use PDL::Ufunc (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # These constants are deleted at the end of this package | ||||||||||||||||||||||||||||
| 20 | use constant { | ||||||||||||||||||||||||||||
| 21 | 7 | ▶ | HAVE_LinearAlgebra => eval { require PDL::LinearAlgebra::Special } || 0, | ||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
require PDL::GSLSF::BESSEL
}
} || 0
MC/DC0%0/1
eval {
do {
require PDL::GSLSF::BESSEL
}
} || 0
eval {
do {
require PDL::GSLSF::BESSEL
}
}
Truth table50%1/2
A
A= eval {
do {
require PDL::GSLSF::BESSEL
}
}
| |||||||||||||||||||||||||||||
| 22 | 7 | ▶ | HAVE_BESSEL => eval { require PDL::GSLSF::BESSEL } || 0, | ||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
require PDL::Graphics::Gnuplot
}
} || 0
MC/DC0%0/1
eval {
do {
require PDL::Graphics::Gnuplot
}
} || 0
eval {
do {
require PDL::Graphics::Gnuplot
}
}
Truth table50%1/2
A
A= eval {
do {
require PDL::Graphics::Gnuplot
}
}
| |||||||||||||||||||||||||||||
| 23 | 7 | ▶ | HAVE_GNUPLOT => eval { require PDL::Graphics::Gnuplot } || 0, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | USE_FFTW_DIRECTION => version->parse($PDL::VERSION) <= v2.007, | ||||||||||||||||||||||||||||
| 25 | 7 | ▶ | I => version->parse($PDL::VERSION) > v2.054 ? PDL::Core::pdl('i') : do { | ||||||||||||||||||||||||||
|
Condition50%1/2
eval {
do {
require PDL::LinearAlgebra::Special
}
} || 0
MC/DC0%0/1
eval {
do {
require PDL::LinearAlgebra::Special
}
} || 0
eval {
do {
require PDL::LinearAlgebra::Special
}
}
Truth table50%1/2
A
A= eval {
do {
require PDL::LinearAlgebra::Special
}
}
| |||||||||||||||||||||||||||||
| 26 | 5 | require PDL::Complex; # Deprecated in 2.055 | |||||||||||||||||||||||||||
| 27 | 0 | PDL::Complex::i(); | |||||||||||||||||||||||||||
| 28 | }, | ||||||||||||||||||||||||||||
| 29 | 7 | ▶ | }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | # These constants are left in our namespace for historical reasons | ||||||||||||||||||||||||||||
| 32 | 2 | ▶ | use constant PI => 4 * atan2(1, 1); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 33 | 2 | ▶ | use constant TPI => 2 * PI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 2 | my %symmetric_windows = ( | |||||||||||||||||||||||||||
| 38 | bartlett => 1, | ||||||||||||||||||||||||||||
| 39 | bartlett_hann => 1, | ||||||||||||||||||||||||||||
| 40 | blackman => 1, | ||||||||||||||||||||||||||||
| 41 | blackman_bnh => 1, | ||||||||||||||||||||||||||||
| 42 | blackman_ex => 1, | ||||||||||||||||||||||||||||
| 43 | blackman_gen => 1, | ||||||||||||||||||||||||||||
| 44 | blackman_gen3 => 1, | ||||||||||||||||||||||||||||
| 45 | blackman_gen4 => 1, | ||||||||||||||||||||||||||||
| 46 | blackman_gen5 => 1, | ||||||||||||||||||||||||||||
| 47 | blackman_harris => 1, | ||||||||||||||||||||||||||||
| 48 | blackman_harris4 => 1, | ||||||||||||||||||||||||||||
| 49 | blackman_nuttall => 1, | ||||||||||||||||||||||||||||
| 50 | bohman => 1, | ||||||||||||||||||||||||||||
| 51 | cauchy => 1, | ||||||||||||||||||||||||||||
| 52 | chebyshev => 1, | ||||||||||||||||||||||||||||
| 53 | cos_alpha => 1, | ||||||||||||||||||||||||||||
| 54 | cosine => 1, | ||||||||||||||||||||||||||||
| 55 | dpss => 1, | ||||||||||||||||||||||||||||
| 56 | exponential => 1, | ||||||||||||||||||||||||||||
| 57 | flattop => 1, | ||||||||||||||||||||||||||||
| 58 | gaussian => 1, | ||||||||||||||||||||||||||||
| 59 | hamming => 1, | ||||||||||||||||||||||||||||
| 60 | hamming_ex => 1, | ||||||||||||||||||||||||||||
| 61 | hamming_gen => 1, | ||||||||||||||||||||||||||||
| 62 | hann => 1, | ||||||||||||||||||||||||||||
| 63 | hann_matlab => 1, | ||||||||||||||||||||||||||||
| 64 | hann_poisson => 1, | ||||||||||||||||||||||||||||
| 65 | kaiser => 1, | ||||||||||||||||||||||||||||
| 66 | lanczos => 1, | ||||||||||||||||||||||||||||
| 67 | nuttall => 1, | ||||||||||||||||||||||||||||
| 68 | nuttall1 => 1, | ||||||||||||||||||||||||||||
| 69 | parzen => 1, | ||||||||||||||||||||||||||||
| 70 | parzen_octave => 1, | ||||||||||||||||||||||||||||
| 71 | poisson => 1, | ||||||||||||||||||||||||||||
| 72 | rectangular => 1, | ||||||||||||||||||||||||||||
| 73 | triangular => 1, | ||||||||||||||||||||||||||||
| 74 | tukey => 1, | ||||||||||||||||||||||||||||
| 75 | welch => 1, | ||||||||||||||||||||||||||||
| 76 | ); | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | # These are not exported | ||||||||||||||||||||||||||||
| 79 | 2 | my %periodic_windows = ( | |||||||||||||||||||||||||||
| 80 | bartlett => 1, | ||||||||||||||||||||||||||||
| 81 | bartlett_hann => 1, | ||||||||||||||||||||||||||||
| 82 | blackman => 1, | ||||||||||||||||||||||||||||
| 83 | blackman_bnh => 1, | ||||||||||||||||||||||||||||
| 84 | blackman_ex => 1, | ||||||||||||||||||||||||||||
| 85 | blackman_gen => 1, | ||||||||||||||||||||||||||||
| 86 | blackman_gen3 => 1, | ||||||||||||||||||||||||||||
| 87 | blackman_gen4 => 1, | ||||||||||||||||||||||||||||
| 88 | blackman_gen5 => 1, | ||||||||||||||||||||||||||||
| 89 | blackman_harris => 1, | ||||||||||||||||||||||||||||
| 90 | blackman_harris4 => 1, | ||||||||||||||||||||||||||||
| 91 | blackman_nuttall => 1, | ||||||||||||||||||||||||||||
| 92 | bohman => 1, | ||||||||||||||||||||||||||||
| 93 | cauchy => 1, | ||||||||||||||||||||||||||||
| 94 | cos_alpha => 1, | ||||||||||||||||||||||||||||
| 95 | cosine => 1, | ||||||||||||||||||||||||||||
| 96 | dpss => 1, | ||||||||||||||||||||||||||||
| 97 | exponential => 1, | ||||||||||||||||||||||||||||
| 98 | flattop => 1, | ||||||||||||||||||||||||||||
| 99 | gaussian => 1, | ||||||||||||||||||||||||||||
| 100 | hamming => 1, | ||||||||||||||||||||||||||||
| 101 | hamming_ex => 1, | ||||||||||||||||||||||||||||
| 102 | hamming_gen => 1, | ||||||||||||||||||||||||||||
| 103 | hann => 1, | ||||||||||||||||||||||||||||
| 104 | hann_poisson => 1, | ||||||||||||||||||||||||||||
| 105 | kaiser => 1, | ||||||||||||||||||||||||||||
| 106 | lanczos => 1, | ||||||||||||||||||||||||||||
| 107 | nuttall => 1, | ||||||||||||||||||||||||||||
| 108 | nuttall1 => 1, | ||||||||||||||||||||||||||||
| 109 | parzen => 1, | ||||||||||||||||||||||||||||
| 110 | poisson => 1, | ||||||||||||||||||||||||||||
| 111 | rectangular => 1, | ||||||||||||||||||||||||||||
| 112 | triangular => 1, | ||||||||||||||||||||||||||||
| 113 | tukey => 1, | ||||||||||||||||||||||||||||
| 114 | welch => 1, | ||||||||||||||||||||||||||||
| 115 | ); | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 2 | my %window_aliases = ( | |||||||||||||||||||||||||||
| 118 | bartlett_hann => [ 'Modified Bartlett-Hann' ], | ||||||||||||||||||||||||||||
| 119 | bartlett => [ 'fejer' ], | ||||||||||||||||||||||||||||
| 120 | blackman_harris4 => [ 'Blackman-Harris' ], | ||||||||||||||||||||||||||||
| 121 | blackman_harris => [ 'Minimum three term (sample) Blackman-Harris' ], | ||||||||||||||||||||||||||||
| 122 | cauchy => [ 'Abel', 'Poisson' ], | ||||||||||||||||||||||||||||
| 123 | chebyshev => [ 'Dolph-Chebyshev' ], | ||||||||||||||||||||||||||||
| 124 | cos_alpha => [ 'Power-of-cosine' ], | ||||||||||||||||||||||||||||
| 125 | cosine => [ 'sine' ], | ||||||||||||||||||||||||||||
| 126 | dpss => [ 'sleppian' ], | ||||||||||||||||||||||||||||
| 127 | gaussian => [ 'Weierstrass' ], | ||||||||||||||||||||||||||||
| 128 | hann => [ 'hanning' ], | ||||||||||||||||||||||||||||
| 129 | kaiser => [ 'Kaiser-Bessel' ], | ||||||||||||||||||||||||||||
| 130 | lanczos => [ 'sinc' ], | ||||||||||||||||||||||||||||
| 131 | parzen => [ 'Jackson', 'Valle-Poussin' ], | ||||||||||||||||||||||||||||
| 132 | rectangular => [ 'dirichlet', 'boxcar' ], | ||||||||||||||||||||||||||||
| 133 | tukey => [ 'tapered cosine' ], | ||||||||||||||||||||||||||||
| 134 | welch => [ 'Riez', 'Bochner', 'Parzen', 'parabolic' ], | ||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 2 | my %window_parameters = ( | |||||||||||||||||||||||||||
| 138 | blackman_gen => [ '$alpha' ], | ||||||||||||||||||||||||||||
| 139 | blackman_gen3 => [ '$a0', '$a1', '$a2' ], | ||||||||||||||||||||||||||||
| 140 | blackman_gen4 => [ '$a0', '$a1', '$a2', '$a3' ], | ||||||||||||||||||||||||||||
| 141 | blackman_gen5 => [ '$a0', '$a1', '$a2', '$a3', '$a4' ], | ||||||||||||||||||||||||||||
| 142 | cauchy => [ '$alpha' ], | ||||||||||||||||||||||||||||
| 143 | chebyshev => [ '$at' ], | ||||||||||||||||||||||||||||
| 144 | cos_alpha => [ '$alpha' ], | ||||||||||||||||||||||||||||
| 145 | dpss => [ '$beta' ], | ||||||||||||||||||||||||||||
| 146 | gaussian => [ '$beta' ], | ||||||||||||||||||||||||||||
| 147 | hamming_gen => [ '$a' ], | ||||||||||||||||||||||||||||
| 148 | hann_poisson => [ '$alpha' ], | ||||||||||||||||||||||||||||
| 149 | kaiser => [ '$beta' ], | ||||||||||||||||||||||||||||
| 150 | poisson => [ '$alpha' ], | ||||||||||||||||||||||||||||
| 151 | tukey => [ '$alpha' ], | ||||||||||||||||||||||||||||
| 152 | ); | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 2 | my %window_names = ( | |||||||||||||||||||||||||||
| 155 | bartlett_hann => 'Bartlett-Hann', | ||||||||||||||||||||||||||||
| 156 | blackman_bnh => '*An improved version of the 3-term Blackman-Harris window given by Nuttall (Ref 2, p. 89).', | ||||||||||||||||||||||||||||
| 157 | blackman_ex => q!'exact' Blackman!, | ||||||||||||||||||||||||||||
| 158 | blackman_gen => '*A single parameter family of the 3-term Blackman window. ', | ||||||||||||||||||||||||||||
| 159 | blackman_gen3 => '*The general form of the Blackman family. ', | ||||||||||||||||||||||||||||
| 160 | blackman_gen4 => '*The general 4-term Blackman-Harris window. ', | ||||||||||||||||||||||||||||
| 161 | blackman_gen5 => '*The general 5-term Blackman-Harris window. ', | ||||||||||||||||||||||||||||
| 162 | blackman_harris4 => 'minimum (sidelobe) four term Blackman-Harris', | ||||||||||||||||||||||||||||
| 163 | blackman_harris => 'Blackman-Harris', | ||||||||||||||||||||||||||||
| 164 | blackman_nuttall => 'Blackman-Nuttall', | ||||||||||||||||||||||||||||
| 165 | blackman => q!'classic' Blackman!, | ||||||||||||||||||||||||||||
| 166 | dpss => 'Digital Prolate Spheroidal Sequence (DPSS)', | ||||||||||||||||||||||||||||
| 167 | flattop => 'flat top', | ||||||||||||||||||||||||||||
| 168 | hamming_ex => q!'exact' Hamming!, | ||||||||||||||||||||||||||||
| 169 | hamming_gen => 'general Hamming', | ||||||||||||||||||||||||||||
| 170 | hann_matlab => '*Equivalent to the Hann window of N+2 points, with the endpoints (which are both zero) removed.', | ||||||||||||||||||||||||||||
| 171 | hann_poisson => 'Hann-Poisson', | ||||||||||||||||||||||||||||
| 172 | nuttall1 => '*A window referred to as the Nuttall window.', | ||||||||||||||||||||||||||||
| 173 | parzen_octave => 'Parzen', | ||||||||||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 2 | my %window_print_names = ( | |||||||||||||||||||||||||||
| 177 | blackman_bnh => 'Blackman-Harris (bnh)', | ||||||||||||||||||||||||||||
| 178 | blackman_gen => 'General classic Blackman', | ||||||||||||||||||||||||||||
| 179 | hann_matlab => 'Hann (matlab)', | ||||||||||||||||||||||||||||
| 180 | nuttall1 => 'Nuttall (v1)', | ||||||||||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 2 | our @EXPORT_OK = ( | |||||||||||||||||||||||||||
| 184 | keys %symmetric_windows, | ||||||||||||||||||||||||||||
| 185 | qw( window list_windows chebpoly cos_mult_to_pow cos_pow_to_mult ), | ||||||||||||||||||||||||||||
| 186 | ); | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 2 | ▶ | $PDL::onlinedoc->scan(__FILE__) if $PDL::onlinedoc; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | =encoding utf8 | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =head1 NAME | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | PDL::DSP::Windows - Window functions for signal processing | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | use PDL; | ||||||||||||||||||||||||||||
| 199 | use PDL::DSP::Windows 'window'; | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | # Get a piddle with a window's samples with the helper | ||||||||||||||||||||||||||||
| 202 | my $samples = window( 10, tukey => { params => .5 }); | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | # Or construct a window object with the same parameters | ||||||||||||||||||||||||||||
| 205 | my $window = PDL::DSP::Windows->new( 10, tukey => { params => .5 }); | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | # These two are equivalent | ||||||||||||||||||||||||||||
| 208 | $samples = $window->samples; | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | # The window object gives access to additional methods | ||||||||||||||||||||||||||||
| 211 | print $window->coherent_gain, "\n"; | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | $window->plot; # Requires PDL::Graphics::Gnuplot | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | This module provides symmetric and periodic (DFT-symmetric) window functions | ||||||||||||||||||||||||||||
| 218 | for use in filtering and spectral analysis. It provides a high-level access | ||||||||||||||||||||||||||||
| 219 | subroutine L</window>. This functional interface is sufficient for getting | ||||||||||||||||||||||||||||
| 220 | the window samples. For analysis and plotting, etc. an object oriented | ||||||||||||||||||||||||||||
| 221 | interface is provided. The functional subroutines must be either explicitly | ||||||||||||||||||||||||||||
| 222 | exported, or fully qualified. In this document, the word I<function> refers | ||||||||||||||||||||||||||||
| 223 | only to the mathematical window functions, while the word I<subroutine> is | ||||||||||||||||||||||||||||
| 224 | used to describe code. | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | Window functions are also known as apodization functions or tapering functions. | ||||||||||||||||||||||||||||
| 227 | In this module, each of these functions maps a sequence of C<$N> integers to | ||||||||||||||||||||||||||||
| 228 | values called a B<samples>. (To confuse matters, the word I<sample> also has | ||||||||||||||||||||||||||||
| 229 | other meanings when describing window functions.) The functions are often | ||||||||||||||||||||||||||||
| 230 | named for authors of journal articles. Be aware that across the literature | ||||||||||||||||||||||||||||
| 231 | and software, some functions referred to by several different names, and some | ||||||||||||||||||||||||||||
| 232 | names refer to several different functions. As a result, the choice of window | ||||||||||||||||||||||||||||
| 233 | names is somewhat arbitrary. | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | The L</kaiser($N,$beta)> window function requires L<PDL::GSLSF::BESSEL>. The | ||||||||||||||||||||||||||||
| 236 | L</dpss($N,$beta)> window function requires L<PDL::LinearAlgebra>. But the | ||||||||||||||||||||||||||||
| 237 | remaining window functions may be used if these modules are not installed. | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | The most common and easiest usage of this module is indirect, via some | ||||||||||||||||||||||||||||
| 240 | higher-level filtering interface, such as L<PDL::DSP::Fir::Simple>. The next | ||||||||||||||||||||||||||||
| 241 | easiest usage is to return a pdl of real-space samples with the subroutine | ||||||||||||||||||||||||||||
| 242 | L</window>. Finally, for analyzing window functions, object methods, such as | ||||||||||||||||||||||||||||
| 243 | L</new>, L</plot>, L</plot_freq> are provided. | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | In the following, first the functional interface (non-object oriented) is | ||||||||||||||||||||||||||||
| 246 | described in L</'FUNCTIONAL INTERFACE'>. Next, the object methods are | ||||||||||||||||||||||||||||
| 247 | described in L</METHODS>. Next the low-level subroutines returning samples | ||||||||||||||||||||||||||||
| 248 | for each named window are described in L</'WINDOW FUNCTIONS'>. Finally, some | ||||||||||||||||||||||||||||
| 249 | support routines that may be of interest are described in | ||||||||||||||||||||||||||||
| 250 | L</'AUXILIARY SUBROUTINES'>. | ||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | =head1 FUNCTIONAL INTERFACE | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | =head2 window | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | $win = window({ OPTIONS }); | ||||||||||||||||||||||||||||
| 257 | $win = window( $N, { OPTIONS }); | ||||||||||||||||||||||||||||
| 258 | $win = window( $N, $name, { OPTIONS }); | ||||||||||||||||||||||||||||
| 259 | $win = window( $N, $name, $params, { OPTIONS }); | ||||||||||||||||||||||||||||
| 260 | $win = window( $N, $name, $params, $periodic ); | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | Returns an C<$N> point window of type C<$name>. The arguments may be passed | ||||||||||||||||||||||||||||
| 263 | positionally in the order C<$N, $name, $params, $periodic>, or they may be | ||||||||||||||||||||||||||||
| 264 | passed by name in the hash C<OPTIONS>. | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | =head3 EXAMPLES | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | # Each of the following return a 100 point symmetric hamming window. | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | $win = window(100); | ||||||||||||||||||||||||||||
| 271 | $win = window( 100, 'hamming' ); | ||||||||||||||||||||||||||||
| 272 | $win = window( 100, { name => 'hamming' }); | ||||||||||||||||||||||||||||
| 273 | $win = window({ N => 100, name => 'hamming' }); | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | # Each of the following returns a 100 point symmetric hann window. | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | $win = window( 100, 'hann' ); | ||||||||||||||||||||||||||||
| 278 | $win = window( 100, { name => 'hann' }); | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | # Returns a 100 point periodic hann window. | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | $win = window( 100, 'hann', { periodic => 1 }); | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | # Returns a 100 point symmetric Kaiser window with alpha = 2. | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | $win = window( 100, 'kaiser', { params => 2 }); | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | =head3 OPTIONS | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | The options follow default PDL::Options rules. They may be abbreviated, and | ||||||||||||||||||||||||||||
| 291 | are case-insensitive. | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | =over | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | =item B<name> | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | (string) name of window function. Default: C<hamming>. This selects one of | ||||||||||||||||||||||||||||
| 298 | the window functions listed below. Note that the suffix '_per', for periodic, | ||||||||||||||||||||||||||||
| 299 | may be ommitted. It is specified with the option C<< periodic => 1 >> | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | =item B<params> | ||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | ref to array of parameter or parameters for the window-function subroutine. | ||||||||||||||||||||||||||||
| 304 | Only some window-function subroutines take parameters. If the subroutine takes | ||||||||||||||||||||||||||||
| 305 | a single parameter, it may be given either as a number, or a list of one | ||||||||||||||||||||||||||||
| 306 | number. For example C<3> or C<[3]>. | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | =item B<N> | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | number of points in window function (the same as the order of the filter). | ||||||||||||||||||||||||||||
| 311 | No default value. | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | =item B<periodic> | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | If value is true, return a periodic rather than a symmetric window function. | ||||||||||||||||||||||||||||
| 316 | Defaults to false, meaning "symmetric". | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | =back | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | =cut | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 167 | ▶ | sub window { PDL::DSP::Windows->new(@_)->samples } | ||||||||||||||||||||||||||
|
Subroutine
window: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | =head2 list_windows | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | list_windows | ||||||||||||||||||||||||||||
| 327 | list_windows STR | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | C<list_windows> prints the names all of the available windows. | ||||||||||||||||||||||||||||
| 330 | C<list_windows STR> prints only the names of windows matching the string C<STR>. | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | =cut | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | sub list_windows { | ||||||||||||||||||||||||||||
| 335 | 0 | ▶ | my ($expr) = @_; | ||||||||||||||||||||||||||
|
Subroutine
list_windows: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | my @match; | |||||||||||||||||||||||||||
| 338 | 0 | ▶ | if ($expr) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 0 | for my $name ( sort keys %symmetric_windows ) { | |||||||||||||||||||||||||||
| 340 | 0 | ▶ | if ( $name =~ /$expr/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 341 | 0 | push @match, $name; | |||||||||||||||||||||||||||
| 342 | 0 | next; | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | push @match, | ||||||||||||||||||||||||||||
| 346 | map "$name (alias $_)", | ||||||||||||||||||||||||||||
| 347 | 0 | ▶ | grep /$expr/i, @{ $window_aliases{$name} // [] }; | ||||||||||||||||||||||||||
|
Condition0%0/2
$window_aliases{$name} // []
MC/DC0%0/1
$window_aliases{$name} // []
$window_aliases{$name}
Truth table0%0/2
A
A= $window_aliases{$name}
| |||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||
| 350 | else { | ||||||||||||||||||||||||||||
| 351 | 0 | @match = sort keys %symmetric_windows; | |||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 0 | print join( ', ', @match ), "\n"; | |||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | =head1 METHODS | ||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | =head2 new | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | =for usage | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | my $win = PDL::DSP::Windows->new(ARGS); | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | =for ref | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | Create an instance of a window object. If C<ARGS> are given, the instance | ||||||||||||||||||||||||||||
| 368 | is initialized. C<ARGS> are interpreted in exactly the same way as arguments | ||||||||||||||||||||||||||||
| 369 | for the L</window> subroutine. | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | =for example | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | For example: | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | my $win1 = PDL::DSP::Windows->new( 8, 'hann' ); | ||||||||||||||||||||||||||||
| 376 | my $win2 = PDL::DSP::Windows->new({ N => 8, name => 'hann' }); | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | =cut | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | sub new { | ||||||||||||||||||||||||||||
| 381 | 171 | ▶ | my $proto = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||
| 382 | 171 | ▶ | my $self = bless {}, ref $proto || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 383 | 171 | ▶ | $self->init(@_) if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 384 | 171 | return $self; | |||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | =head2 init | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | =for usage | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | $win->init(ARGS); | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | =for ref | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | Initialize (or reinitialize) a window object. C<ARGS> are interpreted in | ||||||||||||||||||||||||||||
| 396 | exactly the same way as arguments for the L</window> subroutine. | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | =for example | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | For example: | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | my $win = PDL::DSP::Windows->new( 8, 'hann' ); | ||||||||||||||||||||||||||||
| 403 | $win->init( 10, 'hamming' ); | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | =cut | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | sub init { | ||||||||||||||||||||||||||||
| 408 | 221 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=16 SCAR=28.0
Pod
documented
| |||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | 221 | my ( $N, $name, $params, $periodic ); | |||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | 221 | ▶ | $N = shift unless ref $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 413 | 221 | ▶ | $name = shift unless ref $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 414 | 221 | ▶ | $params = shift unless ref $_[0] eq 'HASH'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | 221 | ▶ | $periodic = shift unless ref $_[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 221 | ▶ | my $opts = PDL::Options->new({ | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() // {}
MC/DC100%1/1
shift() // {}
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 418 | name => 'hamming', | ||||||||||||||||||||||||||||
| 419 | periodic => 0, # symmetric or periodic | ||||||||||||||||||||||||||||
| 420 | N => undef, # order | ||||||||||||||||||||||||||||
| 421 | params => undef, | ||||||||||||||||||||||||||||
| 422 | })->options( shift // {} ); | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 221 | ▶ | $name ||= $opts->{name}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$name ||= $opts->{"name"}
MC/DC0%0/2
$name ||= $opts->{"name"}
$name
$opts->{"name"}
Truth table66%2/3
A ||= B
A= $nameB= $opts->{"name"}
| |||||||||||||||||||||||||||||
| 425 | 221 | ▶ | $N ||= $opts->{N}; | ||||||||||||||||||||||||||
|
Condition66%2/3
$N ||= $opts->{"N"}
MC/DC0%0/2
$N ||= $opts->{"N"}
$N
$opts->{"N"}
Truth table66%2/3
A ||= B
A= $NB= $opts->{"N"}
| |||||||||||||||||||||||||||||
| 426 | 221 | ▶ | $periodic ||= $opts->{periodic}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$periodic ||= $opts->{"periodic"}
MC/DC100%2/2
$periodic ||= $opts->{"periodic"}
$periodic
$opts->{"periodic"}
Truth table100%3/3
A ||= B
A= $periodicB= $opts->{"periodic"}
| |||||||||||||||||||||||||||||
| 427 | 221 | ▶ | $params //= $opts->{params}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$params //= $opts->{"params"}
MC/DC100%2/2
$params //= $opts->{"params"}
$params
$opts->{"params"}
Truth table100%3/3
A //= B
A= $paramsB= $opts->{"params"}
| |||||||||||||||||||||||||||||
| 428 | 221 | ▶ | $params = [$params] if defined $params && !ref $params; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $params and not ref $params
MC/DC100%2/2
defined $params and not ref $params
defined $params
not ref $params
Truth table100%3/3
A and not(B)
A= defined $paramsB= not ref $params
| |||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | 221 | $name =~ s/_per$//; | |||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | 221 | ▶ | my $windows = $periodic ? \%periodic_windows : \%symmetric_windows; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 433 | 221 | ▶ | unless ( $windows->{$name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 434 | 0 | ▶ | my $type = $periodic ? 'periodic' : 'symmetric'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 435 | 0 | PDL::Core::barf "window: Unknown $type window '$name'."; | |||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | 221 | $self->{name} = $name; | |||||||||||||||||||||||||||
| 439 | 221 | $self->{N} = $N; | |||||||||||||||||||||||||||
| 440 | 221 | $self->{periodic} = $periodic; | |||||||||||||||||||||||||||
| 441 | 221 | $self->{params} = $params; | |||||||||||||||||||||||||||
| 442 | 221 | ▶ | $self->{code} = __PACKAGE__->can( $name . ( $periodic ? '_per' : '' ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 443 | 221 | $self->{samples} = undef; | |||||||||||||||||||||||||||
| 444 | 221 | $self->{modfreqs} = undef; | |||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | 221 | return $self; | |||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | =head2 samples | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | =for usage | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | $win->samples; | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | =for ref | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | Generate and return a reference to the piddle of C<$N> samples for the window | ||||||||||||||||||||||||||||
| 458 | C<$win>. This is the real-space representation of the window. | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | The samples are stored in the object C<$win>, but are regenerated every time | ||||||||||||||||||||||||||||
| 461 | C<samples> is invoked. See the method L</get_samples> below. | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | =for example | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | For example: | ||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | my $win = PDL::DSP::Windows->new( 8, 'hann' ); | ||||||||||||||||||||||||||||
| 468 | print $win->samples, "\n"; | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | =cut | ||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||
| 472 | sub samples { | ||||||||||||||||||||||||||||
| 473 | 221 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
samples: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 474 | 221 | ▶ | my @args = ( $self->{N}, @{ $self->{params} // [] } ); | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"params"} // []
MC/DC100%1/1
$self->{"params"} // []
$self->{"params"}
Truth table100%2/2
A
A= $self->{"params"}
| |||||||||||||||||||||||||||||
| 475 | 221 | $self->{samples} = $self->{code}->(@args); | |||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | =head2 modfreqs | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | =for usage | ||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | $win->modfreqs; | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | =for ref | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | Generate and return a reference to the piddle of the modulus of the fourier | ||||||||||||||||||||||||||||
| 487 | transform of the samples for the window C<$win>. | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | These values are stored in the object C<$win>, but are regenerated every time | ||||||||||||||||||||||||||||
| 490 | C<modfreqs> is invoked. See the method L</get_modfreqs> below. | ||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | =head3 options | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | =over | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | =item min_bins => MIN | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | This sets the minimum number of frequency bins. Defaults to 1000. If necessary, | ||||||||||||||||||||||||||||
| 499 | the piddle of window samples are padded with zeroes before the fourier transform | ||||||||||||||||||||||||||||
| 500 | is performed. | ||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | =back | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | =cut | ||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | sub modfreqs { | ||||||||||||||||||||||||||||
| 507 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
modfreqs: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 508 | 2 | my %opts = PDL::Options::iparse( { min_bins => 1000 }, PDL::Options::ifhref(shift) ); | |||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | 2 | my $data = $self->get_samples; | |||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | 2 | my $n = $data->nelem; | |||||||||||||||||||||||||||
| 513 | 2 | ▶ | my $fn = $n > $opts{min_bins} ? 2 * $n : $opts{min_bins}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | 2 | $n--; | |||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | 2 | my $freq = PDL::Core::zeroes($fn); | |||||||||||||||||||||||||||
| 518 | 2 | $freq->slice("0:$n") .= $data; | |||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | 2 | PDL::FFT::realfft($freq); | |||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | 2 | my $real = PDL::Core::zeroes($freq); | |||||||||||||||||||||||||||
| 523 | 2 | my $img = PDL::Core::zeroes($freq); | |||||||||||||||||||||||||||
| 524 | 2 | my $mid = ( $freq->nelem ) / 2 - 1; | |||||||||||||||||||||||||||
| 525 | 2 | my $mid1 = $mid + 1; | |||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | 2 | $real->slice("0:$mid") .= $freq->slice("$mid:0:-1"); | |||||||||||||||||||||||||||
| 528 | 2 | $real->slice("$mid1:-1") .= $freq->slice("0:$mid"); | |||||||||||||||||||||||||||
| 529 | 2 | $img->slice("0:$mid") .= $freq->slice("-1:$mid1:-1"); | |||||||||||||||||||||||||||
| 530 | 2 | $img->slice("$mid1:-1") .= $freq->slice("$mid1:-1"); | |||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | 2 | return $self->{modfreqs} = $real ** 2 + $img ** 2; | |||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||
| 535 | =head2 get | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | =for usage | ||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | my $windata = $win->get('samples'); | ||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | =for ref | ||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||
| 543 | Get an attribute (or list of attributes) of the window C<$win>. If attribute | ||||||||||||||||||||||||||||
| 544 | C<samples> is requested, then the samples are created with the method | ||||||||||||||||||||||||||||
| 545 | L</samples> if they don't exist. | ||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||
| 547 | =for example | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | For example: | ||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||
| 551 | my $win = PDL::DSP::Windows->new( 8, 'hann' ); | ||||||||||||||||||||||||||||
| 552 | print $win->get('samples'), "\n"; | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | =cut | ||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||
| 556 | sub get { | ||||||||||||||||||||||||||||
| 557 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 558 | 0 | my @res; | |||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | 0 | for (@_) { | |||||||||||||||||||||||||||
| 561 | 0 | ▶ | if ($_ eq 'samples') { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 562 | 0 | push @res, $self->get_samples; | |||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||
| 564 | elsif ($_ eq 'modfreqs') { | ||||||||||||||||||||||||||||
| 565 | 0 | push @res, $self->get_modfreqs; | |||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||
| 567 | else { | ||||||||||||||||||||||||||||
| 568 | 0 | push @res, $self->{$_}; | |||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||
| 570 | }; | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | 0 | ▶ | return wantarray ? @res : $res[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | =head2 get_samples | ||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | =for usage | ||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||
| 579 | my $windata = $win->get_samples; | ||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||
| 581 | =for ref | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | Return a reference to the pdl of samples for the Window instance C<$win>. The | ||||||||||||||||||||||||||||
| 584 | samples will be generated with the method L</samples> if and only if they have | ||||||||||||||||||||||||||||
| 585 | not yet been generated. | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | =cut | ||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||
| 589 | sub get_samples { | ||||||||||||||||||||||||||||
| 590 | 17 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_samples: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 591 | 17 | ▶ | return $self->{samples} if defined $self->{samples}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 592 | 17 | return $self->samples; | |||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | =head2 get_modfreqs | ||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||
| 597 | =for usage | ||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||
| 599 | my $winfreqs = $win->get_modfreqs; | ||||||||||||||||||||||||||||
| 600 | my $winfreqs = $win->get_modfreqs(OPTS); | ||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||
| 602 | =for ref | ||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||
| 604 | Return a reference to the pdl of the frequency response (modulus of the DFT) | ||||||||||||||||||||||||||||
| 605 | for the Window instance C<$win>. | ||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||
| 607 | Options passed as a hash reference will be passed to the L</modfreqs>. The | ||||||||||||||||||||||||||||
| 608 | data are created with L</modfreqs> if they don't exist. The data are also | ||||||||||||||||||||||||||||
| 609 | created even if they already exist if options are supplied. Otherwise the | ||||||||||||||||||||||||||||
| 610 | cached data are returned. | ||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | =head3 options | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | =over | ||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | =item min_bins => MIN | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | This sets the minimum number of frequency bins. See L</modfreqs>. Defaults | ||||||||||||||||||||||||||||
| 619 | to 1000. | ||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||
| 621 | =back | ||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||
| 623 | =cut | ||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | sub get_modfreqs { | ||||||||||||||||||||||||||||
| 626 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_modfreqs: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 627 | 0 | ▶ | return $self->modfreqs(@_) if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 628 | 0 | ▶ | return $self->{modfreqs} if defined $self->{modfreqs}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 629 | 0 | return $self->modfreqs; | |||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | =head2 get_params | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | =for usage | ||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||
| 636 | my $params = $win->get_params; | ||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||
| 638 | =for ref | ||||||||||||||||||||||||||||
| 639 | |||||||||||||||||||||||||||||
| 640 | Create a new array containing the parameter values for the instance C<$win> | ||||||||||||||||||||||||||||
| 641 | and return a reference to the array. Note that not all window types take | ||||||||||||||||||||||||||||
| 642 | parameters. | ||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | =cut | ||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||
| 646 | 0 | ▶ | sub get_params { shift->{params} } | ||||||||||||||||||||||||||
|
Subroutine
get_params: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | 0 | ▶ | sub get_N { shift->{N} } | ||||||||||||||||||||||||||
|
Subroutine
get_N: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||
| 650 | =head2 get_name | ||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||
| 652 | =for usage | ||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||
| 654 | print $win->get_name, "\n"; | ||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||
| 656 | =for ref | ||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | Return a name suitable for printing associated with the window C<$win>. This is | ||||||||||||||||||||||||||||
| 659 | something like the name used in the documentation for the particular window | ||||||||||||||||||||||||||||
| 660 | function. This is static data and does not depend on the instance. | ||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | =cut | ||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | sub get_name { | ||||||||||||||||||||||||||||
| 665 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_name: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||
| 667 | 0 | ▶ | if ( my $name = $window_print_names{ $self->{name} } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 668 | 0 | return "$name window"; | |||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||
| 671 | 0 | ▶ | if ( my $name = $window_names{ $self->{name} } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 672 | 0 | ▶ | return "$name window" unless $name =~ /^\*/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 673 | 0 | return $name; | |||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||
| 676 | 0 | return ucfirst $self->{name} . ' window'; | |||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | sub get_param_names { | ||||||||||||||||||||||||||||
| 680 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get_param_names: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 681 | 0 | my $params = $window_parameters{ $self->{name} }; | |||||||||||||||||||||||||||
| 682 | 0 | ▶ | return undef unless $params; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 683 | 0 | return [ @{$params} ]; | |||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||
| 686 | sub format_param_vals { | ||||||||||||||||||||||||||||
| 687 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
format_param_vals: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | 0 | ▶ | my @params = @{ $self->{params} || [] }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 690 | 0 | ▶ | return '' unless @params; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||
| 692 | 0 | ▶ | my @names = @{ $self->get_param_names || [] }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 693 | 0 | ▶ | return '' unless @names; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||
| 695 | join ', ', map { | ||||||||||||||||||||||||||||
| 696 | 0 | my $name = $names[$_]; | |||||||||||||||||||||||||||
| 697 | 0 | $name =~ s/^\$//; | |||||||||||||||||||||||||||
| 698 | 0 | join' = ', $name, $params[$_]; | |||||||||||||||||||||||||||
| 699 | } 0 .. $#params; | ||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | sub format_plot_param_vals { | ||||||||||||||||||||||||||||
| 703 | 0 | ▶ | my $ps = shift->format_param_vals; | ||||||||||||||||||||||||||
|
Subroutine
format_plot_param_vals: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 704 | 0 | ▶ | return $ps ? ": $ps" : $ps; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||
| 707 | =head2 plot | ||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||
| 709 | =for usage | ||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||
| 711 | $win->plot; | ||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | =for ref | ||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||
| 715 | Plot the samples. Currently, only L<PDL::Graphics::Gnuplot> is supported. The | ||||||||||||||||||||||||||||
| 716 | default display type is used. | ||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||
| 718 | =cut | ||||||||||||||||||||||||||||
| 719 | |||||||||||||||||||||||||||||
| 720 | sub plot { | ||||||||||||||||||||||||||||
| 721 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
plot: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 722 | 0 | PDL::Core::barf 'PDL::DSP::Windows::plot Gnuplot not available!' unless HAVE_GNUPLOT; | |||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||
| 724 | 0 | PDL::Graphics::Gnuplot::plot( | |||||||||||||||||||||||||||
| 725 | title => $self->get_name . $self->format_plot_param_vals, | ||||||||||||||||||||||||||||
| 726 | xlabel => 'Time (samples)', | ||||||||||||||||||||||||||||
| 727 | ylabel => 'amplitude', | ||||||||||||||||||||||||||||
| 728 | $self->get_samples, | ||||||||||||||||||||||||||||
| 729 | ); | ||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||
| 731 | 0 | return $self; | |||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||
| 734 | =head2 plot_freq | ||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||
| 736 | =for usage | ||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||
| 738 | Can be called like this | ||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||
| 740 | $win->plot_freq; | ||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||
| 742 | Or this | ||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||
| 744 | $win->plot_freq({ ordinate => ORDINATE }); | ||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||
| 746 | =for ref | ||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||
| 748 | Plot the frequency response (magnitude of the DFT of the window samples). | ||||||||||||||||||||||||||||
| 749 | The response is plotted in dB, and the frequency (by default) as a fraction of | ||||||||||||||||||||||||||||
| 750 | the Nyquist frequency. Currently, only L<PDL::Graphics::Gnuplot> is supported. | ||||||||||||||||||||||||||||
| 751 | The default display type is used. | ||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||
| 753 | =head3 options | ||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||
| 755 | =over | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | =item coord => COORD | ||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | This sets the units of frequency of the co-ordinate axis. C<COORD> must be one | ||||||||||||||||||||||||||||
| 760 | of C<nyquist>, for fraction of the nyquist frequency (range C<-1, 1>); | ||||||||||||||||||||||||||||
| 761 | C<sample>, for fraction of the sampling frequncy (range C<-0.5, 0.5>); or | ||||||||||||||||||||||||||||
| 762 | C<bin> for frequency bin number (range C<0, $N - 1>). The default value is | ||||||||||||||||||||||||||||
| 763 | C<nyquist>. | ||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | =item min_bins => MIN | ||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||
| 767 | This sets the minimum number of frequency bins. See L</get_modfreqs>. | ||||||||||||||||||||||||||||
| 768 | Defaults to 1000. | ||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||
| 770 | =back | ||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||
| 772 | =cut | ||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||
| 774 | sub plot_freq { | ||||||||||||||||||||||||||||
| 775 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
plot_freq: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||
| 777 | 0 | PDL::Core::barf 'PDL::DSP::Windows::plot Gnuplot not available!' unless HAVE_GNUPLOT; | |||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||
| 779 | 0 | ▶ | my $opts = new PDL::Options({ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 780 | coord => 'nyquist', | ||||||||||||||||||||||||||||
| 781 | min_bins => 1000 | ||||||||||||||||||||||||||||
| 782 | })->options( @_ ? shift : {} ); | ||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||
| 784 | 0 | my $mf = $self->get_modfreqs({ min_bins => $opts->{min_bins} }); | |||||||||||||||||||||||||||
| 785 | 0 | $mf /= $mf->max; | |||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||
| 787 | 0 | my $title = $self->get_name . $self->format_plot_param_vals | |||||||||||||||||||||||||||
| 788 | . ', frequency response. ENBW=' . sprintf( '%2.3f', $self->enbw ); | ||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||
| 790 | 0 | my $coord = $opts->{coord}; | |||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||
| 792 | 0 | my ( $coordinate_range, $xlab ); | |||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||
| 794 | 0 | ▶ | if ($coord eq 'nyquist') { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 795 | 0 | $coordinate_range = 1; | |||||||||||||||||||||||||||
| 796 | 0 | $xlab = 'Fraction of Nyquist frequency'; | |||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||
| 798 | elsif ($coord eq 'sample') { | ||||||||||||||||||||||||||||
| 799 | 0 | $coordinate_range = 0.5; | |||||||||||||||||||||||||||
| 800 | 0 | $xlab = 'Fraction of sampling frequency'; | |||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||
| 802 | elsif ($coord eq 'bin') { | ||||||||||||||||||||||||||||
| 803 | 0 | $coordinate_range = $self->{N} / 2; | |||||||||||||||||||||||||||
| 804 | 0 | $xlab = 'bin'; | |||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||
| 806 | else { | ||||||||||||||||||||||||||||
| 807 | 0 | PDL::Core::barf "plot_freq: Unknown ordinate unit specification $coord"; | |||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||
| 810 | 0 | my $ylab = 'frequency response (dB)'; | |||||||||||||||||||||||||||
| 811 | 0 | my $coordinates = PDL::Core::zeroes($mf) | |||||||||||||||||||||||||||
| 812 | ->xlinvals( -$coordinate_range, $coordinate_range ); | ||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||
| 814 | 0 | PDL::Graphics::Gnuplot::plot( | |||||||||||||||||||||||||||
| 815 | title => $title, | ||||||||||||||||||||||||||||
| 816 | xmin => -$coordinate_range, | ||||||||||||||||||||||||||||
| 817 | xmax => $coordinate_range, | ||||||||||||||||||||||||||||
| 818 | xlabel => $xlab, | ||||||||||||||||||||||||||||
| 819 | ylabel => $ylab, | ||||||||||||||||||||||||||||
| 820 | with => 'line', | ||||||||||||||||||||||||||||
| 821 | $coordinates, | ||||||||||||||||||||||||||||
| 822 | 20 * PDL::Ops::log10($mf), | ||||||||||||||||||||||||||||
| 823 | ); | ||||||||||||||||||||||||||||
| 824 | |||||||||||||||||||||||||||||
| 825 | 0 | return $self; | |||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||
| 828 | =head2 enbw | ||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||
| 830 | =for usage | ||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||
| 832 | $win->enbw; | ||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||
| 834 | =for ref | ||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||
| 836 | Compute and return the equivalent noise bandwidth of the window. | ||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||
| 838 | =cut | ||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||
| 840 | sub enbw { | ||||||||||||||||||||||||||||
| 841 | 15 | ▶ | my $w = shift->get_samples; | ||||||||||||||||||||||||||
|
Subroutine
enbw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 842 | 15 | $w->nelem * ( $w ** 2 )->sum / $w->sum ** 2; | |||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||
| 845 | =head2 coherent_gain | ||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||
| 847 | =for usage | ||||||||||||||||||||||||||||
| 848 | |||||||||||||||||||||||||||||
| 849 | $win->coherent_gain; | ||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||
| 851 | =for ref | ||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||
| 853 | Compute and return the coherent gain (the dc gain) of the window. This is just | ||||||||||||||||||||||||||||
| 854 | the average of the samples. | ||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||
| 856 | =cut | ||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||
| 858 | sub coherent_gain { | ||||||||||||||||||||||||||||
| 859 | 0 | ▶ | my $w = shift->get_samples; | ||||||||||||||||||||||||||
|
Subroutine
coherent_gain: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 860 | 0 | $w->sum / $w->nelem; | |||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||
| 864 | =head2 process_gain | ||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||
| 866 | =for usage | ||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||
| 868 | $win->coherent_gain; | ||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||
| 870 | =for ref | ||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||
| 872 | Compute and return the processing gain (the dc gain) of the window. This is | ||||||||||||||||||||||||||||
| 873 | just the multiplicative inverse of the C<enbw>. | ||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||
| 875 | =cut | ||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||
| 877 | 0 | ▶ | sub process_gain { 1 / shift->enbw } | ||||||||||||||||||||||||||
|
Subroutine
process_gain: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||
| 879 | # not quite correct for some reason. | ||||||||||||||||||||||||||||
| 880 | # Seems like 10*log10(this) / 1.154 | ||||||||||||||||||||||||||||
| 881 | # gives the correct answer in decibels | ||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||
| 883 | =head2 scallop_loss | ||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||
| 885 | =for usage | ||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||
| 887 | $win->scallop_loss; | ||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||
| 889 | =for ref | ||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||
| 891 | Compute and return the scalloping loss of the window. | ||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||
| 893 | =cut | ||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||
| 895 | sub scallop_loss { | ||||||||||||||||||||||||||||
| 896 | 37 | ▶ | my $w = shift->samples; | ||||||||||||||||||||||||||
|
Subroutine
scallop_loss: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||
| 898 | # Adapted from https://stackoverflow.com/a/40912607 | ||||||||||||||||||||||||||||
| 899 | 37 | my $num = $w * exp( -( I()->im * PDL::sequence($w) * PI / $w->nelem ) ); | |||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||
| 901 | 37 | 20 * PDL::Ops::log10( abs( $num->sum ) / abs($w)->sum ); | |||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||
| 904 | =head1 WINDOW FUNCTIONS | ||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||
| 906 | These window-function subroutines return a pdl of C<$N> samples. For most | ||||||||||||||||||||||||||||
| 907 | windows, there are a symmetric and a periodic version. The symmetric versions | ||||||||||||||||||||||||||||
| 908 | are functions of C<$N> points, uniformly spaced, and taking values from x_lo | ||||||||||||||||||||||||||||
| 909 | through x_hi. Here, a periodic function of C< $N > points is equivalent to its | ||||||||||||||||||||||||||||
| 910 | symmetric counterpart of C<$N + 1> points, with the final point omitted. The | ||||||||||||||||||||||||||||
| 911 | name of a periodic window-function subroutine is the same as that for the | ||||||||||||||||||||||||||||
| 912 | corresponding symmetric function, except it has the suffix C<_per>. The | ||||||||||||||||||||||||||||
| 913 | descriptions below describe the symmetric version of each window. | ||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||
| 915 | The term 'Blackman-Harris family' is meant to include the Hamming family and | ||||||||||||||||||||||||||||
| 916 | the Blackman family. These are functions of sums of cosines. | ||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||
| 918 | Unless otherwise noted, the arguments in the cosines of all symmetric window | ||||||||||||||||||||||||||||
| 919 | functions are multiples of C<$N> numbers uniformly spaced from 0 through | ||||||||||||||||||||||||||||
| 920 | 2Ï€. | ||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||
| 922 | =cut | ||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||
| 924 | sub bartlett { | ||||||||||||||||||||||||||||
| 925 | 4 | ▶ | PDL::Core::barf 'bartlett: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
bartlett: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 926 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 927 | 2 | 1 - abs( PDL::Core::zeroes($N)->xlinvals( -1, 1 ) ); | |||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||
| 930 | sub bartlett_per { | ||||||||||||||||||||||||||||
| 931 | 4 | ▶ | PDL::Core::barf 'bartlett: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
bartlett_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 932 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 933 | 2 | 1 - abs( PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + 1 * ( $N - 1 ) ) / $N ) ); | |||||||||||||||||||||||||||
| 934 | } | ||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||
| 936 | sub bartlett_hann { | ||||||||||||||||||||||||||||
| 937 | 6 | ▶ | PDL::Core::barf 'bartlett_hann: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
bartlett_hann: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 938 | 4 | my ($N) = @_; | |||||||||||||||||||||||||||
| 939 | 4 | 0.62 - 0.48 * abs( PDL::Core::zeroes($N)->xlinvals( -0.5, 0.5 ) ) | |||||||||||||||||||||||||||
| 940 | + 0.38 * cos( PDL::Core::zeroes($N)->xlinvals( - PI, PI ) ); | ||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||
| 943 | sub bartlett_hann_per { | ||||||||||||||||||||||||||||
| 944 | 4 | ▶ | PDL::Core::barf 'bartlett_hann: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
bartlett_hann_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 945 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 946 | 2 | 0.62 - 0.48 * abs( PDL::Core::zeroes($N)->xlinvals( -0.5, ( -0.5 + 0.5 * ( $N - 1 ) ) / $N ) ) | |||||||||||||||||||||||||||
| 947 | + 0.38 * cos( PDL::Core::zeroes($N)->xlinvals( - PI, ( - PI + PI * ( $N - 1 ) ) / $N ) ); | ||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||
| 950 | sub blackman { | ||||||||||||||||||||||||||||
| 951 | 6 | ▶ | PDL::Core::barf 'blackman: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 952 | 4 | my ($N) = @_; | |||||||||||||||||||||||||||
| 953 | 4 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 954 | 4 | 0.34 + $cx * ( -0.5 + $cx * 0.16 ); | |||||||||||||||||||||||||||
| 955 | } | ||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||
| 957 | sub blackman_per { | ||||||||||||||||||||||||||||
| 958 | 4 | ▶ | PDL::Core::barf 'blackman: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 959 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 960 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 961 | 2 | 0.34 + $cx * ( -0.5 + $cx * 0.16 ); | |||||||||||||||||||||||||||
| 962 | } | ||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||
| 964 | sub blackman_bnh { | ||||||||||||||||||||||||||||
| 965 | 4 | ▶ | PDL::Core::barf 'blackman_bnh: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_bnh: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 966 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 967 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 968 | 2 | 0.3461008 + $cx * ( -0.4973406 + $cx * 0.1565586 ); | |||||||||||||||||||||||||||
| 969 | } | ||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||
| 971 | sub blackman_bnh_per { | ||||||||||||||||||||||||||||
| 972 | 4 | ▶ | PDL::Core::barf 'blackman_bnh: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_bnh_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 973 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 974 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 975 | 2 | 0.3461008 + $cx * ( -0.4973406 + $cx * 0.1565586 ); | |||||||||||||||||||||||||||
| 976 | } | ||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||
| 978 | sub blackman_ex { | ||||||||||||||||||||||||||||
| 979 | 5 | ▶ | PDL::Core::barf 'blackman_ex: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_ex: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 980 | 3 | my ($N) = @_; | |||||||||||||||||||||||||||
| 981 | 3 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 982 | 3 | 0.349742046431642 + $cx * ( -0.496560619088564 + $cx * 0.153697334479794 ); | |||||||||||||||||||||||||||
| 983 | } | ||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||
| 985 | sub blackman_ex_per { | ||||||||||||||||||||||||||||
| 986 | 4 | ▶ | PDL::Core::barf 'blackman_ex: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_ex_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 987 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 988 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 989 | 2 | 0.349742046431642 + $cx * ( -0.496560619088564 + $cx * 0.153697334479794 ); | |||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||
| 991 | |||||||||||||||||||||||||||||
| 992 | sub blackman_gen { | ||||||||||||||||||||||||||||
| 993 | 8 | ▶ | PDL::Core::barf 'blackman_gen: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
blackman_gen: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 994 | 5 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 995 | 5 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 996 | 5 | 0.5 - $alpha + $cx * ( -0.5 + $cx * $alpha ); | |||||||||||||||||||||||||||
| 997 | } | ||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||
| 999 | sub blackman_gen_per { | ||||||||||||||||||||||||||||
| 1000 | 5 | ▶ | PDL::Core::barf 'blackman_gen: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
blackman_gen_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1001 | 2 | my ($N,$alpha) = @_; | |||||||||||||||||||||||||||
| 1002 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1003 | 2 | 0.5 - $alpha + $cx * ( -0.5 + $cx * $alpha ); | |||||||||||||||||||||||||||
| 1004 | } | ||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||
| 1006 | sub blackman_gen3 { | ||||||||||||||||||||||||||||
| 1007 | 7 | ▶ | PDL::Core::barf 'blackman_gen3: 4 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 4; | ||||||||||||||||||||||||||
|
Subroutine
blackman_gen3: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1008 | 2 | my ($N,$a0,$a1,$a2) = @_; | |||||||||||||||||||||||||||
| 1009 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1010 | 2 | $a0 - $a2 + ( $cx * ( -$a1 + $cx * 2 * $a2 ) ); | |||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||
| 1012 | |||||||||||||||||||||||||||||
| 1013 | sub blackman_gen3_per { | ||||||||||||||||||||||||||||
| 1014 | 7 | ▶ | PDL::Core::barf 'blackman_gen3: 4 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 4; | ||||||||||||||||||||||||||
|
Subroutine
blackman_gen3_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1015 | 2 | my ( $N, $a0, $a1, $a2 ) = @_; | |||||||||||||||||||||||||||
| 1016 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1017 | 2 | $a0 - $a2 + ( $cx * ( -$a1 + $cx * 2 * $a2 ) ); | |||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||
| 1019 | |||||||||||||||||||||||||||||
| 1020 | sub blackman_gen4 { | ||||||||||||||||||||||||||||
| 1021 | 8 | ▶ | PDL::Core::barf 'blackman_gen4: 5 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 5; | ||||||||||||||||||||||||||
|
Subroutine
blackman_gen4: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1022 | 2 | my ( $N, $a0, $a1, $a2, $a3 ) = @_; | |||||||||||||||||||||||||||
| 1023 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1024 | 2 | $a0 - $a2 + $cx * ( ( -$a1 + 3 * $a3 ) + $cx * ( 2 * $a2 + $cx * -4 * $a3 ) ); | |||||||||||||||||||||||||||
| 1025 | } | ||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||
| 1027 | sub blackman_gen4_per { | ||||||||||||||||||||||||||||
| 1028 | 8 | ▶ | PDL::Core::barf 'blackman_gen4: 5 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 5; | ||||||||||||||||||||||||||
|
Subroutine
blackman_gen4_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1029 | 2 | my ( $N, $a0, $a1, $a2, $a3 ) = @_; | |||||||||||||||||||||||||||
| 1030 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1031 | 2 | $a0 - $a2 + $cx * ( ( -$a1 + 3 * $a3 ) + $cx * ( 2 * $a2 + $cx * -4 * $a3 ) ); | |||||||||||||||||||||||||||
| 1032 | } | ||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||
| 1034 | sub blackman_gen5 { | ||||||||||||||||||||||||||||
| 1035 | 9 | ▶ | PDL::Core::barf 'blackman_gen5: 6 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 6; | ||||||||||||||||||||||||||
|
Subroutine
blackman_gen5: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1036 | 2 | my ( $N, $a0, $a1, $a2, $a3, $a4 ) = @_; | |||||||||||||||||||||||||||
| 1037 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1038 | 2 | $a0 - $a2 + $a4 + $cx * ( ( -$a1 + 3 * $a3 ) | |||||||||||||||||||||||||||
| 1039 | + $cx * ( 2 * $a2 - 8 * $a4 + $cx * ( -4 * $a3 + $cx * 8 * $a4 ) ) ); | ||||||||||||||||||||||||||||
| 1040 | } | ||||||||||||||||||||||||||||
| 1041 | |||||||||||||||||||||||||||||
| 1042 | sub blackman_gen5_per { | ||||||||||||||||||||||||||||
| 1043 | 9 | ▶ | PDL::Core::barf 'blackman_gen5: 6 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 6; | ||||||||||||||||||||||||||
|
Subroutine
blackman_gen5_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1044 | 2 | my ( $N, $a0, $a1, $a2, $a3, $a4 ) = @_; | |||||||||||||||||||||||||||
| 1045 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1046 | 2 | $a0 - $a2 + $a4 + $cx * ( ( -$a1 + 3 * $a3 ) | |||||||||||||||||||||||||||
| 1047 | + $cx * ( 2 * $a2 - 8 * $a4 + $cx * ( -4 * $a3 + $cx * 8 * $a4 ) ) ); | ||||||||||||||||||||||||||||
| 1048 | } | ||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||
| 1050 | sub blackman_harris { | ||||||||||||||||||||||||||||
| 1051 | 5 | ▶ | PDL::Core::barf 'blackman_harris: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_harris: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1052 | 3 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1053 | 3 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1054 | 3 | 0.343103 + $cx * ( -0.49755 + $cx * 0.15844 ); | |||||||||||||||||||||||||||
| 1055 | } | ||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||
| 1057 | sub blackman_harris_per { | ||||||||||||||||||||||||||||
| 1058 | 4 | ▶ | PDL::Core::barf 'blackman_harris: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_harris_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1059 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1060 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1061 | 2 | 0.343103 + $cx * ( -0.49755 + $cx * 0.15844 ); | |||||||||||||||||||||||||||
| 1062 | } | ||||||||||||||||||||||||||||
| 1063 | |||||||||||||||||||||||||||||
| 1064 | sub blackman_harris4 { | ||||||||||||||||||||||||||||
| 1065 | 6 | ▶ | PDL::Core::barf 'blackman_harris4: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_harris4: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1066 | 4 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1067 | 4 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1068 | 4 | 0.21747 + $cx * ( -0.45325 + $cx * ( 0.28256 + $cx * -0.04672 ) ); | |||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||
| 1071 | sub blackman_harris4_per { | ||||||||||||||||||||||||||||
| 1072 | 4 | ▶ | PDL::Core::barf 'blackman_harris4: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_harris4_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1073 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1074 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1075 | 2 | 0.21747 + $cx * ( -0.45325 + $cx * ( 0.28256 + $cx * -0.04672 ) ); | |||||||||||||||||||||||||||
| 1076 | } | ||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||
| 1078 | sub blackman_nuttall { | ||||||||||||||||||||||||||||
| 1079 | 6 | ▶ | PDL::Core::barf 'blackman_nuttall: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_nuttall: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1080 | 4 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1081 | 4 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1082 | 4 | 0.2269824 + $cx * ( -0.4572542 + $cx * ( 0.273199 + $cx * -0.0425644 ) ); | |||||||||||||||||||||||||||
| 1083 | } | ||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||
| 1085 | sub blackman_nuttall_per { | ||||||||||||||||||||||||||||
| 1086 | 4 | ▶ | PDL::Core::barf 'blackman_nuttall: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
blackman_nuttall_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1087 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1088 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1089 | 2 | 0.2269824 + $cx * ( -0.4572542 + $cx * ( 0.273199 + $cx * -0.0425644 ) ); | |||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||
| 1091 | |||||||||||||||||||||||||||||
| 1092 | sub bohman { | ||||||||||||||||||||||||||||
| 1093 | 7 | ▶ | PDL::Core::barf 'bohman: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
bohman: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1094 | 5 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1095 | 5 | my $x = abs( PDL::Core::zeroes($N)->xlinvals( -1, 1 ) ); | |||||||||||||||||||||||||||
| 1096 | 5 | ( 1 - $x ) * cos( PI * $x ) + ( 1 / PI ) * sin( PI * $x ); | |||||||||||||||||||||||||||
| 1097 | } | ||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||
| 1099 | sub bohman_per { | ||||||||||||||||||||||||||||
| 1100 | 4 | ▶ | PDL::Core::barf 'bohman: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
bohman_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1101 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1102 | 2 | my $x = abs( PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + 1 * ( $N - 1 ) ) / $N ) ); | |||||||||||||||||||||||||||
| 1103 | 2 | ( 1 - $x ) * cos( PI * $x ) + ( 1 / PI ) * sin( PI * $x ); | |||||||||||||||||||||||||||
| 1104 | } | ||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||
| 1106 | sub cauchy { | ||||||||||||||||||||||||||||
| 1107 | 6 | ▶ | PDL::Core::barf 'cauchy: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
cauchy: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1108 | 3 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 1109 | 3 | 1 / ( 1 + ( PDL::Core::zeroes($N)->xlinvals( -1, 1 ) * $alpha ) ** 2 ); | |||||||||||||||||||||||||||
| 1110 | } | ||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||
| 1112 | sub cauchy_per { | ||||||||||||||||||||||||||||
| 1113 | 5 | ▶ | PDL::Core::barf 'cauchy: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
cauchy_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1114 | 2 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 1115 | 2 | 1 / ( 1 + ( PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + 1 * ( $N - 1 ) ) / $N ) * $alpha ) ** 2 ); | |||||||||||||||||||||||||||
| 1116 | } | ||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||
| 1118 | sub chebyshev { | ||||||||||||||||||||||||||||
| 1119 | 8 | ▶ | PDL::Core::barf 'chebyshev: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
chebyshev: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1120 | 5 | my ( $N, $at ) = @_; | |||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||
| 1122 | 5 | my ( $M, $M1, $pos, $pos1 ); | |||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||
| 1124 | 5 | my $beta = PDL::Math::cosh( 1 / ( $N - 1 ) * PDL::Math::acosh( 1 / ( 10 ** ( -$at / 20 ) ) ) ); | |||||||||||||||||||||||||||
| 1125 | 5 | my $x = $beta * cos( PI * PDL::Basic::sequence($N) / $N ); | |||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||
| 1127 | 5 | my $cw = chebpoly( $N - 1, $x ); | |||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||
| 1129 | 5 | ▶ | if ( $N % 2 ) { # odd | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1130 | 1 | $M1 = ( $N + 1 ) / 2; | |||||||||||||||||||||||||||
| 1131 | 1 | $M = $M1 - 1; | |||||||||||||||||||||||||||
| 1132 | 1 | $pos = 0; | |||||||||||||||||||||||||||
| 1133 | 1 | $pos1 = 1; | |||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||
| 1135 | 1 | PDL::FFT::realfft($cw); | |||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||
| 1137 | else { # half-sample delay (even order) | ||||||||||||||||||||||||||||
| 1138 | 4 | my $arg = PI / $N * PDL::Basic::sequence($N); | |||||||||||||||||||||||||||
| 1139 | 4 | my $cw_im = $cw * sin($arg); | |||||||||||||||||||||||||||
| 1140 | 4 | $cw *= cos($arg); | |||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||
| 1142 | 4 | if (USE_FFTW_DIRECTION) { | |||||||||||||||||||||||||||
| 1143 | PDL::FFT::fftnd( $cw, $cw_im ); | ||||||||||||||||||||||||||||
| 1144 | } | ||||||||||||||||||||||||||||
| 1145 | else { | ||||||||||||||||||||||||||||
| 1146 | 4 | PDL::FFT::ifftnd( $cw, $cw_im ); | |||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||
| 1149 | 4 | $M1 = $N / 2; | |||||||||||||||||||||||||||
| 1150 | 4 | $M = $M1 - 1; | |||||||||||||||||||||||||||
| 1151 | 4 | $pos = 1; | |||||||||||||||||||||||||||
| 1152 | 4 | $pos1 = 0; | |||||||||||||||||||||||||||
| 1153 | } | ||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||
| 1155 | 5 | $cw /= $cw->at($pos); | |||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||
| 1157 | 5 | my $cwout = PDL::Core::zeroes($N); | |||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||
| 1159 | 5 | $cwout->slice("0:$M") .= $cw->slice("$M:0:-1"); | |||||||||||||||||||||||||||
| 1160 | 5 | $cwout->slice("$M1:-1") .= $cw->slice("$pos1:$M"); | |||||||||||||||||||||||||||
| 1161 | 5 | $cwout /= PDL::Ufunc::max($cwout); | |||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||
| 1163 | 5 | $cwout; | |||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||
| 1166 | sub cos_alpha { | ||||||||||||||||||||||||||||
| 1167 | 10 | ▶ | PDL::Core::barf 'cos_alpha: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
cos_alpha: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1168 | 7 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 1169 | 7 | ( sin( PDL::Core::zeroes($N)->xlinvals( 0, PI ) ) ) ** $alpha ; | |||||||||||||||||||||||||||
| 1170 | } | ||||||||||||||||||||||||||||
| 1171 | |||||||||||||||||||||||||||||
| 1172 | sub cos_alpha_per { | ||||||||||||||||||||||||||||
| 1173 | 6 | ▶ | PDL::Core::barf 'cos_alpha: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
cos_alpha_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1174 | 3 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 1175 | 3 | sin( PDL::Core::zeroes($N)->xlinvals( 0, PI * ( $N - 1 ) / $N ) ) ** $alpha ; | |||||||||||||||||||||||||||
| 1176 | } | ||||||||||||||||||||||||||||
| 1177 | |||||||||||||||||||||||||||||
| 1178 | sub cosine { | ||||||||||||||||||||||||||||
| 1179 | 6 | ▶ | PDL::Core::barf 'cosine: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
cosine: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1180 | 4 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1181 | 4 | sin( PDL::Core::zeroes($N)->xlinvals( 0, PI ) ); | |||||||||||||||||||||||||||
| 1182 | } | ||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||
| 1184 | sub cosine_per { | ||||||||||||||||||||||||||||
| 1185 | 4 | ▶ | PDL::Core::barf 'cosine: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
cosine_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1186 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1187 | 2 | sin( PDL::Core::zeroes($N)->xlinvals( 0, PI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1188 | } | ||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||
| 1190 | sub dpss { | ||||||||||||||||||||||||||||
| 1191 | 0 | ▶ | PDL::Core::barf 'dpss: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
dpss: not called CC=4 SCAR=30.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1192 | 0 | my ( $N, $beta ) = @_; | |||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||
| 1194 | 0 | PDL::Core::barf 'dpss: PDL::LinearAlgebra not installed.' unless HAVE_LinearAlgebra; | |||||||||||||||||||||||||||
| 1195 | 0 | ▶ | PDL::Core::barf "dpss: $beta not between 0 and $N." unless $beta >= 0 and $beta <= $N; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$beta >= 0 and $beta <= $N
MC/DC0%0/2
$beta >= 0 and $beta <= $N
$beta >= 0
$beta <= $N
Truth table0%0/3
A and B
A= $beta >= 0B= $beta <= $N
| |||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||
| 1197 | 0 | $beta /= $N / 2; | |||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||
| 1199 | 0 | my $k = PDL::Basic::sequence($N); | |||||||||||||||||||||||||||
| 1200 | 0 | my $s = sin( PI * $beta * $k ) / $k; | |||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||
| 1202 | 0 | $s->slice('0') .= $beta; | |||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||
| 1204 | 0 | my ( $ev, $e ) = PDL::MatrixOps::eigens_sym( PDL::LinearAlgebra::Special::mtoeplitz($s) ); | |||||||||||||||||||||||||||
| 1205 | 0 | my $i = $e->maximum_ind; | |||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||
| 1207 | 0 | $ev->slice("($i)")->copy; | |||||||||||||||||||||||||||
| 1208 | } | ||||||||||||||||||||||||||||
| 1209 | |||||||||||||||||||||||||||||
| 1210 | sub dpss_per { | ||||||||||||||||||||||||||||
| 1211 | 0 | ▶ | PDL::Core::barf 'dpss: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
dpss_per: not called CC=4 SCAR=30.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1212 | 0 | my ( $N, $beta ) = @_; | |||||||||||||||||||||||||||
| 1213 | 0 | $N++; | |||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||
| 1215 | 0 | PDL::Core::barf 'dpss: PDL::LinearAlgebra not installed.' unless HAVE_LinearAlgebra; | |||||||||||||||||||||||||||
| 1216 | 0 | ▶ | PDL::Core::barf "dpss: $beta not between 0 and $N." unless $beta >= 0 and $beta <= $N; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$beta >= 0 and $beta <= $N
MC/DC0%0/2
$beta >= 0 and $beta <= $N
$beta >= 0
$beta <= $N
Truth table0%0/3
A and B
A= $beta >= 0B= $beta <= $N
| |||||||||||||||||||||||||||||
| 1217 | |||||||||||||||||||||||||||||
| 1218 | 0 | $beta /= $N / 2; | |||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||
| 1220 | 0 | my $k = PDL::Basic::sequence($N); | |||||||||||||||||||||||||||
| 1221 | 0 | my $s = sin( PI * $beta * $k ) / $k; | |||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||
| 1223 | 0 | $s->slice('0') .= $beta; | |||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||
| 1225 | 0 | my ( $ev, $e ) = PDL::MatrixOps::eigens_sym( PDL::LinearAlgebra::Special::mtoeplitz($s) ); | |||||||||||||||||||||||||||
| 1226 | 0 | my $i = $e->maximum_ind; | |||||||||||||||||||||||||||
| 1227 | |||||||||||||||||||||||||||||
| 1228 | 0 | $ev->slice("($i),0:-2")->copy; | |||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||
| 1231 | sub exponential { | ||||||||||||||||||||||||||||
| 1232 | 4 | ▶ | PDL::Core::barf 'exponential: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
exponential: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1233 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1234 | 2 | 2 ** ( 1 - abs( PDL::Core::zeroes($N)->xlinvals( -1, 1 ) ) ) - 1; | |||||||||||||||||||||||||||
| 1235 | } | ||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||
| 1237 | sub exponential_per { | ||||||||||||||||||||||||||||
| 1238 | 4 | ▶ | PDL::Core::barf 'exponential: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
exponential_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1239 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1240 | 2 | 2 ** ( 1 - abs( PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + 1 * ( $N - 1 ) ) / $N ) ) ) - 1; | |||||||||||||||||||||||||||
| 1241 | } | ||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||
| 1243 | sub flattop { | ||||||||||||||||||||||||||||
| 1244 | 7 | ▶ | PDL::Core::barf 'flattop: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
flattop: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1245 | 5 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1246 | 5 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1247 | 5 | -0.05473684 + $cx * ( -0.165894739 + $cx * ( 0.498947372 + $cx * ( -0.334315788 + $cx * 0.055578944 ) ) ); | |||||||||||||||||||||||||||
| 1248 | } | ||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||
| 1250 | sub flattop_per { | ||||||||||||||||||||||||||||
| 1251 | 4 | ▶ | PDL::Core::barf 'flattop: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
flattop_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1252 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1253 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1254 | 2 | -0.05473684 + $cx * ( -0.165894739 + $cx * ( 0.498947372 + $cx * ( -0.334315788 + $cx * 0.055578944 ) ) ); | |||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||
| 1257 | sub gaussian { | ||||||||||||||||||||||||||||
| 1258 | 8 | ▶ | PDL::Core::barf 'gaussian: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
gaussian: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1259 | 5 | my ( $N, $beta ) = @_; | |||||||||||||||||||||||||||
| 1260 | 5 | exp( -0.5 * ( $beta * PDL::Core::zeroes($N)->xlinvals( -1, 1 ) ) ** 2); | |||||||||||||||||||||||||||
| 1261 | } | ||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||
| 1263 | sub gaussian_per { | ||||||||||||||||||||||||||||
| 1264 | 5 | ▶ | PDL::Core::barf 'gaussian: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
gaussian_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1265 | 2 | my ( $N, $beta ) = @_; | |||||||||||||||||||||||||||
| 1266 | 2 | exp( -0.5 * ( $beta * PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + 1 * ( $N - 1 ) ) / $N ) ) ** 2 ); | |||||||||||||||||||||||||||
| 1267 | } | ||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||
| 1269 | sub hamming { | ||||||||||||||||||||||||||||
| 1270 | 12 | ▶ | PDL::Core::barf 'hamming: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
hamming: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1271 | 10 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1272 | 10 | 0.54 + -0.46 * cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1273 | } | ||||||||||||||||||||||||||||
| 1274 | |||||||||||||||||||||||||||||
| 1275 | sub hamming_per { | ||||||||||||||||||||||||||||
| 1276 | 4 | ▶ | PDL::Core::barf 'hamming: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
hamming_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1277 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1278 | 2 | 0.54 + -0.46 * cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1279 | } | ||||||||||||||||||||||||||||
| 1280 | |||||||||||||||||||||||||||||
| 1281 | sub hamming_ex { | ||||||||||||||||||||||||||||
| 1282 | 4 | ▶ | PDL::Core::barf 'hamming_ex: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
hamming_ex: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1283 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1284 | 2 | 0.53836 + -0.46164 * cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1285 | } | ||||||||||||||||||||||||||||
| 1286 | |||||||||||||||||||||||||||||
| 1287 | sub hamming_ex_per { | ||||||||||||||||||||||||||||
| 1288 | 4 | ▶ | PDL::Core::barf 'hamming_ex: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
hamming_ex_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1289 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1290 | 2 | 0.53836 + -0.46164 * cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1291 | } | ||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||
| 1293 | sub hamming_gen { | ||||||||||||||||||||||||||||
| 1294 | 5 | ▶ | PDL::Core::barf 'hamming_gen: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
hamming_gen: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1295 | 2 | my ( $N, $a ) = @_; | |||||||||||||||||||||||||||
| 1296 | 2 | $a - ( 1 - $a ) * cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1297 | } | ||||||||||||||||||||||||||||
| 1298 | |||||||||||||||||||||||||||||
| 1299 | sub hamming_gen_per { | ||||||||||||||||||||||||||||
| 1300 | 5 | ▶ | PDL::Core::barf 'hamming_gen: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
hamming_gen_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1301 | 2 | my ( $N, $a ) = @_; | |||||||||||||||||||||||||||
| 1302 | 2 | $a - ( 1 - $a ) * cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1303 | } | ||||||||||||||||||||||||||||
| 1304 | |||||||||||||||||||||||||||||
| 1305 | sub hann { | ||||||||||||||||||||||||||||
| 1306 | 8 | ▶ | PDL::Core::barf 'hann: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
hann: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1307 | 6 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1308 | 6 | 0.5 + -0.5 * cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1309 | } | ||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||
| 1311 | sub hann_per { | ||||||||||||||||||||||||||||
| 1312 | 4 | ▶ | PDL::Core::barf 'hann: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
hann_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1313 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1314 | 2 | 0.5 + -0.5 * cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||
| 1317 | sub hann_matlab { | ||||||||||||||||||||||||||||
| 1318 | 3 | ▶ | PDL::Core::barf 'hann_matlab: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
hann_matlab: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1319 | 1 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1320 | 1 | 0.5 - 0.5 * cos( PDL::Core::zeroes($N)->xlinvals( TPI / ( $N + 1 ), TPI * $N / ( $N + 1 ) ) ); | |||||||||||||||||||||||||||
| 1321 | } | ||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||
| 1323 | sub hann_poisson { | ||||||||||||||||||||||||||||
| 1324 | 9 | ▶ | PDL::Core::barf 'hann_poisson: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
hann_poisson: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1325 | 6 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 1326 | 6 | 0.5 * ( 1 + cos( PDL::Core::zeroes($N)->xlinvals( - PI, PI ) ) ) | |||||||||||||||||||||||||||
| 1327 | * exp( -$alpha * abs( PDL::Core::zeroes($N)->xlinvals( -1, 1 ) ) ); | ||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||
| 1329 | } | ||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||
| 1331 | sub hann_poisson_per { | ||||||||||||||||||||||||||||
| 1332 | 5 | ▶ | PDL::Core::barf 'hann_poisson: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
hann_poisson_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1333 | 2 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 1334 | 2 | 0.5 * ( 1 + cos( PDL::Core::zeroes($N)->xlinvals( - PI, ( - PI + PI * ( $N - 1 ) ) / $N ) ) ) | |||||||||||||||||||||||||||
| 1335 | * exp( -$alpha * abs( PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + 1 * ( $N - 1 ) ) / $N ) ) ); | ||||||||||||||||||||||||||||
| 1336 | } | ||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||
| 1338 | sub kaiser { | ||||||||||||||||||||||||||||
| 1339 | 0 | ▶ | PDL::Core::barf 'kaiser: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
kaiser: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1340 | 0 | my ( $N, $beta ) = @_; | |||||||||||||||||||||||||||
| 1341 | |||||||||||||||||||||||||||||
| 1342 | 0 | PDL::Core::barf 'kaiser: PDL::GSLSF not installed' unless HAVE_BESSEL; | |||||||||||||||||||||||||||
| 1343 | |||||||||||||||||||||||||||||
| 1344 | 0 | $beta *= PI; | |||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||
| 1346 | 0 | my ($n) = PDL::GSLSF::BESSEL::gsl_sf_bessel_In( | |||||||||||||||||||||||||||
| 1347 | $beta * sqrt( 1 - PDL::Core::zeroes($N)->xlinvals( -1, 1 ) ** 2 ), 0 ); | ||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||
| 1349 | 0 | my ($d) = PDL::GSLSF::BESSEL::gsl_sf_bessel_In( $beta, 0 ); | |||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||
| 1351 | 0 | $n / $d; | |||||||||||||||||||||||||||
| 1352 | } | ||||||||||||||||||||||||||||
| 1353 | |||||||||||||||||||||||||||||
| 1354 | sub kaiser_per { | ||||||||||||||||||||||||||||
| 1355 | 0 | ▶ | PDL::Core::barf 'kaiser: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
kaiser_per: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1356 | 0 | my ($N,$beta) = @_; | |||||||||||||||||||||||||||
| 1357 | |||||||||||||||||||||||||||||
| 1358 | 0 | PDL::Core::barf 'kaiser: PDL::GSLSF not installed' unless HAVE_BESSEL; | |||||||||||||||||||||||||||
| 1359 | |||||||||||||||||||||||||||||
| 1360 | 0 | $beta *= PI; | |||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||
| 1362 | 0 | my ($n) = PDL::GSLSF::BESSEL::gsl_sf_bessel_In( | |||||||||||||||||||||||||||
| 1363 | $beta * sqrt( 1 - PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + 1 * ( $N - 1 ) ) / $N ) ** 2 ), 0); | ||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||
| 1365 | 0 | my ($d) = PDL::GSLSF::BESSEL::gsl_sf_bessel_In( $beta, 0 ); | |||||||||||||||||||||||||||
| 1366 | |||||||||||||||||||||||||||||
| 1367 | 0 | $n / $d; | |||||||||||||||||||||||||||
| 1368 | } | ||||||||||||||||||||||||||||
| 1369 | |||||||||||||||||||||||||||||
| 1370 | sub lanczos { | ||||||||||||||||||||||||||||
| 1371 | 6 | ▶ | PDL::Core::barf 'lanczos: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
lanczos: called CC=3 SCAR=11.0
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1372 | 4 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||
| 1374 | 4 | my $x = PI * PDL::Core::zeroes($N)->xlinvals( -1, 1 ); | |||||||||||||||||||||||||||
| 1375 | 4 | my $res = sin($x) / $x; | |||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||
| 1377 | 4 | ▶ | $res->slice( int( $N / 2 ) ) .= 1 if $N % 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||
| 1379 | 4 | $res; | |||||||||||||||||||||||||||
| 1380 | } | ||||||||||||||||||||||||||||
| 1381 | |||||||||||||||||||||||||||||
| 1382 | sub lanczos_per { | ||||||||||||||||||||||||||||
| 1383 | 4 | ▶ | PDL::Core::barf 'lanczos: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
lanczos_per: called CC=3 SCAR=11.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1384 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||
| 1386 | 2 | my $x = PI * PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + 1 * ( $N - 1 ) ) / $N ); | |||||||||||||||||||||||||||
| 1387 | 2 | my $res = sin($x) / $x; | |||||||||||||||||||||||||||
| 1388 | |||||||||||||||||||||||||||||
| 1389 | 2 | ▶ | $res->slice( int( $N / 2 ) ) .= 1 unless $N % 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1390 | |||||||||||||||||||||||||||||
| 1391 | 2 | $res; | |||||||||||||||||||||||||||
| 1392 | } | ||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||
| 1394 | sub nuttall { | ||||||||||||||||||||||||||||
| 1395 | 5 | ▶ | PDL::Core::barf 'nuttall: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
nuttall: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1396 | 3 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1397 | 3 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI ) ); | |||||||||||||||||||||||||||
| 1398 | 3 | 0.2269824 + $cx * ( -0.4572542 + $cx * ( 0.273199 + $cx * -0.0425644 ) ); | |||||||||||||||||||||||||||
| 1399 | } | ||||||||||||||||||||||||||||
| 1400 | |||||||||||||||||||||||||||||
| 1401 | sub nuttall_per { | ||||||||||||||||||||||||||||
| 1402 | 4 | ▶ | PDL::Core::barf 'nuttall: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
nuttall_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1403 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1404 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1405 | 2 | 0.2269824 + $cx * ( -0.4572542 + $cx * ( 0.273199 + $cx * -0.0425644 ) ); | |||||||||||||||||||||||||||
| 1406 | } | ||||||||||||||||||||||||||||
| 1407 | |||||||||||||||||||||||||||||
| 1408 | sub nuttall1 { | ||||||||||||||||||||||||||||
| 1409 | 4 | ▶ | PDL::Core::barf 'nuttall1: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
nuttall1: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1410 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1411 | 2 | my $cx = (cos(PDL::Core::zeroes($N)->xlinvals(0,TPI))); | |||||||||||||||||||||||||||
| 1412 | |||||||||||||||||||||||||||||
| 1413 | 2 | (0.211536) + ($cx * ((-0.449584) + ($cx * (0.288464 + $cx * (-0.050416) )))); | |||||||||||||||||||||||||||
| 1414 | } | ||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||
| 1416 | sub nuttall1_per { | ||||||||||||||||||||||||||||
| 1417 | 4 | ▶ | PDL::Core::barf 'nuttall1: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
nuttall1_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1418 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1419 | 2 | my $cx = cos( PDL::Core::zeroes($N)->xlinvals( 0, TPI * ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1420 | 2 | 0.211536 + $cx * ( -0.449584 + $cx * ( 0.288464 + $cx * -0.050416 ) ); | |||||||||||||||||||||||||||
| 1421 | } | ||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||
| 1423 | sub parzen { | ||||||||||||||||||||||||||||
| 1424 | 7 | ▶ | PDL::Core::barf 'parzen: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
parzen: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1425 | 5 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1426 | |||||||||||||||||||||||||||||
| 1427 | 5 | my $x = PDL::Core::zeroes($N)->xlinvals( -1, 1 ); | |||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||
| 1429 | 5 | my $x1 = $x->where( $x <= -0.5 ); | |||||||||||||||||||||||||||
| 1430 | 5 | my $x2 = $x->where( ( $x < 0.5 ) & ( $x > -0.5 ) ); | |||||||||||||||||||||||||||
| 1431 | 5 | my $x3 = $x->where( $x >= 0.5 ); | |||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||
| 1433 | 5 | $x1 .= 2 * ( 1 - abs($x1) ) ** 3; | |||||||||||||||||||||||||||
| 1434 | 5 | $x2 .= 1 - 6 * $x2 ** 2 * ( 1 - abs($x2) ); | |||||||||||||||||||||||||||
| 1435 | 5 | $x3 .= $x1->slice('-1:0:-1'); | |||||||||||||||||||||||||||
| 1436 | |||||||||||||||||||||||||||||
| 1437 | 5 | $x; | |||||||||||||||||||||||||||
| 1438 | } | ||||||||||||||||||||||||||||
| 1439 | |||||||||||||||||||||||||||||
| 1440 | sub parzen_per { | ||||||||||||||||||||||||||||
| 1441 | 4 | ▶ | PDL::Core::barf 'parzen: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
parzen_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1442 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1443 | |||||||||||||||||||||||||||||
| 1444 | 2 | my $x = PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + ( $N - 1 ) ) / $N); | |||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||
| 1446 | 2 | my $x1 = $x->where( $x <= -0.5 ); | |||||||||||||||||||||||||||
| 1447 | 2 | my $x2 = $x->where( ( $x < 0.5 ) & ( $x > -0.5 ) ); | |||||||||||||||||||||||||||
| 1448 | 2 | my $x3 = $x->where( $x >= 0.5 ); | |||||||||||||||||||||||||||
| 1449 | |||||||||||||||||||||||||||||
| 1450 | 2 | $x1 .= 2 * ( 1 - abs($x1)) ** 3; | |||||||||||||||||||||||||||
| 1451 | 2 | $x2 .= 1 - 6 * $x2 ** 2 * ( 1 - abs($x2) ); | |||||||||||||||||||||||||||
| 1452 | 2 | $x3 .= $x1->slice('-1:1:-1'); | |||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||
| 1454 | 2 | $x; | |||||||||||||||||||||||||||
| 1455 | } | ||||||||||||||||||||||||||||
| 1456 | |||||||||||||||||||||||||||||
| 1457 | sub parzen_octave { | ||||||||||||||||||||||||||||
| 1458 | 4 | ▶ | PDL::Core::barf 'parzen_octave: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
parzen_octave: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1459 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||
| 1461 | 2 | my $r = ( $N - 1 ) / 2; | |||||||||||||||||||||||||||
| 1462 | 2 | my $N2 = $N / 2; | |||||||||||||||||||||||||||
| 1463 | 2 | my $r4 = $r / 2; | |||||||||||||||||||||||||||
| 1464 | 2 | my $n = PDL::Basic::sequence( 2 * $r + 1 ) - $r; | |||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||
| 1466 | 2 | my $n1 = $n->where( abs($n) <= $r4 ); | |||||||||||||||||||||||||||
| 1467 | 2 | my $n2 = $n->where( $n > $r4 ); | |||||||||||||||||||||||||||
| 1468 | 2 | my $n3 = $n->where( $n < -$r4 ); | |||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||
| 1470 | 2 | $n1 .= 1 - 6 * ( abs($n1) / $N2 ) ** 2 + 6 * ( abs($n1) / $N2 ) ** 3; | |||||||||||||||||||||||||||
| 1471 | 2 | $n2 .= 2 * ( 1 - abs($n2) / $N2 ) ** 3; | |||||||||||||||||||||||||||
| 1472 | 2 | $n3 .= 2 * ( 1 - abs($n3) / $N2 ) ** 3; | |||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||
| 1474 | 2 | $n; | |||||||||||||||||||||||||||
| 1475 | } | ||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||
| 1477 | sub poisson { | ||||||||||||||||||||||||||||
| 1478 | 9 | ▶ | PDL::Core::barf 'poisson: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
poisson: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1479 | 6 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 1480 | 6 | exp( -$alpha * abs( PDL::Core::zeroes($N)->xlinvals( -1, 1 ) ) ); | |||||||||||||||||||||||||||
| 1481 | } | ||||||||||||||||||||||||||||
| 1482 | |||||||||||||||||||||||||||||
| 1483 | sub poisson_per { | ||||||||||||||||||||||||||||
| 1484 | 5 | ▶ | PDL::Core::barf 'poisson: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
poisson_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1485 | 2 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 1486 | 2 | exp( -$alpha * abs( PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + 1 * ( $N - 1 ) ) / $N ) ) ); | |||||||||||||||||||||||||||
| 1487 | } | ||||||||||||||||||||||||||||
| 1488 | |||||||||||||||||||||||||||||
| 1489 | sub rectangular { | ||||||||||||||||||||||||||||
| 1490 | 7 | ▶ | PDL::Core::barf 'rectangular: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
rectangular: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1491 | 5 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1492 | 5 | PDL::Core::ones($N); | |||||||||||||||||||||||||||
| 1493 | } | ||||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||
| 1495 | sub rectangular_per { | ||||||||||||||||||||||||||||
| 1496 | 4 | ▶ | PDL::Core::barf 'rectangular: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
rectangular_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1497 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1498 | 2 | PDL::Core::ones($N); | |||||||||||||||||||||||||||
| 1499 | } | ||||||||||||||||||||||||||||
| 1500 | |||||||||||||||||||||||||||||
| 1501 | sub triangular { | ||||||||||||||||||||||||||||
| 1502 | 7 | ▶ | PDL::Core::barf 'triangular: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
triangular: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1503 | 5 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1504 | 5 | 1 - abs( PDL::Core::zeroes($N)->xlinvals( -( $N - 1 ) / $N, ( $N - 1 ) / $N ) ); | |||||||||||||||||||||||||||
| 1505 | } | ||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||
| 1507 | sub triangular_per { | ||||||||||||||||||||||||||||
| 1508 | 4 | ▶ | PDL::Core::barf 'triangular: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
triangular_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1509 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1510 | 2 | 1 - abs( PDL::Core::zeroes($N)->xlinvals( -$N / ( $N + 1 ), -1 / ( $N + 1 ) + ( $N - 1 ) / ( $N + 1 ) ) ); | |||||||||||||||||||||||||||
| 1511 | } | ||||||||||||||||||||||||||||
| 1512 | |||||||||||||||||||||||||||||
| 1513 | sub tukey { | ||||||||||||||||||||||||||||
| 1514 | 18 | ▶ | PDL::Core::barf 'tukey: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
tukey: called CC=5 SCAR=16.1
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1515 | 15 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||
| 1517 | 15 | ▶ | PDL::Core::barf('tukey: alpha must be between 0 and 1') unless $alpha >= 0 and $alpha <= 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$alpha >= 0 and $alpha <= 1
MC/DC100%2/2
$alpha >= 0 and $alpha <= 1
$alpha >= 0
$alpha <= 1
Truth table100%3/3
A and B
A= $alpha >= 0B= $alpha <= 1
| |||||||||||||||||||||||||||||
| 1518 | |||||||||||||||||||||||||||||
| 1519 | 13 | ▶ | return PDL::Core::ones($N) if $alpha == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1520 | |||||||||||||||||||||||||||||
| 1521 | 13 | my $x = PDL::Core::zeroes($N)->xlinvals( 0, 1 ); | |||||||||||||||||||||||||||
| 1522 | |||||||||||||||||||||||||||||
| 1523 | 13 | my $x1 = $x->where( $x < $alpha / 2 ); | |||||||||||||||||||||||||||
| 1524 | 13 | my $x2 = $x->where( ( $x <= 1 - $alpha / 2 ) & ( $x >= $alpha / 2 ) ); | |||||||||||||||||||||||||||
| 1525 | 13 | my $x3 = $x->where( $x > 1 - $alpha / 2 ); | |||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||
| 1527 | 13 | $x1 .= 0.5 * ( 1 + cos( PI * ( 2 * $x1 / $alpha - 1 ) ) ); | |||||||||||||||||||||||||||
| 1528 | 13 | $x2 .= 1; | |||||||||||||||||||||||||||
| 1529 | 13 | $x3 .= $x1->slice('-1:0:-1'); | |||||||||||||||||||||||||||
| 1530 | |||||||||||||||||||||||||||||
| 1531 | 13 | return $x; | |||||||||||||||||||||||||||
| 1532 | } | ||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||
| 1534 | sub tukey_per { | ||||||||||||||||||||||||||||
| 1535 | 12 | ▶ | PDL::Core::barf 'tukey: 2 arguments expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
tukey_per: called CC=5 SCAR=16.1
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1536 | 9 | my ( $N, $alpha ) = @_; | |||||||||||||||||||||||||||
| 1537 | |||||||||||||||||||||||||||||
| 1538 | 9 | ▶ | PDL::Core::barf 'tukey: alpha must be between 0 and 1' unless $alpha >= 0 && $alpha <= 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$alpha >= 0 and $alpha <= 1
MC/DC100%2/2
$alpha >= 0 and $alpha <= 1
$alpha >= 0
$alpha <= 1
Truth table100%3/3
A and B
A= $alpha >= 0B= $alpha <= 1
| |||||||||||||||||||||||||||||
| 1539 | |||||||||||||||||||||||||||||
| 1540 | 7 | ▶ | return PDL::Core::ones($N) if $alpha == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||
| 1542 | 7 | my $x = PDL::Core::zeroes($N)->xlinvals( 0, ( $N - 1 ) / $N ); | |||||||||||||||||||||||||||
| 1543 | |||||||||||||||||||||||||||||
| 1544 | 7 | my $x1 = $x->where( $x < $alpha / 2 ); | |||||||||||||||||||||||||||
| 1545 | 7 | my $x2 = $x->where( ( $x <= 1 - $alpha / 2 ) & ( $x >= $alpha / 2 ) ); | |||||||||||||||||||||||||||
| 1546 | 7 | my $x3 = $x->where( $x > 1 - $alpha / 2 ); | |||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||
| 1548 | 7 | $x1 .= 0.5 * ( 1 + cos( PI * ( 2 * $x1 / $alpha - 1 ) ) ); | |||||||||||||||||||||||||||
| 1549 | 7 | $x2 .= 1; | |||||||||||||||||||||||||||
| 1550 | 7 | $x3 .= $x1->slice('-1:1:-1'); | |||||||||||||||||||||||||||
| 1551 | |||||||||||||||||||||||||||||
| 1552 | 7 | return $x; | |||||||||||||||||||||||||||
| 1553 | } | ||||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||
| 1555 | sub welch { | ||||||||||||||||||||||||||||
| 1556 | 6 | ▶ | PDL::Core::barf 'welch: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
welch: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1557 | 4 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1558 | 4 | 1 - PDL::Core::zeroes($N)->xlinvals( -1, 1 ) ** 2; | |||||||||||||||||||||||||||
| 1559 | } | ||||||||||||||||||||||||||||
| 1560 | |||||||||||||||||||||||||||||
| 1561 | sub welch_per { | ||||||||||||||||||||||||||||
| 1562 | 4 | ▶ | PDL::Core::barf 'welch: 1 argument expected. Got ' . scalar(@_) . ' arguments.' unless @_ == 1; | ||||||||||||||||||||||||||
|
Subroutine
welch_per: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1563 | 2 | my ($N) = @_; | |||||||||||||||||||||||||||
| 1564 | 2 | 1 - PDL::Core::zeroes($N)->xlinvals( -1, ( -1 + 1 * ( $N - 1 ) ) / $N ) ** 2; | |||||||||||||||||||||||||||
| 1565 | } | ||||||||||||||||||||||||||||
| 1566 | |||||||||||||||||||||||||||||
| 1567 | =head1 Symmetric window functions | ||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||
| 1569 | =head2 bartlett($N) | ||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||
| 1571 | The Bartlett window. (Ref 1). Another name for this window is the fejer window. | ||||||||||||||||||||||||||||
| 1572 | This window is defined by | ||||||||||||||||||||||||||||
| 1573 | |||||||||||||||||||||||||||||
| 1574 | 1 - abs(arr) | ||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||
| 1576 | where the points in arr range from -1 through 1. See also | ||||||||||||||||||||||||||||
| 1577 | L<triangular|/triangular($N)>. | ||||||||||||||||||||||||||||
| 1578 | |||||||||||||||||||||||||||||
| 1579 | =head2 bartlett_hann($N) | ||||||||||||||||||||||||||||
| 1580 | |||||||||||||||||||||||||||||
| 1581 | The Bartlett-Hann window. Another name for this window is the Modified | ||||||||||||||||||||||||||||
| 1582 | Bartlett-Hann window. This window is defined by | ||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||
| 1584 | 0.62 - 0.48 * abs(arr) + 0.38 * arr1 | ||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||
| 1586 | where the points in arr range from -1/2 through 1/2, and arr1 are the cos of | ||||||||||||||||||||||||||||
| 1587 | points ranging from -PI through PI. | ||||||||||||||||||||||||||||
| 1588 | |||||||||||||||||||||||||||||
| 1589 | =head2 blackman($N) | ||||||||||||||||||||||||||||
| 1590 | |||||||||||||||||||||||||||||
| 1591 | The 'classic' Blackman window. (Ref 1). One of the Blackman-Harris family, with coefficients | ||||||||||||||||||||||||||||
| 1592 | |||||||||||||||||||||||||||||
| 1593 | a0 = 0.42 | ||||||||||||||||||||||||||||
| 1594 | a1 = 0.5 | ||||||||||||||||||||||||||||
| 1595 | a2 = 0.08 | ||||||||||||||||||||||||||||
| 1596 | |||||||||||||||||||||||||||||
| 1597 | =head2 blackman_bnh($N) | ||||||||||||||||||||||||||||
| 1598 | |||||||||||||||||||||||||||||
| 1599 | The Blackman-Harris (bnh) window. An improved version of the 3-term | ||||||||||||||||||||||||||||
| 1600 | Blackman-Harris window given by Nuttall (Ref 2, p. 89). One of the | ||||||||||||||||||||||||||||
| 1601 | Blackman-Harris family, with coefficients | ||||||||||||||||||||||||||||
| 1602 | |||||||||||||||||||||||||||||
| 1603 | a0 = 0.4243801 | ||||||||||||||||||||||||||||
| 1604 | a1 = 0.4973406 | ||||||||||||||||||||||||||||
| 1605 | a2 = 0.0782793 | ||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||
| 1607 | =head2 blackman_ex($N) | ||||||||||||||||||||||||||||
| 1608 | |||||||||||||||||||||||||||||
| 1609 | The 'exact' Blackman window. (Ref 1). One of the Blackman-Harris family, with | ||||||||||||||||||||||||||||
| 1610 | coefficients | ||||||||||||||||||||||||||||
| 1611 | |||||||||||||||||||||||||||||
| 1612 | a0 = 0.426590713671539 | ||||||||||||||||||||||||||||
| 1613 | a1 = 0.496560619088564 | ||||||||||||||||||||||||||||
| 1614 | a2 = 0.0768486672398968 | ||||||||||||||||||||||||||||
| 1615 | |||||||||||||||||||||||||||||
| 1616 | =head2 blackman_gen($N,$alpha) | ||||||||||||||||||||||||||||
| 1617 | |||||||||||||||||||||||||||||
| 1618 | The General classic Blackman window. A single parameter family of the 3-term | ||||||||||||||||||||||||||||
| 1619 | Blackman window. This window is defined by | ||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||
| 1621 | my $cx = arr; | ||||||||||||||||||||||||||||
| 1622 | .5 - $alpha + ($cx * (-.5 + $cx * $alpha)); | ||||||||||||||||||||||||||||
| 1623 | |||||||||||||||||||||||||||||
| 1624 | where the points in arr are the cos of points ranging from 0 through 2PI. | ||||||||||||||||||||||||||||
| 1625 | |||||||||||||||||||||||||||||
| 1626 | =head2 blackman_gen3($N,$a0,$a1,$a2) | ||||||||||||||||||||||||||||
| 1627 | |||||||||||||||||||||||||||||
| 1628 | The general form of the Blackman family. One of the Blackman-Harris family, | ||||||||||||||||||||||||||||
| 1629 | with coefficients | ||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||
| 1631 | a0 = $a0 | ||||||||||||||||||||||||||||
| 1632 | a1 = $a1 | ||||||||||||||||||||||||||||
| 1633 | a2 = $a2 | ||||||||||||||||||||||||||||
| 1634 | |||||||||||||||||||||||||||||
| 1635 | =head2 blackman_gen4($N,$a0,$a1,$a2,$a3) | ||||||||||||||||||||||||||||
| 1636 | |||||||||||||||||||||||||||||
| 1637 | The general 4-term Blackman-Harris window. One of the Blackman-Harris family, | ||||||||||||||||||||||||||||
| 1638 | with coefficients | ||||||||||||||||||||||||||||
| 1639 | |||||||||||||||||||||||||||||
| 1640 | a0 = $a0 | ||||||||||||||||||||||||||||
| 1641 | a1 = $a1 | ||||||||||||||||||||||||||||
| 1642 | a2 = $a2 | ||||||||||||||||||||||||||||
| 1643 | a3 = $a3 | ||||||||||||||||||||||||||||
| 1644 | |||||||||||||||||||||||||||||
| 1645 | =head2 blackman_gen5($N,$a0,$a1,$a2,$a3,$a4) | ||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||
| 1647 | The general 5-term Blackman-Harris window. One of the Blackman-Harris family, | ||||||||||||||||||||||||||||
| 1648 | with coefficients | ||||||||||||||||||||||||||||
| 1649 | |||||||||||||||||||||||||||||
| 1650 | a0 = $a0 | ||||||||||||||||||||||||||||
| 1651 | a1 = $a1 | ||||||||||||||||||||||||||||
| 1652 | a2 = $a2 | ||||||||||||||||||||||||||||
| 1653 | a3 = $a3 | ||||||||||||||||||||||||||||
| 1654 | a4 = $a4 | ||||||||||||||||||||||||||||
| 1655 | |||||||||||||||||||||||||||||
| 1656 | =head2 blackman_harris($N) | ||||||||||||||||||||||||||||
| 1657 | |||||||||||||||||||||||||||||
| 1658 | The Blackman-Harris window. (Ref 1). One of the Blackman-Harris family, with | ||||||||||||||||||||||||||||
| 1659 | coefficients | ||||||||||||||||||||||||||||
| 1660 | |||||||||||||||||||||||||||||
| 1661 | a0 = 0.422323 | ||||||||||||||||||||||||||||
| 1662 | a1 = 0.49755 | ||||||||||||||||||||||||||||
| 1663 | a2 = 0.07922 | ||||||||||||||||||||||||||||
| 1664 | |||||||||||||||||||||||||||||
| 1665 | Another name for this window is the Minimum three term (sample) Blackman-Harris | ||||||||||||||||||||||||||||
| 1666 | window. | ||||||||||||||||||||||||||||
| 1667 | |||||||||||||||||||||||||||||
| 1668 | =head2 blackman_harris4($N) | ||||||||||||||||||||||||||||
| 1669 | |||||||||||||||||||||||||||||
| 1670 | The minimum (sidelobe) four term Blackman-Harris window. (Ref 1). One of the | ||||||||||||||||||||||||||||
| 1671 | Blackman-Harris family, with coefficients | ||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||
| 1673 | a0 = 0.35875 | ||||||||||||||||||||||||||||
| 1674 | a1 = 0.48829 | ||||||||||||||||||||||||||||
| 1675 | a2 = 0.14128a3 = 0.01168 | ||||||||||||||||||||||||||||
| 1676 | |||||||||||||||||||||||||||||
| 1677 | Another name for this window is the Blackman-Harris window. | ||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||
| 1679 | =head2 blackman_nuttall($N) | ||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||
| 1681 | The Blackman-Nuttall window. One of the Blackman-Harris family, with | ||||||||||||||||||||||||||||
| 1682 | coefficients | ||||||||||||||||||||||||||||
| 1683 | |||||||||||||||||||||||||||||
| 1684 | a0 = 0.3635819 | ||||||||||||||||||||||||||||
| 1685 | a1 = 0.4891775 | ||||||||||||||||||||||||||||
| 1686 | a2 = 0.1365995 | ||||||||||||||||||||||||||||
| 1687 | a3 = 0.0106411 | ||||||||||||||||||||||||||||
| 1688 | |||||||||||||||||||||||||||||
| 1689 | =head2 bohman($N) | ||||||||||||||||||||||||||||
| 1690 | |||||||||||||||||||||||||||||
| 1691 | The Bohman window. (Ref 1). This window is defined by | ||||||||||||||||||||||||||||
| 1692 | |||||||||||||||||||||||||||||
| 1693 | my $x = abs(arr); | ||||||||||||||||||||||||||||
| 1694 | (1 - $x) * cos(PI * $x) + (1 / PI) * sin(PI * $x) | ||||||||||||||||||||||||||||
| 1695 | |||||||||||||||||||||||||||||
| 1696 | where the points in arr range from -1 through 1. | ||||||||||||||||||||||||||||
| 1697 | |||||||||||||||||||||||||||||
| 1698 | =head2 cauchy($N,$alpha) | ||||||||||||||||||||||||||||
| 1699 | |||||||||||||||||||||||||||||
| 1700 | The Cauchy window. (Ref 1). Other names for this window are: Abel, Poisson. | ||||||||||||||||||||||||||||
| 1701 | This window is defined by | ||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||
| 1703 | 1 / (1 + (arr * $alpha) ** 2) | ||||||||||||||||||||||||||||
| 1704 | |||||||||||||||||||||||||||||
| 1705 | where the points in arr range from -1 through 1. | ||||||||||||||||||||||||||||
| 1706 | |||||||||||||||||||||||||||||
| 1707 | =head2 chebyshev($N,$at) | ||||||||||||||||||||||||||||
| 1708 | |||||||||||||||||||||||||||||
| 1709 | The Chebyshev window. The frequency response of this window has C<$at> dB of | ||||||||||||||||||||||||||||
| 1710 | attenuation in the stop-band. Another name for this window is the | ||||||||||||||||||||||||||||
| 1711 | Dolph-Chebyshev window. No periodic version of this window is defined. This | ||||||||||||||||||||||||||||
| 1712 | routine gives the same result as the routine B<chebwin> in Octave 3.6.2. | ||||||||||||||||||||||||||||
| 1713 | |||||||||||||||||||||||||||||
| 1714 | =head2 cos_alpha($N,$alpha) | ||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||
| 1716 | The Cos_alpha window. (Ref 1). Another name for this window is the | ||||||||||||||||||||||||||||
| 1717 | Power-of-cosine window. This window is defined by | ||||||||||||||||||||||||||||
| 1718 | |||||||||||||||||||||||||||||
| 1719 | arr ** $alpha | ||||||||||||||||||||||||||||
| 1720 | |||||||||||||||||||||||||||||
| 1721 | where the points in arr are the sin of points ranging from 0 through PI. | ||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||
| 1723 | =head2 cosine($N) | ||||||||||||||||||||||||||||
| 1724 | |||||||||||||||||||||||||||||
| 1725 | The Cosine window. Another name for this window is the sine window. This | ||||||||||||||||||||||||||||
| 1726 | window is defined by | ||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||
| 1728 | arr | ||||||||||||||||||||||||||||
| 1729 | |||||||||||||||||||||||||||||
| 1730 | where the points in arr are the sin of points ranging from 0 through PI. | ||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||
| 1732 | =head2 dpss($N,$beta) | ||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||
| 1734 | The Digital Prolate Spheroidal Sequence (DPSS) window. The parameter C<$beta> | ||||||||||||||||||||||||||||
| 1735 | is the half-width of the mainlobe, measured in frequency bins. This window | ||||||||||||||||||||||||||||
| 1736 | maximizes the power in the mainlobe for given C<$N> and C<$beta>. Another | ||||||||||||||||||||||||||||
| 1737 | name for this window is the sleppian window. | ||||||||||||||||||||||||||||
| 1738 | |||||||||||||||||||||||||||||
| 1739 | =head2 exponential($N) | ||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||
| 1741 | The Exponential window. This window is defined by | ||||||||||||||||||||||||||||
| 1742 | |||||||||||||||||||||||||||||
| 1743 | 2 ** (1 - abs arr) - 1 | ||||||||||||||||||||||||||||
| 1744 | |||||||||||||||||||||||||||||
| 1745 | where the points in arr range from -1 through 1. | ||||||||||||||||||||||||||||
| 1746 | |||||||||||||||||||||||||||||
| 1747 | =head2 flattop($N) | ||||||||||||||||||||||||||||
| 1748 | |||||||||||||||||||||||||||||
| 1749 | The flat top window. One of the Blackman-Harris family, with coefficients | ||||||||||||||||||||||||||||
| 1750 | |||||||||||||||||||||||||||||
| 1751 | a0 = 0.21557895 | ||||||||||||||||||||||||||||
| 1752 | a1 = 0.41663158 | ||||||||||||||||||||||||||||
| 1753 | a2 = 0.277263158 | ||||||||||||||||||||||||||||
| 1754 | a3 = 0.083578947 | ||||||||||||||||||||||||||||
| 1755 | a4 = 0.006947368 | ||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||
| 1757 | =head2 gaussian($N,$beta) | ||||||||||||||||||||||||||||
| 1758 | |||||||||||||||||||||||||||||
| 1759 | The Gaussian window. (Ref 1). Another name for this window is the Weierstrass | ||||||||||||||||||||||||||||
| 1760 | window. This window is defined by | ||||||||||||||||||||||||||||
| 1761 | |||||||||||||||||||||||||||||
| 1762 | exp (-0.5 * ($beta * arr )**2), | ||||||||||||||||||||||||||||
| 1763 | |||||||||||||||||||||||||||||
| 1764 | where the points in arr range from -1 through 1. | ||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||
| 1766 | =head2 hamming($N) | ||||||||||||||||||||||||||||
| 1767 | |||||||||||||||||||||||||||||
| 1768 | The Hamming window. (Ref 1). One of the Blackman-Harris family, with | ||||||||||||||||||||||||||||
| 1769 | coefficients | ||||||||||||||||||||||||||||
| 1770 | |||||||||||||||||||||||||||||
| 1771 | a0 = 0.54 | ||||||||||||||||||||||||||||
| 1772 | a1 = 0.46 | ||||||||||||||||||||||||||||
| 1773 | |||||||||||||||||||||||||||||
| 1774 | =head2 hamming_ex($N) | ||||||||||||||||||||||||||||
| 1775 | |||||||||||||||||||||||||||||
| 1776 | The 'exact' Hamming window. (Ref 1). One of the Blackman-Harris family, with | ||||||||||||||||||||||||||||
| 1777 | coefficients | ||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||
| 1779 | a0 = 0.53836 | ||||||||||||||||||||||||||||
| 1780 | a1 = 0.46164 | ||||||||||||||||||||||||||||
| 1781 | |||||||||||||||||||||||||||||
| 1782 | =head2 hamming_gen($N,$a) | ||||||||||||||||||||||||||||
| 1783 | |||||||||||||||||||||||||||||
| 1784 | The general Hamming window. (Ref 1). One of the Blackman-Harris family, with | ||||||||||||||||||||||||||||
| 1785 | coefficients | ||||||||||||||||||||||||||||
| 1786 | |||||||||||||||||||||||||||||
| 1787 | a0 = $a | ||||||||||||||||||||||||||||
| 1788 | a1 = (1-$a) | ||||||||||||||||||||||||||||
| 1789 | |||||||||||||||||||||||||||||
| 1790 | =head2 hann($N) | ||||||||||||||||||||||||||||
| 1791 | |||||||||||||||||||||||||||||
| 1792 | The Hann window. (Ref 1). One of the Blackman-Harris family, with coefficients | ||||||||||||||||||||||||||||
| 1793 | |||||||||||||||||||||||||||||
| 1794 | a0 = 0.5 | ||||||||||||||||||||||||||||
| 1795 | a1 = 0.5 | ||||||||||||||||||||||||||||
| 1796 | |||||||||||||||||||||||||||||
| 1797 | Another name for this window is the hanning window. See also | ||||||||||||||||||||||||||||
| 1798 | L<hann_matlab|/hann_matlab($N)>. | ||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||
| 1800 | =head2 hann_matlab($N) | ||||||||||||||||||||||||||||
| 1801 | |||||||||||||||||||||||||||||
| 1802 | The Hann (matlab) window. Equivalent to the Hann window of N+2 points, with the | ||||||||||||||||||||||||||||
| 1803 | endpoints (which are both zero) removed. No periodic version of this window is | ||||||||||||||||||||||||||||
| 1804 | defined. This window is defined by | ||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||
| 1806 | 0.5 - 0.5 * arr | ||||||||||||||||||||||||||||
| 1807 | |||||||||||||||||||||||||||||
| 1808 | where the points in arr are the cosine of points ranging from 2PI/($N+1) | ||||||||||||||||||||||||||||
| 1809 | through 2PI*$N/($N+1). This routine gives the same result as the routine | ||||||||||||||||||||||||||||
| 1810 | B<hanning> in Matlab. See also L<hann|/hann($N)>. | ||||||||||||||||||||||||||||
| 1811 | |||||||||||||||||||||||||||||
| 1812 | =head2 hann_poisson($N,$alpha) | ||||||||||||||||||||||||||||
| 1813 | |||||||||||||||||||||||||||||
| 1814 | The Hann-Poisson window. (Ref 1). This window is defined by | ||||||||||||||||||||||||||||
| 1815 | |||||||||||||||||||||||||||||
| 1816 | 0.5 * (1 + arr1) * exp (-$alpha * abs arr) | ||||||||||||||||||||||||||||
| 1817 | |||||||||||||||||||||||||||||
| 1818 | where the points in arr range from -1 through 1, and arr1 are the cos of points | ||||||||||||||||||||||||||||
| 1819 | ranging from -PI through PI. | ||||||||||||||||||||||||||||
| 1820 | |||||||||||||||||||||||||||||
| 1821 | =head2 kaiser($N,$beta) | ||||||||||||||||||||||||||||
| 1822 | |||||||||||||||||||||||||||||
| 1823 | The Kaiser window. (Ref 1). The parameter C<$beta> is the approximate | ||||||||||||||||||||||||||||
| 1824 | half-width of the mainlobe, measured in frequency bins. Another name for this | ||||||||||||||||||||||||||||
| 1825 | window is the Kaiser-Bessel window. This window is defined by | ||||||||||||||||||||||||||||
| 1826 | |||||||||||||||||||||||||||||
| 1827 | $beta *= PI; | ||||||||||||||||||||||||||||
| 1828 | my @n = gsl_sf_bessel_In($beta * sqrt(1 - arr ** 2), 0); | ||||||||||||||||||||||||||||
| 1829 | my @d = gsl_sf_bessel_In($beta, 0); | ||||||||||||||||||||||||||||
| 1830 | $n[0] / $d[0]; | ||||||||||||||||||||||||||||
| 1831 | |||||||||||||||||||||||||||||
| 1832 | where the points in arr range from -1 through 1. | ||||||||||||||||||||||||||||
| 1833 | |||||||||||||||||||||||||||||
| 1834 | =head2 lanczos($N) | ||||||||||||||||||||||||||||
| 1835 | |||||||||||||||||||||||||||||
| 1836 | The Lanczos window. Another name for this window is the sinc window. This | ||||||||||||||||||||||||||||
| 1837 | window is defined by | ||||||||||||||||||||||||||||
| 1838 | |||||||||||||||||||||||||||||
| 1839 | my $x = PI * arr; | ||||||||||||||||||||||||||||
| 1840 | my $res = sin($x) / $x; | ||||||||||||||||||||||||||||
| 1841 | my $mid; | ||||||||||||||||||||||||||||
| 1842 | $mid = int($N / 2), $res->slice($mid) .= 1 if $N % 2; | ||||||||||||||||||||||||||||
| 1843 | $res; | ||||||||||||||||||||||||||||
| 1844 | |||||||||||||||||||||||||||||
| 1845 | where the points in arr range from -1 through 1. | ||||||||||||||||||||||||||||
| 1846 | |||||||||||||||||||||||||||||
| 1847 | =head2 nuttall($N) | ||||||||||||||||||||||||||||
| 1848 | |||||||||||||||||||||||||||||
| 1849 | The Nuttall window. One of the Blackman-Harris family, with coefficients | ||||||||||||||||||||||||||||
| 1850 | |||||||||||||||||||||||||||||
| 1851 | a0 = 0.3635819 | ||||||||||||||||||||||||||||
| 1852 | a1 = 0.4891775 | ||||||||||||||||||||||||||||
| 1853 | a2 = 0.1365995 | ||||||||||||||||||||||||||||
| 1854 | a3 = 0.0106411 | ||||||||||||||||||||||||||||
| 1855 | |||||||||||||||||||||||||||||
| 1856 | See also L<nuttall1|/nuttall1($N)>. | ||||||||||||||||||||||||||||
| 1857 | |||||||||||||||||||||||||||||
| 1858 | =head2 nuttall1($N) | ||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||
| 1860 | The Nuttall (v1) window. A window referred to as the Nuttall window. One of the | ||||||||||||||||||||||||||||
| 1861 | Blackman-Harris family, with coefficients | ||||||||||||||||||||||||||||
| 1862 | |||||||||||||||||||||||||||||
| 1863 | a0 = 0.355768 | ||||||||||||||||||||||||||||
| 1864 | a1 = 0.487396 | ||||||||||||||||||||||||||||
| 1865 | a2 = 0.144232 | ||||||||||||||||||||||||||||
| 1866 | a3 = 0.012604 | ||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||
| 1868 | This routine gives the same result as the routine B<nuttallwin> in Octave 3.6.2. | ||||||||||||||||||||||||||||
| 1869 | See also L<nuttall|/nuttall($N)>. | ||||||||||||||||||||||||||||
| 1870 | |||||||||||||||||||||||||||||
| 1871 | =head2 parzen($N) | ||||||||||||||||||||||||||||
| 1872 | |||||||||||||||||||||||||||||
| 1873 | The Parzen window. (Ref 1). Other names for this window are: Jackson, | ||||||||||||||||||||||||||||
| 1874 | Valle-Poussin. This function disagrees with the Octave subroutine B<parzenwin>, | ||||||||||||||||||||||||||||
| 1875 | but agrees with Ref. 1. See also L<parzen_octave|/parzen_octave($N)>. | ||||||||||||||||||||||||||||
| 1876 | |||||||||||||||||||||||||||||
| 1877 | =head2 parzen_octave($N) | ||||||||||||||||||||||||||||
| 1878 | |||||||||||||||||||||||||||||
| 1879 | The Parzen window. No periodic version of this window is defined. This routine | ||||||||||||||||||||||||||||
| 1880 | gives the same result as the routine B<parzenwin> in Octave 3.6.2. See also | ||||||||||||||||||||||||||||
| 1881 | L<parzen|/parzen($N)>. | ||||||||||||||||||||||||||||
| 1882 | |||||||||||||||||||||||||||||
| 1883 | =head2 poisson($N,$alpha) | ||||||||||||||||||||||||||||
| 1884 | |||||||||||||||||||||||||||||
| 1885 | The Poisson window. (Ref 1). This window is defined by | ||||||||||||||||||||||||||||
| 1886 | |||||||||||||||||||||||||||||
| 1887 | exp(-$alpha * abs(arr)) | ||||||||||||||||||||||||||||
| 1888 | |||||||||||||||||||||||||||||
| 1889 | where the points in arr range from -1 through 1. | ||||||||||||||||||||||||||||
| 1890 | |||||||||||||||||||||||||||||
| 1891 | =head2 rectangular($N) | ||||||||||||||||||||||||||||
| 1892 | |||||||||||||||||||||||||||||
| 1893 | The Rectangular window. (Ref 1). Other names for this window are: dirichlet, | ||||||||||||||||||||||||||||
| 1894 | boxcar. | ||||||||||||||||||||||||||||
| 1895 | |||||||||||||||||||||||||||||
| 1896 | =head2 triangular($N) | ||||||||||||||||||||||||||||
| 1897 | |||||||||||||||||||||||||||||
| 1898 | The Triangular window. This window is defined by | ||||||||||||||||||||||||||||
| 1899 | |||||||||||||||||||||||||||||
| 1900 | 1 - abs(arr) | ||||||||||||||||||||||||||||
| 1901 | |||||||||||||||||||||||||||||
| 1902 | where the points in arr range from -$N/($N-1) through $N/($N-1). | ||||||||||||||||||||||||||||
| 1903 | See also L<bartlett|/bartlett($N)>. | ||||||||||||||||||||||||||||
| 1904 | |||||||||||||||||||||||||||||
| 1905 | =head2 tukey($N,$alpha) | ||||||||||||||||||||||||||||
| 1906 | |||||||||||||||||||||||||||||
| 1907 | The Tukey window. (Ref 1). Another name for this window is the tapered cosine | ||||||||||||||||||||||||||||
| 1908 | window. | ||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||
| 1910 | =head2 welch($N) | ||||||||||||||||||||||||||||
| 1911 | |||||||||||||||||||||||||||||
| 1912 | The Welch window. (Ref 1). Other names for this window are: Riez, Bochner, | ||||||||||||||||||||||||||||
| 1913 | Parzen, parabolic. This window is defined by | ||||||||||||||||||||||||||||
| 1914 | |||||||||||||||||||||||||||||
| 1915 | 1 - arr**2 | ||||||||||||||||||||||||||||
| 1916 | |||||||||||||||||||||||||||||
| 1917 | where the points in arr range from -1 through 1. | ||||||||||||||||||||||||||||
| 1918 | |||||||||||||||||||||||||||||
| 1919 | =head1 AUXILIARY SUBROUTINES | ||||||||||||||||||||||||||||
| 1920 | |||||||||||||||||||||||||||||
| 1921 | These subroutines are used internally, but are also available for export. | ||||||||||||||||||||||||||||
| 1922 | |||||||||||||||||||||||||||||
| 1923 | =head2 cos_mult_to_pow | ||||||||||||||||||||||||||||
| 1924 | |||||||||||||||||||||||||||||
| 1925 | Convert Blackman-Harris coefficients. The BH windows are usually defined via | ||||||||||||||||||||||||||||
| 1926 | coefficients for cosines of integer multiples of an argument. The same windows | ||||||||||||||||||||||||||||
| 1927 | may be written instead as terms of powers of cosines of the same argument. | ||||||||||||||||||||||||||||
| 1928 | These may be computed faster as they replace evaluation of cosines with | ||||||||||||||||||||||||||||
| 1929 | multiplications. This subroutine is used internally to implement the | ||||||||||||||||||||||||||||
| 1930 | Blackman-Harris family of windows more efficiently. | ||||||||||||||||||||||||||||
| 1931 | |||||||||||||||||||||||||||||
| 1932 | This subroutine takes between 1 and 7 numeric arguments a0, a1, ... | ||||||||||||||||||||||||||||
| 1933 | |||||||||||||||||||||||||||||
| 1934 | It converts the coefficients of this | ||||||||||||||||||||||||||||
| 1935 | |||||||||||||||||||||||||||||
| 1936 | a0 - a1 cos(arg) + a2 cos(2 * arg) - a3 cos(3 * arg) + ... | ||||||||||||||||||||||||||||
| 1937 | |||||||||||||||||||||||||||||
| 1938 | To the cofficients of this | ||||||||||||||||||||||||||||
| 1939 | |||||||||||||||||||||||||||||
| 1940 | c0 + c1 cos(arg) + c2 cos(arg)**2 + c3 cos(arg)**3 + ... | ||||||||||||||||||||||||||||
| 1941 | |||||||||||||||||||||||||||||
| 1942 | =head2 cos_pow_to_mult | ||||||||||||||||||||||||||||
| 1943 | |||||||||||||||||||||||||||||
| 1944 | This function is the inverse of L</cos_mult_to_pow>. | ||||||||||||||||||||||||||||
| 1945 | |||||||||||||||||||||||||||||
| 1946 | This subroutine takes between 1 and 7 numeric arguments c0, c1, ... | ||||||||||||||||||||||||||||
| 1947 | |||||||||||||||||||||||||||||
| 1948 | It converts the coefficients of this | ||||||||||||||||||||||||||||
| 1949 | |||||||||||||||||||||||||||||
| 1950 | c0 + c1 cos(arg) + c2 cos(arg)**2 + c3 cos(arg)**3 + ... | ||||||||||||||||||||||||||||
| 1951 | |||||||||||||||||||||||||||||
| 1952 | To the cofficients of this | ||||||||||||||||||||||||||||
| 1953 | |||||||||||||||||||||||||||||
| 1954 | a0 - a1 cos(arg) + a2 cos( 2 * arg) - a3 cos( 3 * arg) + ... | ||||||||||||||||||||||||||||
| 1955 | |||||||||||||||||||||||||||||
| 1956 | =cut | ||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||
| 1958 | sub cos_pow_to_mult { | ||||||||||||||||||||||||||||
| 1959 | 9 | ▶ | my @cin = @_; | ||||||||||||||||||||||||||
|
Subroutine
cos_pow_to_mult: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 1960 | 9 | ▶ | PDL::Core::barf 'cos_pow_to_mult: number of args not less than 8.' if @cin > 7; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||
| 1962 | 8 | my $ex = 7 - @cin; | |||||||||||||||||||||||||||
| 1963 | |||||||||||||||||||||||||||||
| 1964 | 8 | my @c = ( @cin, (0) x $ex ); | |||||||||||||||||||||||||||
| 1965 | |||||||||||||||||||||||||||||
| 1966 | 8 | my @as = ( | |||||||||||||||||||||||||||
| 1967 | 10 * $c[6] + 12 * $c[4] + 16 * $c[2] + 32 * $c[0], | ||||||||||||||||||||||||||||
| 1968 | 20 * $c[5] + 24 * $c[3] + 32 * $c[1], | ||||||||||||||||||||||||||||
| 1969 | 15 * $c[6] + 16 * $c[4] + 16 * $c[2], | ||||||||||||||||||||||||||||
| 1970 | 10 * $c[5] + 8 * $c[3], | ||||||||||||||||||||||||||||
| 1971 | 6 * $c[6] + 4 * $c[4], | ||||||||||||||||||||||||||||
| 1972 | 2 * $c[5], | ||||||||||||||||||||||||||||
| 1973 | $c[6], | ||||||||||||||||||||||||||||
| 1974 | ); | ||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||
| 1976 | 8 | pop @as for 1 .. $ex; | |||||||||||||||||||||||||||
| 1977 | |||||||||||||||||||||||||||||
| 1978 | 8 | my $sign = -1; | |||||||||||||||||||||||||||
| 1979 | |||||||||||||||||||||||||||||
| 1980 | 8 | foreach (@as) { | |||||||||||||||||||||||||||
| 1981 | 28 | $_ /= -$sign * 32; | |||||||||||||||||||||||||||
| 1982 | 28 | $sign *= -1; | |||||||||||||||||||||||||||
| 1983 | } | ||||||||||||||||||||||||||||
| 1984 | |||||||||||||||||||||||||||||
| 1985 | 8 | @as; | |||||||||||||||||||||||||||
| 1986 | } | ||||||||||||||||||||||||||||
| 1987 | |||||||||||||||||||||||||||||
| 1988 | =head2 chebpoly | ||||||||||||||||||||||||||||
| 1989 | |||||||||||||||||||||||||||||
| 1990 | =for usage | ||||||||||||||||||||||||||||
| 1991 | |||||||||||||||||||||||||||||
| 1992 | chebpoly($n,$x) | ||||||||||||||||||||||||||||
| 1993 | |||||||||||||||||||||||||||||
| 1994 | =for ref | ||||||||||||||||||||||||||||
| 1995 | |||||||||||||||||||||||||||||
| 1996 | Returns the value of the C<$n>-th order Chebyshev polynomial at point C<$x>. | ||||||||||||||||||||||||||||
| 1997 | $n and $x may be scalar numbers, pdl's, or array refs. However, at least one | ||||||||||||||||||||||||||||
| 1998 | of $n and $x must be a scalar number. | ||||||||||||||||||||||||||||
| 1999 | |||||||||||||||||||||||||||||
| 2000 | All mixtures of pdls and scalars could be handled much more easily as a PP | ||||||||||||||||||||||||||||
| 2001 | routine. But, at this point PDL::DSP::Windows is pure perl/pdl, requiring no | ||||||||||||||||||||||||||||
| 2002 | C/Fortran compiler. | ||||||||||||||||||||||||||||
| 2003 | |||||||||||||||||||||||||||||
| 2004 | =cut | ||||||||||||||||||||||||||||
| 2005 | |||||||||||||||||||||||||||||
| 2006 | sub chebpoly { | ||||||||||||||||||||||||||||
| 2007 | 8 | ▶ | PDL::Core::barf 'chebpoly: Two arguments expected. Got ' .scalar(@_) . "\n" unless @_ == 2; | ||||||||||||||||||||||||||
|
Subroutine
chebpoly: called CC=6 SCAR=18.3
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2008 | |||||||||||||||||||||||||||||
| 2009 | 8 | my ( $n, $x ) = @_; | |||||||||||||||||||||||||||
| 2010 | |||||||||||||||||||||||||||||
| 2011 | 8 | ▶ | if ( ref $x ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2012 | 7 | ▶ | PDL::Core::barf "chebpoly: neither $n nor $x is a scalar number" if ref($n); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2013 | 7 | $x = PDL::Core::topdl($x); | |||||||||||||||||||||||||||
| 2014 | |||||||||||||||||||||||||||||
| 2015 | 7 | my $tn = PDL::Core::zeroes($x); | |||||||||||||||||||||||||||
| 2016 | |||||||||||||||||||||||||||||
| 2017 | 7 | my ( $ind1, $ind2 ) = PDL::Primitive::which_both( abs($x) <= 1 ); | |||||||||||||||||||||||||||
| 2018 | |||||||||||||||||||||||||||||
| 2019 | 7 | $tn->index($ind1) .= cos( $n * PDL::Math::acos( $x->index($ind1) ) ); | |||||||||||||||||||||||||||
| 2020 | 7 | $tn->index($ind2) .= PDL::Math::cosh( $n * PDL::Math::acosh( $x->index($ind2) ) ); | |||||||||||||||||||||||||||
| 2021 | |||||||||||||||||||||||||||||
| 2022 | 7 | return $tn; | |||||||||||||||||||||||||||
| 2023 | } | ||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||
| 2025 | 1 | ▶ | $n = PDL::Core::topdl($n) if ref $n; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2026 | 1 | ▶ | return abs($x) <= 1 ? PDL::Math::cos( $n * PDL::Math::acos($x) ) : PDL::Math::cosh( $n * PDL::Math::acosh($x) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2027 | } | ||||||||||||||||||||||||||||
| 2028 | |||||||||||||||||||||||||||||
| 2029 | |||||||||||||||||||||||||||||
| 2030 | sub cos_mult_to_pow { | ||||||||||||||||||||||||||||
| 2031 | 9 | ▶ | my( @ain ) = @_; | ||||||||||||||||||||||||||
|
Subroutine
cos_mult_to_pow: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 2032 | 9 | ▶ | PDL::Core::barf 'cos_mult_to_pow: number of args not less than 8.' if @ain > 7; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 2033 | |||||||||||||||||||||||||||||
| 2034 | 8 | my $ex = 7 - @ain; | |||||||||||||||||||||||||||
| 2035 | |||||||||||||||||||||||||||||
| 2036 | 8 | my @a = ( @ain, (0) x $ex ); | |||||||||||||||||||||||||||
| 2037 | |||||||||||||||||||||||||||||
| 2038 | 8 | my (@cs) = ( | |||||||||||||||||||||||||||
| 2039 | -$a[6] + $a[4] - $a[2] + $a[0], | ||||||||||||||||||||||||||||
| 2040 | -5 * $a[5] + 3 * $a[3] - $a[1], | ||||||||||||||||||||||||||||
| 2041 | 18 * $a[6] - 8 * $a[4] + 2 * $a[2], | ||||||||||||||||||||||||||||
| 2042 | 20 * $a[5] - 4 * $a[3], | ||||||||||||||||||||||||||||
| 2043 | 8 * $a[4] - 48 * $a[6], | ||||||||||||||||||||||||||||
| 2044 | -16 * $a[5], | ||||||||||||||||||||||||||||
| 2045 | 32 * $a[6] | ||||||||||||||||||||||||||||
| 2046 | ); | ||||||||||||||||||||||||||||
| 2047 | |||||||||||||||||||||||||||||
| 2048 | 8 | pop @cs for 1 .. $ex; | |||||||||||||||||||||||||||
| 2049 | |||||||||||||||||||||||||||||
| 2050 | 8 | @cs; | |||||||||||||||||||||||||||
| 2051 | } | ||||||||||||||||||||||||||||
| 2052 | |||||||||||||||||||||||||||||
| 2053 | # Delete internal constants from namespace | ||||||||||||||||||||||||||||
| 2054 | 2 | delete @PDL::DSP::Windows::{qw( | |||||||||||||||||||||||||||
| 2055 | HAVE_LinearAlgebra | ||||||||||||||||||||||||||||
| 2056 | HAVE_BESSEL | ||||||||||||||||||||||||||||
| 2057 | HAVE_GNUPLOT | ||||||||||||||||||||||||||||
| 2058 | USE_FFTW_DIRECTION | ||||||||||||||||||||||||||||
| 2059 | I | ||||||||||||||||||||||||||||
| 2060 | )}; | ||||||||||||||||||||||||||||
| 2061 | |||||||||||||||||||||||||||||
| 2062 | 2 | 1; | |||||||||||||||||||||||||||
| 2063 | |||||||||||||||||||||||||||||
| 2064 | __END__ | ||||||||||||||||||||||||||||