Skip to content

Commit 60a4ae6

Browse files
committed
Use $TFDEGCH in csqrt routines. Rename _csqrt_right to csqrt
1 parent 768055a commit 60a4ae6

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

lib/PDL/Ops.pd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,16 +422,16 @@ EOF
422422
Code => '$c() = $r() + $i() * I;'
423423
);
424424

425-
pp_def('csqrt_right',
425+
pp_def('csqrt',
426426
GenericTypes => $AF,
427427
Pars => 'i(); complex [o] o()',
428428
Doc => <<'EOF',
429429
Take the complex square root of a number choosing that with
430-
not negative real part, i.e., a square root with a branch cut
431-
'infinitesimally' below the negative real axis.
430+
non-negative real part, i.e., a square root with a branch cut
431+
'infinitesimally' below the negative real axis, the standard choice.
432432
EOF
433433
Code => q{
434-
PDL_IF_GENTYPE_REAL(complex,$GENERIC()) tmp=$i();
434+
$TFDEGCH(PDL_CFloat,PDL_CDouble,PDL_CLDouble,PDL_CFloat,PDL_CDouble,PDL_CLDouble) tmp=$i();
435435
tmp=csqrt(tmp);
436436
$o() = tmp;
437437
},
@@ -446,7 +446,7 @@ part is not negative, i.e., it is a square root with a branch cut
446446
'infinitesimally' below the positive real axis.
447447
EOF
448448
Code => q{
449-
PDL_IF_GENTYPE_REAL(complex,$GENERIC()) tmp=$i();
449+
$TFDEGCH(PDL_CFloat,PDL_CDouble,PDL_CLDouble,PDL_CFloat,PDL_CDouble,PDL_CLDouble) tmp=$i();
450450
tmp=csqrt(tmp);
451451
if(cimag(tmp)<0){
452452
tmp = -tmp;

t/ops.t

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -112,32 +112,32 @@ if ($can_complex_power) {
112112
is $pa->at(0), '16', 'sqrt orig value ok';
113113
}
114114

115-
{ # csqrt_right
115+
{ # csqrt
116116
my $pi=4*atan2(1,1);
117117
my $eiO = exp(i()*(sequence(8)-3)*$pi/4);
118118
my $eiO2 = exp(i()*(sequence(8)-3)*$pi/8);
119-
my $sqrt=csqrt_right($eiO);
120-
is_pdl($sqrt, $eiO2, "csqrt_right of complex");
121-
my $i=csqrt_right(-1);
122-
is_pdl($i, i(), "csqrt_right of real -1");
119+
my $sqrt=csqrt($eiO);
120+
is_pdl($sqrt, $eiO2, "csqrt of complex");
121+
my $i=csqrt(-1);
122+
is_pdl($i, i(), "csqrt of real -1");
123123
my $squares="-9 -4 -1 0 1 4 9";
124124
my $roots="3i 2i i 0 1 2 3";
125-
my $lsqrt=long($squares)->csqrt_right;
126-
is_pdl($lsqrt, cdouble($roots), "csqrt_right of long");
127-
my $llsqrt=longlong($squares)->csqrt_right;
128-
is_pdl($llsqrt, cdouble($roots), "csqrt_right of longlong");
129-
my $fsqrt=float($squares)->csqrt_right;
130-
is_pdl($fsqrt, cfloat($roots), "csqrt_right of float");
131-
my $dsqrt=double($squares)->csqrt_right;
132-
is_pdl($dsqrt,cdouble($roots), "csqrt_right of double");
133-
my $ldsqrt=ldouble($squares)->csqrt_right;
134-
is_pdl($ldsqrt, cldouble($roots), "csqrt_right of ldouble");
135-
my $cfsqrt=cfloat($squares)->csqrt_right;
136-
is_pdl($cfsqrt, cfloat($roots), "csqrt_right of cfloat");
137-
my $cdsqrt=cdouble($squares)->csqrt_right;
138-
is_pdl($cdsqrt,cdouble($roots), "csqrt_right of cdouble");
139-
my $cldsqrt=cldouble($squares)->csqrt_right;
140-
is_pdl($cldsqrt,cldouble($roots), "csqrt_right of cldouble");
125+
my $lsqrt=long($squares)->csqrt;
126+
is_pdl($lsqrt, cdouble($roots), "csqrt of long");
127+
my $llsqrt=longlong($squares)->csqrt;
128+
is_pdl($llsqrt, cdouble($roots), "csqrt of longlong");
129+
my $fsqrt=float($squares)->csqrt;
130+
is_pdl($fsqrt, cfloat($roots), "csqrt of float");
131+
my $dsqrt=double($squares)->csqrt;
132+
is_pdl($dsqrt,cdouble($roots), "csqrt of double");
133+
my $ldsqrt=ldouble($squares)->csqrt;
134+
is_pdl($ldsqrt, cldouble($roots), "csqrt of ldouble");
135+
my $cfsqrt=cfloat($squares)->csqrt;
136+
is_pdl($cfsqrt, cfloat($roots), "csqrt of cfloat");
137+
my $cdsqrt=cdouble($squares)->csqrt;
138+
is_pdl($cdsqrt,cdouble($roots), "csqrt of cdouble");
139+
my $cldsqrt=cldouble($squares)->csqrt;
140+
is_pdl($cldsqrt,cldouble($roots), "csqrt of cldouble");
141141
}
142142

143143
{ # csqrt_up

0 commit comments

Comments
 (0)