Exemple #1
0
qcomplex __cqexp(long double zqreal, long double zqimag)
{
  long double expx;
  qcomplex result;

  expx = __qexp(zqreal);
  result.qreal = expx*__qcos(zqimag);
  result.qimag = expx*__qsin(zqimag);
  return result;
}
Exemple #2
0
long double __q_cosd(long double *x)
{
ldquad	u;
int	n;
double	dn;
long double	result;

	u.ld = *x;

	if ( u.q.hi != u.q.hi )
	{
		/* x is a NaN; return a quiet NaN */

#ifdef _IP_NAN_SETS_ERRNO

		*__errnoaddr = EDOM;
#endif
		return ( __libm_qnan_ld );
	}

	if ( __qabs(*x) == __libm_inf_ld )
	{
		/* x is +/-Inf; return a quiet NaN */

		*__errnoaddr = EDOM;

		return ( __libm_qnan_ld );
	}

	if ( *x == 0.0L )
		return ( 1.0L );

	/* reduce arg to +/- 360 degrees */

	u.ld = __qmod(u.ld, 360.0L);

	/* next, reduce to +/-45.0 */

	if ( __qabs(u.ld) <= 45.0L )
	{
		n = 0;
	}
	else
	{
		dn = u.q.hi*rninety.d;
		n = ROUND(dn);
		dn = n;

		u.ld = u.ld - dn*90.0L;
	}

	/* convert x to radians */

	u.ld *= radspdeg.ld;

	if ( n&1)
	{
		if ( n&2 )
		{
			/*
			 *  n%4 = 3
			 *  result is sin(u)
			 */

			result = __qsin(u.ld);
		}
		else
		{
			/*
			 *  n%4 = 1
			 *  result is -sin(u)
			 */

			result = -__qsin(u.ld);
		}

		return ( result );
	}

	if ( n&2 )
	{
		/*
		 *  n%4 = 2
		 *  result is -cos(u)
		 */

		result = -__qcos(u.ld);
	}
	else
	{
		/*
		 *  n%4 = 0
		 *  result is cos(u)
		 */

		result = __qcos(u.ld);
	}

	return( result );
}