Skip to content

Commit

Permalink
moved augment, mstack, tricpy, t to PDL 2.091
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Sep 6, 2024
1 parent 8a8175e commit 20d06d8
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 186 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- moved augment, mstack, tricpy, t to PDL 2.091

0.39 2024-07-23
- bump minimum PDL to 2.083 as tricpy needs ArgOrder

Expand Down
56 changes: 0 additions & 56 deletions Complex/complex.pd
Original file line number Diff line number Diff line change
Expand Up @@ -4890,62 +4890,6 @@ EOF
&(integer){1});
');

################################################################################
#
# OTHER AUXILIARY ROUTINES
#
################################################################################
pp_def(
'ctricpy',
Pars => 'A(c=2,m,n);[o] C(c=2,m,n)',
OtherPars => 'int uplo',
OtherParsDefaults => {uplo => 0},
ArgOrder => [qw(A uplo C)],
Code => '
if ($COMP(uplo))
{
broadcastloop %{
loop (n,m) %{
loop(c) %{ $C() = $A(); %}
if (m >= n) break;
%}
%}
}
else
{
broadcastloop %{
loop (m,n) %{
loop(c) %{ $C() = $A(); %}
if (n >= m) break;
%}
%}
}
',
Doc => undef
);

pp_bless('PDL');
pp_def('cmstack',
DefaultFlow => 1,
TwoWay => 1,
Pars => 'x(c,n,m);y(c,n,p);[o]out(c,n,q=CALC($SIZE(m)+$SIZE(p)));',
Code => '
loop (m,n,c) %{ $out(q=>m) = $x(); %}
loop (q=$SIZE(m),n,c) %{ $out() = $y(p=>q-$SIZE(m)); %}
',
BackCode => '
loop (m,n,c) %{ $x() = $out(q=>m); %}
loop (q=$SIZE(m),n,c) %{ $y(p=>q-$SIZE(m)) = $out(); %}
',
Doc => <<EOT
=for ref

Combine two 3D ndarrays into a single ndarray, along the second
("vertical") dim.
This routine does backward and forward dataflow automatically.
EOT
);

