File: erf.t

package info (click to toggle)
pdl 1%3A2.4.7%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 10,128 kB
  • ctags: 5,821
  • sloc: perl: 26,328; fortran: 13,113; ansic: 9,378; makefile: 71; sh: 50; sed: 6
file content (30 lines) | stat: -rw-r--r-- 557 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*-perl-*-

use Test;

BEGIN { plan tests => 5; }

use PDL::LiteF;
use PDL::Math;

kill INT,$$ if $ENV{UNDER_DEBUGGER}; # Useful for debugging.

sub tapprox {
    my($a,$b) = @_;
    $c = abs($a-$b);
    $d = max($c);
    $d < 0.01;
}

ok( tapprox(erf(0.),0.) && tapprox(erf(30.),1.) );
ok( tapprox(erf(0.5),1.-erfc(0.5)) );
ok( tapprox(erf(erfi(0.5)),0.5) && tapprox(erfi(erf(0.5)),0.5) );

# now test inplace
$a = pdl(0.0,30.0);
$a->inplace->erf;
ok( tapprox( $a, pdl(0.0,1.0) ) );

$a = pdl(0.5);
$a->inplace->erfc; 
ok( tapprox( 1.0-$a, erf(0.5) ) );