Skip to content

Commit

Permalink
remove support for PDL::Complex entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Nov 26, 2024
1 parent e1735f5 commit 9159e3a
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 194 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
- remove support for PDL::Complex entirely

0.40 2024-09-06
- moved augment, mstack, tricpy, t to PDL 2.091

Expand Down
112 changes: 48 additions & 64 deletions Complex/complex.pd
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,6 @@ pp_addpm({At=>'Top'},<<'EOD');
use strict;
use PDL::LinearAlgebra::Real;

{
package # hide from CPAN
PDL::Complex;
my $warningFlag;
BEGIN{
$warningFlag = $^W;
$^W = 0;
}
use overload (
'x' => sub {UNIVERSAL::isa($_[1],'PDL::Complex') ? PDL::cmmult($_[0], $_[1]) :
PDL::cmmult($_[0], PDL::Complex::r2C($_[1]));
},
);
BEGIN{ $^W = $warningFlag ; }
}

=encoding utf8

=head1 NAME
Expand Down Expand Up @@ -325,7 +309,7 @@ EOF
rwork = ($GENERIC() *)malloc( 7 * lwork * sizeof($GENERIC()));
break;

}
}
lwork = -1;
FORTRAN($TFD(c,z)gesdd)(
&tra,
Expand Down Expand Up @@ -383,9 +367,9 @@ The SVD is written
pp_defc("ggsvd",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)ggsvd3)(char *jobu, char *jobv, char *jobq, integer *m,
integer *n, integer *p, integer *k, integer *l, $GENERIC() *a,
integer *lda, $GENERIC() *b, integer *ldb, $GENERIC() *alpha,
$GENERIC() *beta, $GENERIC() *u, integer *ldu, $GENERIC() *v, integer
integer *n, integer *p, integer *k, integer *l, $GENERIC() *a,
integer *lda, $GENERIC() *b, integer *ldb, $GENERIC() *alpha,
$GENERIC() *beta, $GENERIC() *u, integer *ldu, $GENERIC() *v, integer
*ldv, $GENERIC() *q, integer *ldq, $GENERIC() *work, integer *lwork, $GENERIC() *rwork, integer *iwork,
integer *info);
EOF
Expand All @@ -398,7 +382,7 @@ EOF
',
Code => generate_code '
char pjobu = \'N\';
char pjobv = \'N\';
char pjobv = \'N\';
char pjobq = \'N\';
$GENERIC() *work, twork[2];
integer lwork = -1;
Expand Down Expand Up @@ -439,7 +423,7 @@ EOF

lwork = (integer) twork[0];
work = ($GENERIC() *)malloc(2*(lwork * sizeof($GENERIC())));

FORTRAN($TFD(c,z)ggsvd3)(
&pjobu,
&pjobv,
Expand Down Expand Up @@ -870,7 +854,7 @@ EOF
&lwork,
$P(rwork),
$P(bwork),
$P(info));
$P(info));

lwork = (integer )tmp_work[0];

Expand Down Expand Up @@ -903,13 +887,13 @@ Complex version of L<PDL::LinearAlgebra::Real/gees>
to the top left of the Schur form.
If sort = 0, select_func is not referenced.
An complex eigenvalue w is selected if
select_func(PDL::Complex(w)) is true;
select_func(complex(w)) is true;
Note that a selected complex eigenvalue may no longer
satisfy select_func(PDL::Complex(w)) = 1 after ordering, since
satisfy select_func(complex(w)) = 1 after ordering, since
ordering may change the value of complex eigenvalues
(especially if the eigenvalue is ill-conditioned); in this
case info is set to N+2.


');

Expand Down Expand Up @@ -1009,9 +993,9 @@ Complex version of L<PDL::LinearAlgebra::Real/geesx>
to the top left of the Schur form.
If sort = 0, select_func is not referenced.
An complex eigenvalue w is selected if
select_func(PDL::Complex(w)) is true;
select_func(complex(w)) is true;
Note that a selected complex eigenvalue may no longer
satisfy select_func(PDL::Complex(w)) = 1 after ordering, since
satisfy select_func(complex(w)) = 1 after ordering, since
ordering may change the value of complex eigenvalues
(especially if the eigenvalue is ill-conditioned); in this
case info is set to N+2.
Expand Down Expand Up @@ -1114,9 +1098,9 @@ Complex version of L<PDL::LinearAlgebra::Real/ggees>
to the top left of the Schur form.
If sort = 0, select_func is not referenced.
An eigenvalue w = w/beta is selected if
select_func(PDL::Complex(w), PDL::Complex(beta)) is true;
select_func(complex(w), complex(beta)) is true;
Note that a selected complex eigenvalue may no longer
satisfy select_func(PDL::Complex(w),PDL::Complex(beta)) = 1 after ordering, since
satisfy select_func(complex(w),complex(beta)) = 1 after ordering, since
ordering may change the value of complex eigenvalues
(especially if the eigenvalue is ill-conditioned); in this
case info is set to N+2.
Expand Down Expand Up @@ -1232,9 +1216,9 @@ Complex version of L<PDL::LinearAlgebra::Real/ggeesx>
to the top left of the Schur form.
If sort = 0, select_func is not referenced.
An eigenvalue w = w/beta is selected if
select_func(PDL::Complex(w), PDL::Complex(beta)) is true;
select_func(complex(w), complex(beta)) is true;
Note that a selected complex eigenvalue may no longer
satisfy select_func(PDL::Complex(w),PDL::Complex(beta)) = 1 after ordering, since
satisfy select_func(complex(w),complex(beta)) = 1 after ordering, since
ordering may change the value of complex eigenvalues
(especially if the eigenvalue is ill-conditioned); in this
case info is set to N+3.
Expand Down Expand Up @@ -1670,8 +1654,8 @@ EOF
$P(w),
&tmp_work[0],
&lwork,
&tmp_rwork,
&lrwork,
&tmp_rwork,
&lrwork,
&tmp_iwork,
&liwork,
$P(info));
Expand Down Expand Up @@ -1924,9 +1908,9 @@ Doc => '
Complex version of L<PDL::LinearAlgebra::Real/gesvx>.

