3
END { unlink 't/callext.pdb';}; # In case we build a 2nd time,
4
# but using a different Microsoft compiler
6
# Example of how to use callext() - also see callext.c
12
BEGIN { plan tests => 1;
17
use PDL::Core ':Internal'; # For topdl()
21
kill 'INT',$$ if $ENV{UNDER_DEBUGGER}; # Useful for debugging.
30
# Create the filenames
31
my $cfile = File::Spec->catfile('t', 'callext.c');
32
# include the pdlsimple.h that's in blib.
33
my $inc = File::Spec->catdir('blib', 'lib', 'PDL', 'Core');
34
my $out = File::Spec->catfile('t', 'callext.'.$Config{dlext});
38
callext_cc($cfile, "-I$inc", '', $out);
40
my $y = sequence(5,4)+2; # Create PDL
41
my $x = $y*20+100; # Another
43
my $try = loglog($x,$y);
44
my $correct = log(float($x))/log(float($y));
47
print "Correct = $correct\n";
48
ok( tapprox($try, $correct) );
50
# Return log $x to base $y using callext() routine -
51
# perl wrapper makes this nice and easy to use.
55
die 'Usage: loglog($x,$y)' if scalar(@_)!=2;
59
# (i) topdl() forces arguments to be pdl vars even
60
# if ordinary numbers are passed
62
# (ii) float() forces the pdl vars to be float precision
63
# thus matching the C routine.
65
my $x = float(topdl(shift));
66
my $y = float(topdl(shift));
68
my $ret = $x->copy; # Make copy of $x to return
74
callext($out, "loglog_ext", $ret, $y);