Hi Doug-

I think the problem is only when
a perl scalar is the input to atan().
The top two cases are the expected
result.  Maybe the logic in the type
conversion is off.  You don't say
what version of PDL but I see the
same output from PDL-2.014_02.

--Chris


On Wed, Nov 18, 2015 at 1:29 PM, Douglas Hunt <dh...@ucar.edu> wrote:

> Hi all:  I just noticed a thing which caused me some trouble.
>
> The PDL 'atan' function defaults to 'float' precision instead of the
> more natural 'double':
>
> use PDL;
>
> my $a1 = atan(double(2379.0)/double(1024.0));
> my $a2 = atan(float(2379.0)/float(1024.0));
> my $a3 = atan(2379.0/1024.0);
>
> print "$a1, $a2, $a3\n";
>
> This prints:
> 1.1643329321713, 1.1643328666687, 1.1643328666687
>
> This feature causes a problem when porting to/from C as the C atan
> function operates on doubles.
>
> I think this traces down to Basic::Math in the math.pd file:
>
> my (@ufuncs1) = qw(acos asin atan cosh sinh tan tanh); # F,D only
> ...
> my $func;
> foreach $func (@ufuncs1) {
>      pp_def($func,
>             HandleBad => 1,
>             NoBadifNaN => 1,
>             GenericTypes => ['F','D'],
>             Pars => 'a(); [o]b();',
>             Inplace => 1,
>             Doc => inplace_doc( $func ),
>             Code => code_ufunc($func),
>             BadCode => badcode_ufunc($func),
>             );
> }
>
> Note that GenericTypes isF, D instead of D, F.
>
> I would go so far to say that this is a bug, as the default pdl type is
> double as in:
>
> my $pdl = pdl(4,5,6);
> p $pdl->info
> PDL: Double D [3]
>
> Regards,
>
>    Doug Hunt
>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> pdl-devel mailing list
> pdl-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pdl-devel
>
------------------------------------------------------------------------------
_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel

Reply via email to