trans: Specifies the form of the system of equations:
= 0: A * X = B (No transpose)
= 0: A * X = B (No transpose)
= 1: A\' * X = B (Transpose)
= 2: A**H * X = B (Conjugate transpose)
= 2: A**H * X = B (Conjugate transpose)
');

pp_defc("sysv",
Expand Down Expand Up @@ -2321,7 +2305,7 @@ EOF
Doc=>'
=for ref

Solves overdetermined or underdetermined complex linear systems
Solves overdetermined or underdetermined complex linear systems
involving an M-by-N matrix A, or its conjugate-transpose.
Complex version of L<PDL::LinearAlgebra::Real/gels>.

Expand Down Expand Up @@ -2981,8 +2965,8 @@ EOF

Complex version of L<PDL::LinearAlgebra::Real/getrs>

Arguments
=========
Arguments
=========
trans: = 0: No transpose;
= 1: Transpose;
= 2: Conjugate transpose;
Expand Down Expand Up @@ -3112,15 +3096,15 @@ EOF
$P(B),
&(integer){$SIZE(n)},
$P(info));
',
',
Doc=>'

=for ref

Complex version of L<PDL::LinearAlgebra::Real/trtrs>

Arguments
=========
Arguments
=========
trans: = 0: No transpose;
= 1: Transpose;
= 2: Conjugate transpose;
Expand All @@ -3131,7 +3115,7 @@ Complex version of L<PDL::LinearAlgebra::Real/trtrs>
pp_defc("latrs",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)latrs)(char *uplo, char *trans, char *diag, char *
normin, integer *n, $GENERIC() *a, integer *lda, $GENERIC() *x,
normin, integer *n, $GENERIC() *a, integer *lda, $GENERIC() *x,
$GENERIC() *scale, $GENERIC() *cnorm, integer *info);
EOF
HandleBad => 0,
Expand Down Expand Up @@ -3172,8 +3156,8 @@ EOF

Complex version of L<PDL::LinearAlgebra::Real/latrs>

Arguments
=========
Arguments
=========
trans: = 0: No transpose;
= 1: Transpose;
= 2: Conjugate transpose;
Expand Down Expand Up @@ -3397,7 +3381,7 @@ EOF
pp_defc("ungqr",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)ungqr)(integer *m, integer *n, integer *k, $GENERIC() *
a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
integer *info);
EOF
HandleBad => 0,
Expand Down Expand Up @@ -3540,7 +3524,7 @@ EOF
pp_defc("unglq",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)unglq)(integer *m, integer *n, integer *k, $GENERIC() *
a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
integer *info);
EOF
HandleBad => 0,
Expand Down Expand Up @@ -3682,7 +3666,7 @@ EOF
pp_defc("ungql",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)ungql)(integer *m, integer *n, integer *k, $GENERIC() *
a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
integer *info);
EOF
HandleBad => 0,
Expand Down Expand Up @@ -3822,7 +3806,7 @@ EOF
pp_defc("ungrq",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)ungrq)(integer *m, integer *n, integer *k, $GENERIC() *
a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
integer *info);
EOF
HandleBad => 0,
Expand Down Expand Up @@ -4025,7 +4009,7 @@ Complex version of L<PDL::LinearAlgebra::Real/ormrz>. Here trans = 1 means conju
pp_defc("gehrd",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)gehrd)(integer *n, integer *ilo, integer *ihi,
$GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *work,
$GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *work,
integer *lwork, integer *info);
EOF
HandleBad => 0,
Expand Down Expand Up @@ -4064,7 +4048,7 @@ EOF
pp_defc("unghr",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)unghr)(integer *n, integer *ilo, integer *ihi,
$GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *work,
$GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *work,
integer *lwork, integer *info);
EOF
HandleBad => 0,
Expand Down Expand Up @@ -4110,7 +4094,7 @@ pp_defc("hseqr",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)hseqr)(char *job, char *compz, integer *n, integer *ilo,
integer *ihi, $GENERIC() *h__, integer *ldh, $GENERIC() *w,
$GENERIC() *z__, integer *ldz, $GENERIC() *work,
$GENERIC() *z__, integer *ldz, $GENERIC() *work,
integer *lwork, integer *info);
EOF
HandleBad => 0,
Expand Down Expand Up @@ -4172,7 +4156,7 @@ pp_defc("trevc",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)trevc)(char *side, char *howmny, logical *select,
integer *n, $GENERIC() *t, integer *ldt, $GENERIC() *vl, integer *
ldvl, $GENERIC() *vr, integer *ldvr, integer *mm, integer *m,
ldvl, $GENERIC() *vr, integer *ldvr, integer *mm, integer *m,
$GENERIC() *work, $GENERIC() *rwork, integer *info);
EOF
HandleBad => 0,
Expand Down Expand Up @@ -4214,7 +4198,7 @@ EOF
$P(VR),
&(integer){$SIZE(p)},
&mm,
$P(m),
$P(m),
$P(work) + $SIZE(n),
$P(work),
$P(info));
Expand All @@ -4224,7 +4208,7 @@ pp_defc("tgevc",
_decl => <<'EOF',
extern int FORTRAN($TFD(c,z)tgevc)(char *side, char *howmny, logical *select,
integer *n, $GENERIC() *a, integer *lda, $GENERIC() *b, integer *ldb,
$GENERIC() *vl, integer *ldvl, $GENERIC() *vr, integer *ldvr,
$GENERIC() *vl, integer *ldvl, $GENERIC() *vr, integer *ldvr,
integer *mm, integer *m, $GENERIC() *work, $GENERIC() *rwork, integer *info);
EOF
HandleBad => 0,
Expand Down Expand Up @@ -4266,7 +4250,7 @@ EOF
$P(VR),
&(integer){$SIZE(p)},
&mm,
$P(m),
$P(m),
$P(work)+2*$SIZE(n),
$P(work),
$P(info));
Expand Down Expand Up @@ -4455,8 +4439,8 @@ EOF

