Full_Name: Peter Fortini
Version: 2.0.1
OS: Windows 2000
Submission from: (NULL) (65.246.187.164)
When the imaginary part of the argument is very large, the complex tangent
function returns 0+NaNi. For example, tan(1+1000i)=0+NaNi; it should be 0+1i
Easy to fix in complex.c, as the original NaN came from division of sinh and
cosh that had reached machine infinity.
static void z_tan(Rcomplex *r, Rcomplex *z)
{
double x2, y2, den;
x2 = 2.0 * z->r;
y2 = 2.0 * z->i;
den = cos(x2) + cosh(y2);
r->r = sin(x2)/den;
/* any limit above about log(DBL_EPSILON) will do */
if (fabs(r->i) < 40.0)
r->i = sinh(y2)/den;
else
r->i = 1.0;
}
On Thu, 7 Apr 2005 pfortini@wyeth.com wrote:> > static void z_tan(Rcomplex *r, Rcomplex *z) > { > double x2, y2, den; > x2 = 2.0 * z->r; > y2 = 2.0 * z->i; > den = cos(x2) + cosh(y2); > r->r = sin(x2)/den; > /* any limit above about log(DBL_EPSILON) will do */ > if (fabs(r->i) < 40.0)You need z->i (or y2) here, r->i hasn't been initialized yet. Otherwise, yes. -thomas
Possibly Parallel Threads
- complex NA's match(), etc: not back-compatible change proposal
- complex NA's match(), etc: not back-compatible change proposal
- Breaking Change in Rcomplex Layout?
- Calling FORTRAN function from R issue?
- complex NA's match(), etc: not back-compatible change proposal