Ah, I see. That rationale makes sense.
Paul
From: NumPy-Discussion
on behalf of
Marten van Kerkwijk
Reply-To: Discussion of Numerical Python
Date: Tuesday, May 8, 2018 at 2:40 PM
To: Discussion of Numerical Python
Subject: Re: [Numpy-discussion] sinc always returns double precision
It is actually a bit more subtle (annoyingly so), the reason you get a
float64 is that you pass in a scalar, and for scalars, the dtype of
`pi` indeed "wins", as there is little reason to possibly loose
precision. If you pass in an array instead, then you do get
`float32`:
```
np.sinc(np.array([1.
Sinc seems to always return double precision, even when the input is single
precision:
In [125]: np.sinc(np.float32(0)).dtype
Out[125]: dtype('float64')
Is this desired behavior? I’m guessing the promotion occurs in the
multiplication by pi:
y = pi * where(x == 0, 1.0e-20, x)
Pa