Complex version of L<PDL::LinearAlgebra::Real/gemm>.

Arguments
=========
Arguments
=========
transa: = 0: No transpose;
= 1: Transpose;
= 2: Conjugate transpose;
Expand Down Expand Up @@ -4517,8 +4501,8 @@ Doc=>'

Complex version of L<PDL::LinearAlgebra::Real/rmgemm>.

Arguments
=========
Arguments
=========
transa: = 0: No transpose;
= 1: Transpose;
= 2: Conjugate transpose;
Expand Down Expand Up @@ -4736,7 +4720,7 @@ EOF
Doc=>'
=for ref

Forms the dot product of two vectors, conjugating the first
Forms the dot product of two vectors, conjugating the first
vector.
');

Expand Down Expand Up @@ -4835,7 +4819,7 @@ EOF
$P(a),
$P(b),
$P(c),
$P(s)
$P(s)
);
');

Expand Down Expand Up @@ -4906,8 +4890,8 @@ EOF
Code => '
int i,j,k;
$GENERIC() tr[2], b[2];
//$GENERIC() *tmp;
char ptrans = \'N\';
//$GENERIC() *tmp;
char ptrans = \'N\';
$GENERIC() alpha[2] = {1,0};
$GENERIC() beta[2] = {0,0};
loop(n0,n1) %{
Expand Down
13 changes: 5 additions & 8 deletions Complex/selectfunc.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern Core *PDL;
ENTER; SAVETMPS; PUSHMARK(sp); \
SV *svpdl = sv_newmortal(); \
PDL->SetSV_PDL(svpdl, pdlvar); \
svpdl = sv_bless(svpdl, bless_stash); /* bless in PDL::Complex */ \
svpdl = sv_bless(svpdl, bless_stash); \
XPUSHs(svpdl); \
PUTBACK;

Expand All @@ -37,13 +37,10 @@ int xerbla_(char *sub, int *info) { return 0; }
{ \
dSP; \
PDL_Indx odims[] = {0}; \
PDL_Indx pc_dims[] = {2}; \
SV *pcv = perl_get_sv("PDL::Complex::VERSION", 0); \
char use_native = !pcv || !SvOK(pcv); \
PDL_Indx *dims = use_native ? NULL : pc_dims; \
PDL_Indx ndims = use_native ? 0 : sizeof(pc_dims)/sizeof(pc_dims[0]); \
int type_add = use_native ? PDL_CF - PDL_F : 0; \
HV *bless_stash = gv_stashpv(use_native ? "PDL" : "PDL::Complex", 0); \
PDL_Indx *dims = NULL; \
PDL_Indx ndims = 0; \
int type_add = PDL_CF - PDL_F; \
HV *bless_stash = gv_stashpv("PDL", 0); \
init \
int count = perl_call_sv(letter ## select_func, G_SCALAR); \
SPAGAIN; \
Expand Down
1 change: 0 additions & 1 deletion MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ t/1.t
t/cgtsv.t
t/common.pl
t/gtsv.t
t/legacy.t
Trans/Makefile.PL
Trans/selectfunc.c
Trans/trans.pd
Loading

0 comments on commit 9159e3a

Please sign in to comment.