pp_addhdr('
void cftrace(int n, void *a1, void *a2);
void cdtrace(int n, void *a1, void *a2);
Expand Down
4 changes: 2 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ WriteMakefile(
x_IRC => 'irc://irc.perl.org/#pdl',
},
CONFIGURE_REQUIRES => {
"PDL" => '2.083',
"PDL" => '2.091',
"Devel::CheckLib" => 0,
"ExtUtils::F77" => '1.26',
},
PREREQ_PM => {
"PDL" => '2.088', # =CALC
"PDL" => '2.091', # tricpy etc
},
TEST_REQUIRES => {
"Test::More" => '0.88', # done_testing
Expand Down
101 changes: 0 additions & 101 deletions Real/real.pd
Original file line number Diff line number Diff line change
Expand Up @@ -10452,63 +10452,6 @@ the exponent range, as is found on a Cray.
labad ($underflow, $overflow);

');
################################################################################
#
# OTHER AUXILIARY ROUTINES
#
################################################################################
pp_def(
'tricpy',
Pars => 'A(m,n);[o] C(m,n)',
OtherPars => 'int uplo',
OtherParsDefaults => {uplo => 0},
ArgOrder => [qw(A uplo C)],
GenericTypes => [ppdefs_all()],
Code => '
if ($COMP(uplo))
{
broadcastloop %{
loop(n,m) %{
$C() = $A();
if (m >= n) break;
%}
%}
}
else
{
broadcastloop %{
loop(m,n) %{
$C() = $A();
if (n >= m) break;
%}
%}
}
',
Doc => <<'EOT'
=for usage

tricpy(PDL(A), int(uplo), PDL(C))

=for example

use PDL::LinearAlgebra;

$c = $a->tricpy($uplo); # explicit uplo
$c = $a->tricpy; # default upper
or
use PDL::LinearAlgebra::Real;

tricpy($a, $uplo, $c); # modify c

=for ref

Copy triangular part to another matrix. If uplo == 0 copy upper triangular part.

=cut

EOT

);

pp_def(
'cplx_eigen',
Expand Down Expand Up @@ -10583,50 +10526,6 @@ as computed by geev or geevx.
EOT
);


pp_def('augment',
DefaultFlow => 1,
TwoWay => 1,
Pars => 'x(n); y(p);[o]out(q=CALC($SIZE(n)+$SIZE(p)))',
GenericTypes => [ppdefs_all()],
Code => '
loop (q=:$SIZE(n)) %{ $out() = $x(n=>q); %}
loop (q=$SIZE(n)) %{ $out() = $y(p=>q-$SIZE(n)); %}
',
BackCode => '
loop (q=:$SIZE(n)) %{ $x(n=>q) = $out(); %}
loop (q=$SIZE(n)) %{ $y(p=>q-$SIZE(n)) = $out(); %}
',
Doc => <<EOT
=for ref

Combine two ndarrays into a single ndarray along the 0-th ("horizontal") dim.
This routine does backward and forward dataflow automatically.
EOT
);

pp_def('mstack',
DefaultFlow => 1,
TwoWay => 1,
Pars => 'x(n,m);y(n,p);[o]out(n,q=CALC($SIZE(m)+$SIZE(p)));',
GenericTypes => [ppdefs_all()],
Code => '
loop (m,n) %{ $out(q=>m) = $x(); %}
loop (q=$SIZE(m),n) %{ $out() = $y(p=>q-$SIZE(m)); %}
',
BackCode => '
loop (m,n) %{ $x() = $out(q=>m); %}
loop (q=$SIZE(m),n) %{ $y(p=>q-$SIZE(m)) = $out(); %}
',
Doc => <<EOT
=for ref

Combine two 3D ndarrays into a single ndarray, along the second
("vertical") dim.
This routine does backward and forward dataflow automatically.
EOT
);

pp_addhdr('
float ftrace(int n, float *mat);
double dtrace(int n, double *mat);
Expand Down
13 changes: 1 addition & 12 deletions lib/PDL/LinearAlgebra.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ our $VERSION = '0.39';
$VERSION = eval $VERSION;

@PDL::LinearAlgebra::ISA = qw/PDL::Exporter/;
@PDL::LinearAlgebra::EXPORT_OK = qw/t diag issym minv mtriinv msyminv mposinv mdet mposdet mrcond positivise
@PDL::LinearAlgebra::EXPORT_OK = qw/diag issym minv mtriinv msyminv mposinv mdet mposdet mrcond positivise
mdsvd msvd mgsvd mpinv mlu mhessen mchol mqr mql mlq mrq meigen meigenx
mgeigen mgeigenx msymeigen msymeigenx msymgeigen msymgeigenx
msolve mtrisolve msymsolve mpossolve msolvex msymsolvex mpossolvex
Expand All @@ -41,8 +41,6 @@ package # hide from CPAN indexer
our $floatformat = "%4.4g"; # Default print format for long numbers
our $doubleformat = "%6.6g";
our @ISA = @ISA ? @ISA : 'PDL'; # so still operates when no PDL::Complex

*tricpy = \&PDL::LinearAlgebra::Complex::ctricpy;
}
########################################################################

Expand Down Expand Up @@ -182,14 +180,6 @@ sub PDL::_norm {
return $trans ? $m->t*$scale->dummy(2) : $m*$scale->dummy(2)->t;
}

*t = \&PDL::t;
sub PDL::t {
my $d = $_[0]->dims_internal;
my ($m, $conj) = @_;
my $r = ($m->dims > $d+1) ? $m->xchg($d,$d+1) : $m->dummy($d);
$conj ? $r->conj : $r;
}

=head2 issym
=for usage
Expand Down Expand Up @@ -361,7 +351,6 @@ use attributes 'PDL', \&PDL::diag, 'lvalue';
Returns symmetric or Hermitian matrix from lower or upper triangular matrix.
Supports inplace and threading.
Uses L<tricpy|PDL::LinearAlgebra::Real/tricpy> or L<ctricpy|PDL::LinearAlgebra::Complex/ctricpy> from Lapack.
=for usage
Expand Down
11 changes: 0 additions & 11 deletions t/1.t
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,4 @@ $B = identity(2);
ok fapprox($got = $A x $B, $A), 'complex first' or diag "got: $got";
ok fapprox($got = $B x $A, $A), 'complex second' or diag "got: $got";

$A = pdl '[[1 2 3] [4 5 6] [7 8 9]]';
my $up = pdl '[[1 2 3] [0 5 6] [0 0 9]]';
my $lo = pdl '[[1 0 0] [4 5 0] [7 8 9]]';
ok fapprox($got = $A->tricpy(0), $up), 'upper triangle #1' or diag "got: $got";
tricpy($A, 0, $got = null);
ok fapprox($got, $up), 'upper triangle #2' or diag "got: $got";
ok fapprox($got = $A->tricpy, $up), 'upper triangle #3' or diag "got: $got";
ok fapprox($got = $A->tricpy(1), $lo), 'lower triangle #1' or diag "got: $got";
tricpy($A, 1, $got = null);
ok fapprox($got, $lo), 'lower triangle #2' or diag "got: $got";

done_testing;
4 changes: 0 additions & 4 deletions t/legacy.t
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ $aa = pdl('[[[0 1] [2 3] [4 5]] [[6 7] [8 9] [10 11]] [[12 13] [14 15] [16 17]
my $up = pdl('[[[0 1] [2 3] [4 5]] [[0 0] [8 9] [10 11]] [[0 0] [0 0] [16 17]]]')->cplx;
my $lo = pdl('[[[0 1] [0 0] [0 0]] [[6 7] [8 9] [0 0]] [[12 13] [14 15] [16 17]]]')->cplx;

runtest($aa, 'ctricpy', $up, [0]);
runtest($aa, 'ctricpy', $up);
runtest($aa, 'ctricpy', $lo, [1]);

do './t/common.pl'; die if $@;

done_testing;

0 comments on commit 20d06d8

Please sign in to comment.