/* qexpm1.c
*
* Exponential function check routine
*
*
*
* SYNOPSIS :
*
* int qexpm1 ( x , y ) ;
* QELT * x , * y ;
*
* qexpm1 ( x , y ) ;
*
*
*
* DESCRIPTION :
*
* Returns e ( 2 . 71828 . . . ) raised to the x power , minus 1 .
*
*/
/*
Cephes Math Library Release 2 . 3 : January , 1995
Copyright 1984 , 1995 by Stephen L . Moshier
*/
#include "qhead.h"
extern QELT qlog2[], qhalf[], qone[];
int qtanh();
/* C1 + C2 = ln 2 */
#if WORDSIZE == 16
static QELT C1[NQ] = {0 ,EXPONE-1 ,0 ,0 xb172, 0 x17f7};
#if 0
#if NQ > 12
static QELT C2[NQ] = {
0 x0000,EXPONE-33 ,0 x0000,0 xd1cf,0 x79ab,0 xc9e3,0 xb398,0 x03f2,
0 xf6af,0 x40f3,0 x4326,0 x7298,0 xb62d,0 x8a0d,0 x175b,0 x8baa,
0 xfa2b,0 xe7b8,0 x7620,0 x6deb,0 xac98,0 x5595,0 x52fb,0 x4afa};
#else /* not NQ > 12 */
static QELT C2[NQ] = {
0 x0000,EXPONE-33 ,0 x0000,0 xd1cf,0 x79ab,0 xc9e3,0 xb398,0 x03f2,
0 xf6af,0 x40f3,0 x4326,0 x7299};
#endif /* not NQ > 12 */
#endif /* 0 */
#else /* WORDSIZE 32 */
static QELT C1[NQ] = {0 ,EXPONE-1 ,0 ,0 xb17217f7};
#if 0
static QELT C2[NQ] = {
0 x0000,EXPONE-33 ,0 x0000,0 xd1cf79ab,0 xc9e3b398,0 x03f2f6af,0 x40f34326,0 x7298b62d,
0 x8a0d175b,0 x8baafa2b,0 xe7b87620,0 x6debac98,0 x559552fb,0 x4afa1b11};
#endif /* 0 */
#endif /* WORDSIZE 32 */
int qexpm1( x, y )
QELT *x, *y;
{
QELT num[NQ], den[NQ], x2[NQ];
/* goto use_exp; */
qmov (C1, num);
num[1 ] -= 1 ;
if (qcmp(x, num) > 0 )
goto use_exp;
qmov(x, den);
qneg(den);
if (qcmp(den, num) > 0 )
goto use_exp;
qmov(x, x2);
x2[1 ] -= 1 ; /* x/2 */
qtanh( x2, x2 ); /* tanh( x/2 ) */
/* 2 tanh / (1 - tanh) */
qmov( x2, num ); /* 2 tanh */
num[1 ] += 1 ;
qneg( x2 );
qadd( x2, qone, den ); /* 1 - tanh */
qdiv( den, num, y ); /* (2 tanh)/(1 - tanh) */
return 0 ;
use_exp:
qexp(x, num);
qsub(qone, num, y);
return 0 ;
}
Messung V0.5 in Prozent C=83 H=72 G=77
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-06-14)
¤
*© Formatika GbR, Deutschland