@@ -489,20 +489,25 @@ works with native-complex data.
489489 ($yr, $yi) = polyval($cr, $ci, $xr, $xi);
490490',);
491491
492- pp_def('csqrt',
493- GenericTypes => $AF,
494- Pars => 'i(); complex [o] o()',
495- Doc => <<'EOF',
496- Take the complex square root of a number choosing that with
497- non-negative real part, i.e., a square root with a branch cut
498- 'infinitesimally' below the negative real axis, the standard choice.
492+ sub cequiv {
493+ my ($func, $ref) = @_;
494+ pp_def("c$func",
495+ GenericTypes => $AF,
496+ Pars => 'i(); complex [o] o()',
497+ Doc => <<EOF,
498+ =for ref\n
499+ Takes real or complex data, returns the complex C<$func>.\n
500+ Added in 2.099.
499501EOF
500- Code => q{
501- $TFDEGCH(PDL_CFloat,PDL_CDouble,PDL_CLDouble,PDL_CFloat,PDL_CDouble,PDL_CLDouble) tmp=$i();
502- tmp=csqrt(tmp);
503- $o() = tmp;
504- },
505- );
502+ Code => pp_line_numbers(__LINE__, <<EOF),
503+ \$TFDEGCH(PDL_CFloat,PDL_CDouble,PDL_CLDouble,PDL_CFloat,PDL_CDouble,PDL_CLDouble) tmp = \$i();
504+ tmp = c$func(tmp);
505+ \$o() = tmp;
506+ EOF
507+ );
508+ }
509+
510+ cequiv($_) for qw(sqrt log acos asin acosh atanh);
506511
507512pp_def('csqrt_up',
508513 GenericTypes => $AF,
@@ -512,23 +517,16 @@ Take the complex square root of a number choosing that whose imaginary
512517part is not negative, i.e., it is a square root with a branch cut
513518'infinitesimally' below the positive real axis.
514519EOF
515- Code => q{
516- $TFDEGCH(PDL_CFloat,PDL_CDouble,PDL_CLDouble,PDL_CFloat,PDL_CDouble,PDL_CLDouble) tmp=$i();
517- tmp=csqrt(tmp);
518- if(cimag(tmp)<0){
519- tmp = -tmp;
520- }
521- $o() = tmp;
522- },
520+ Code => pp_line_numbers(__LINE__, <<'EOF'),
521+ $TFDEGCH(PDL_CFloat,PDL_CDouble,PDL_CLDouble,PDL_CFloat,PDL_CDouble,PDL_CLDouble) tmp = $i();
522+ tmp = csqrt(tmp);
523+ if (cimag(tmp)<0)
524+ tmp = -tmp;
525+ $o() = tmp;
526+ EOF
523527);
524528
525529pp_addpm({At=>'Bot'},<<'EOD');
526-
527- =head1 BUGS
528-
529- Hasn't been tested on all platforms to ensure Cephes
530- versions are picked up automatically and used correctly.
531-
532530=head1 AUTHOR
533531
534532Copyright (C) R.J.R. Williams 1997 (rjrw@ast.leeds.ac.uk), Karl Glazebrook
0 commit comments