File Coverage

blib/lib/PDL/Constants.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 28 28 100.0


line stmt bran cond sub pod time code
1             =head1 NAME
2              
3             PDL::Constants -- basic compile time constants for PDL
4              
5             =head1 DESCRIPTION
6              
7             This module is used to define compile time constant
8             values for PDL. It uses Perl's L pragma for
9             simplicity and availability.
10              
11             =head1 SYNOPSIS
12              
13             use PDL::Constants qw(PI E);
14             print 'PI is ' . PI . "\n";
15             print 'E is ' . E . "\n";
16              
17             =cut
18              
19             package PDL::Constants;
20             our $VERSION = "0.02";
21             $VERSION = eval $VERSION;
22              
23             require Exporter;
24             @ISA = qw(Exporter);
25             @EXPORT_OK = qw(PI DEGRAD E I J); # symbols to export
26              
27 2     2   57546 use PDL::Lite;
  2         4  
  2         14  
28 2     2   919 use PDL::Complex qw(i);
  2         4  
  2         12  
29              
30             =head2 PI
31              
32             The ratio of a circle's circumference to its diameter
33              
34             =cut
35              
36 2     2   14 use constant PI => 4 * atan2(1, 1);
  2         4  
  2         175  
37              
38             =head2 DEGRAD
39              
40             The number of degrees of arc per radian (180/PI)
41              
42             =cut
43              
44 2     2   12 use constant DEGRAD => 180/PI;
  2         3  
  2         113  
45              
46             =head2 E
47              
48             The base of the natural logarithms or Euler's number
49              
50             =cut
51              
52 2     2   10 use constant E => exp(1);
  2         3  
  2         82  
53              
54             =head2 I
55              
56             The imaginary unit, C< I*I == -1 >
57              
58             =cut
59              
60 2     2   8 use constant I => i;
  2         4  
  2         5  
61              
62             =head2 J
63              
64             The imaginary unit for engineers, C< J*J == -1 >
65              
66             =cut
67              
68 2     2   13 use constant J => i;
  2         2  
  2         6  
69              
70             =head1 COPYRIGHT & LICENSE
71              
72             Copyright 2010 Chris Marshall (chm at cpan dot org).
73              
74             This program is free software; you can redistribute it and/or modify it
75             under the terms of either: the GNU General Public License as published
76             by the Free Software Foundation; or the Artistic License.
77              
78             See http://dev.perl.org/licenses/ for more information.
79              
80             =cut
81              
82             1;