File: inlpp.pl

package info (click to toggle)
pdl 1%3A2.025-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,768 kB
  • sloc: perl: 43,919; fortran: 13,113; ansic: 9,366; makefile: 37; sh: 32; sed: 6
file content (29 lines) | stat: -rw-r--r-- 674 bytes parent folder | download | duplicates (2)
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
use blib;
use PDL; # this must be called before (!) 'use Inline Pdlpp' calls
use Inline Pdlpp; # the actual code is in the __Pdlpp__ block below

$x = sequence 10;
print $x->inc,"\n";
print $x->inc->dummy(1,10)->tcumul,"\n";

__DATA__

__Pdlpp__

# a rather silly increment function
pp_def('inc',
       Pars => 'i();[o] o()',
       Code => '$o() = $i() + 1;',
      );

# a cumulative product
# essentially the same functionality that is
# already implemented by prodover
# in the base distribution
pp_def('tcumul',
       Pars => 'in(n); float+ [o] mul()',
       Code => '$mul() = 1;
                loop(n) %{
                  $mul() *= $in();
                %}',
);