Re: [Pdl-devel] PDL atan defaults to float

2015-11-18 Thread kmx
Just for record (and future hackers trying to re-think this) the trouble maker is AFAIK: int pdl_whichdatatype_double (NV nv) in Basic/Core/pdlcore.c -- kmx On 19.11.2015 1:08, dhunt wrote: Hi Chris: Understand that for my part, I've already worked around this (mis)feature. We should not r

Re: [Pdl-devel] PDL atan defaults to float

2015-11-18 Thread dhunt
Hi Chris: Understand that for my part, I've already worked around this (mis)feature. We should not rush to make a fix that would have unintended consequences. Thanks for all your work on PDL! --Doug On 11/18/15 4:53 PM, Chris Marshall wrote: The problem is how to avoid data type size by hav

Re: [Pdl-devel] PDL atan defaults to float

2015-11-18 Thread Chris Marshall
The problem is how to avoid data type size by having a byte image be converted to a double image by adding the value 2 to it. Making an image frame 8x bigger would be surprising and annoying in that case. As for how perl does it, I think that perl uses IVs to long (except when it is a long long)

Re: [Pdl-devel] PDL atan defaults to float

2015-11-18 Thread Craig DeForest
I like the idea of autopromoting all IVs to long and all NVs to double. After all, that’s how Perl stores and treats them. I don’t like the idea of setting this parameter anywhere other than at compile time. Action at a distance is madness at a distance… > On Nov 18, 2015, at 3:47 PM, Chris

Re: [Pdl-devel] PDL atan defaults to float

2015-11-18 Thread dhunt
Hi Craig: Thanks for exploring this further. I'm glad it's a cool bug and not a boring bug or a nerdy bug! --Doug On 11/18/15 2:58 PM, Craig DeForest wrote: Yes, I believe this is a Bug in the conversion code logic. Currently we use the smallest possible type that can contain a value. Valu

Re: [Pdl-devel] PDL atan defaults to float

2015-11-18 Thread Chris Marshall
I agree that the this is a surprising result---even if correct by our current implementation. Maybe the default for NV perl scalars should be type PDL_Double. Maybe a perl scalar promotion setting that could set a default value, double or other specific type, smallest size, or ... --Chris On We

Re: [Pdl-devel] PDL atan defaults to float

2015-11-18 Thread Craig DeForest
Yes, I believe this is a Bug in the conversion code logic. Currently we use the smallest possible type that can contain a value. Values that fit in a float get promoted to float and those that require a double get promoted to double. Here’s a four-atan trial, showing the autopromotion using a

Re: [Pdl-devel] PDL atan defaults to float

2015-11-18 Thread Chris Marshall
I think we may need something like an option to enable/disable forced conversion of perl scalars to double piddles. --Chris On Wed, Nov 18, 2015 at 3:03 PM, Chris Marshall wrote: > Hi Doug- > > I think the problem is only when > a perl scalar is the input to atan(). > The top two cases are the

Re: [Pdl-devel] PDL atan defaults to float

2015-11-18 Thread Chris Marshall
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, Dou

[Pdl-devel] PDL atan defaults to float

2015-11-18 Thread Douglas Hunt
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,