Skip to content

Commit

Permalink
PDL::Math switch to new lib/*.pd scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Nov 18, 2024
1 parent 1efbd08 commit 77ee0f5
Show file tree
Hide file tree
Showing 21 changed files with 36 additions and 45 deletions.
3 changes: 3 additions & 0 deletions Basic/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ lib/PDL/Bad.pm
lib/PDL/Bad.xs
lib/PDL/Core.c
lib/PDL/Core/pdl.h
lib/PDL/Math.c
lib/PDL/Math.pm
lib/PDL/Math.xs
lib/PDL/Ops.c
lib/PDL/Ops.pm
lib/PDL/Ops.xs
Expand Down
6 changes: 3 additions & 3 deletions Basic/Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if (!$pthread_library) {
print "\t==> Enabling perl threads will not help!\n";
}
my $pthread_define = $pthread_library ? ' -DPDL_PTHREAD ' : '';
my $libs_string = "$pthread_library -lm";
my $libs_string = "$pthread_library ".get_maths_libs();

my $hdeps = join ' ', map catfile(qw(lib PDL Core), $_), qw(pdl.h pdlperl.h pdlcore.h pdlbroadcast.h pdlmagic.h);
my @cfiles = qw(pdlcore pdlapi pdlbroadcast pdlconv pdlmagic pdlaffine pdlutil);
Expand All @@ -65,8 +65,8 @@ push @cleanup, $cobj;
my $core_obj = catfile(qw(lib PDL), 'Core$(OBJ_EXT)');

# the modules in PDL::LiteF, used in t/core.t
my @BUILD_CORE = qw(Bad Core Ops Slices Ufunc);
my @DIRS_CORE = qw(Primitive Math MatrixOps);
my @BUILD_CORE = qw(Bad Core Math Ops Slices Ufunc);
my @DIRS_CORE = qw(Primitive MatrixOps);
# the modules needed in "use PDL"
my @DIRS_BASIC = qw(IO-Misc IO-Pnm Lib-Compression Lib-FFT Lib-ImageND Lib-ImageRGB);
WriteMakefile(
Expand Down
3 changes: 0 additions & 3 deletions Basic/Math/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions Basic/Math/Makefile.PL

This file was deleted.

9 changes: 7 additions & 2 deletions Basic/lib/PDL/Core/Dev.pm
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ sub pdlpp_postamble {
join '', map _postamble($w, 0, @$_), @_;
}

our %EXTRAS;
sub pdlpp_eumm_update_deep {
my ($eumm) = @_;
my $pm = $eumm->{PM};
Expand All @@ -197,19 +198,22 @@ sub pdlpp_eumm_update_deep {
my @macro_vars = pdlpp_mod_vars(my $mod = join '::', split /\//, $nolib);
@$macro{@macro_vars} = pdlpp_mod_values(1, $f, $base, 1, 1);
$xsb->{$base}{OBJECT} = "\$($macro_vars[1])";
$xsb->{$base}{OBJECT} .= $EXTRAS{$f}{OBJECT} if $EXTRAS{$f}{OBJECT};
$eumm->{INC} .= " $EXTRAS{$f}{INC}" if $EXTRAS{$f}{INC}; # global
my $mtime = (stat $f)[9] // die "$f: $!";
open my $fh, ">", $pmfile or die "$pmfile: $!"; # XSMULTI needs this
print $fh "package $mod;\nour \$VER"."SION = '$global_version';\n1;\n"; # break is so cpanm doesn't try to parse as version
close $fh;
utime $mtime - 120, $mtime - 120, $pmfile; # so is out of date
push @pd_srcs, [$f, $base, $mod, '', 1];
$eumm->{clean}{FILES} .= join ' ', '', $pmfile, map "\$($_)", @macro_vars;
$eumm->{clean}{FILES} .= $EXTRAS{$f}{OBJECT} if $EXTRAS{$f}{OBJECT};
}
@pd_srcs;
}

sub pdlpp_list_functions {
my ($src, $internal) = @_;
my ($src, $internal, $base) = @_;
my $abs_src = File::Spec::Functions::rel2abs($src);
if (!$flist_cache{$abs_src}) {
my $w = whereami_any();
Expand All @@ -219,6 +223,7 @@ sub pdlpp_list_functions {
$INC{'PDL/Types.pm'} = 1;
}
require ''.catfile($w, qw(PP.pm));
$::PDLBASE = $base;
$flist_cache{$abs_src} = [ PDL::PP::list_functions($src) ];
}
@{ $flist_cache{$abs_src} };
Expand All @@ -234,7 +239,7 @@ sub pdlpp_mod_values {
my ($internal, $src, $base, $multi_c, $deep) = @_;
return ("$base.xs", "$base\$(OBJ_EXT)") if !$multi_c;
my $cfileprefix = $deep ? "$base-" : '';
my @cbase = map $cfileprefix."pp-$_", pdlpp_list_functions($src, $internal);
my @cbase = map $cfileprefix."pp-$_", pdlpp_list_functions($src, $internal, $base);
(join(' ', "$base.xs", map "$_.c", @cbase),
join(' ', map "$_\$(OBJ_EXT)", $base, @cbase));
}
Expand Down
7 changes: 4 additions & 3 deletions Basic/Math/math.pd → Basic/lib/PDL/Math.pd
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,19 @@ my @keys = sort keys %source;
my $libs = PDL::Core::Dev::get_maths_libs();
# Test for presence of besfuncs
require File::Spec::Functions;
my $include = qq{#include "}.File::Spec::Functions::rel2abs('mconf.h').qq{"};
my $include = qq{#include "}.File::Spec::Functions::rel2abs("$::PDLBASE/mconf.h").qq{"};
$source{$_} = 'system' for grep PDL::Core::Dev::trylink('', $include, "$_(1.);", $libs), qw(j0 j1 y0 y1);
$source{$_} = 'system' for grep PDL::Core::Dev::trylink('', $include, "$_(1,1.);", $libs), qw(jn yn);
my %seen; # Build object file list
foreach my $func (@keys) {
my $file = $source{$func};
next if $file eq 'system';
die "File for function $func not found\n" if $file eq '';
$PDL::Core::Dev::EXTRAS{$::PDLMOD}{OBJECT} .= " $file\$(OBJ_EXT)" unless $seen{$file}++;
$PDL::Core::Dev::EXTRAS{$::PDLMOD}{OBJECT} .= " $::PDLBASE/$file\$(OBJ_EXT)" unless $seen{$file}++;
}
# Add support routines
$PDL::Core::Dev::EXTRAS{$::PDLMOD}{OBJECT} .= join '', map " $_\$(OBJ_EXT)", qw(const mtherr polevl cpoly ndtri);
$PDL::Core::Dev::EXTRAS{$::PDLMOD}{OBJECT} .= join '', map " $::PDLBASE/$_\$(OBJ_EXT)", qw(const mtherr polevl cpoly ndtri);
$PDL::Core::Dev::EXTRAS{$::PDLMOD}{INC} .= qq{ "-I$::PDLBASE"};
}

my $R = [ppdefs()];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 18 additions & 19 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ Basic/lib/PDL/IO/Storable.pm
Basic/lib/PDL/Lite.pm
Basic/lib/PDL/LiteF.pm
Basic/lib/PDL/Lvalue.pm
Basic/lib/PDL/Math.pd
Basic/lib/PDL/Math/const.c
Basic/lib/PDL/Math/cpoly.c
Basic/lib/PDL/Math/cpoly.h
Basic/lib/PDL/Math/j0.c
Basic/lib/PDL/Math/j1.c
Basic/lib/PDL/Math/jn.c
Basic/lib/PDL/Math/mconf.h
Basic/lib/PDL/Math/mtherr.c
Basic/lib/PDL/Math/ndtri.c
Basic/lib/PDL/Math/NOTES
Basic/lib/PDL/Math/polevl.c
Basic/lib/PDL/Math/protos.h
Basic/lib/PDL/Math/yn.c
Basic/lib/PDL/MATLAB.pod
Basic/lib/PDL/Matrix.pm
Basic/lib/PDL/Modules.pod
Expand Down Expand Up @@ -142,26 +156,11 @@ Basic/lib/PDL/Slices.pd
Basic/lib/PDL/Tips.pod
Basic/lib/PDL/Tutorials.pod
Basic/lib/PDL/Types.pm
Basic/lib/PDL/Ufunc.pd
Basic/lib/PDLdb.pl
Basic/lib/Test/Deep/PDL.pm
Basic/lib/Test/PDL.pm
Basic/lib/PDL/Ufunc.pd
Basic/Makefile.PL
Basic/Math/const.c
Basic/Math/cpoly.c
Basic/Math/cpoly.h
Basic/Math/j0.c
Basic/Math/j1.c
Basic/Math/jn.c
Basic/Math/Makefile.PL
Basic/Math/math.pd
Basic/Math/mconf.h
Basic/Math/mtherr.c
Basic/Math/ndtri.c
Basic/Math/NOTES
Basic/Math/polevl.c
Basic/Math/protos.h
Basic/Math/yn.c
Basic/MatrixOps/eigen.c
Basic/MatrixOps/eigen.h
Basic/MatrixOps/eigens.c
Expand Down Expand Up @@ -216,17 +215,17 @@ Basic/t/niceslice-utilcall.t
Basic/t/niceslice.t
Basic/t/ops-bitwise.t
Basic/t/ops.t
Basic/t/pdl_from_string.t
Basic/t/pdlchar.t
Basic/t/pp_croaking.t
Basic/t/pp_line_numbers.t
Basic/t/pdl_from_string.t
Basic/t/ppt-01_ref_counting.t
Basic/t/ppt-02_non_threaded.t
Basic/t/ppt-03_name_munging.t
Basic/t/ppt-10_physical_piddles.t
Basic/t/ppt-11_memory_mapped.t
Basic/t/ppt-20_simd.t
Basic/t/ppt-30_sharing_from_threads.t
Basic/t/pp_croaking.t
Basic/t/pp_line_numbers.t
Basic/t/primitive-append.t
Basic/t/primitive-clip.t
Basic/t/primitive-interpolate.t
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.SKIP
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ RCS
/core$
\b_eumm/
^Basic/lib/PDL/Bad(\.(pm|xs|c)$|-pp-)
^Basic/lib/PDL/Math(\.(pm|xs|c)$|-pp-)
^Basic/lib/PDL/Ops(\.(pm|xs|c)$|-pp-)
^Basic/lib/PDL/Slices(\.(pm|xs|c)$|-pp-)
^Basic/lib/PDL/Ufunc(\.(pm|xs|c)$|-pp-)
Expand All @@ -53,7 +54,6 @@ RCS
^Basic/Lib-ImageND/ImageND\..*
^Basic/Lib-ImageRGB/ImageRGB\..*
^Basic/Lib-Transform/Transform\..*
^Basic/Math/Math\..*
^Basic/MatrixOps/MatrixOps\..*
^Basic/Primitive/Primitive\..*
^Basic/script/pdl$
Expand Down

0 comments on commit 77ee0f5

Please sign in to comment.