The R Project SVN R

Rev

Rev 51316 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 51316 Rev 51743
Line 210... Line 210...
210
   against MSVCRT's pow, and gets (0+0i)^Y as 0+0i for all Y */
210
   against MSVCRT's pow, and gets (0+0i)^Y as 0+0i for all Y */
211
static double complex mycpow (double complex X, double complex Y)
211
static double complex mycpow (double complex X, double complex Y)
212
{
212
{
213
    double complex Res; int k;
213
    double complex Res; int k;
214
    if (X == 0.0) {
214
    if (X == 0.0) {
-
 
215
	if(cimag(Y) == 0.0){
215
	__real__ Res = R_pow(0.0, __real__ Y);
216
	    __real__ Res = R_pow(0.0, __real__ Y);
216
	__imag__ Res = 0.0;
217
	    __imag__ Res = 0.0;
-
 
218
	} else {
-
 
219
	    __real__ Res = R_NaN;
-
 
220
	    __imag__ Res = R_NaN;
-
 
221
	}
217
    } else if (__imag__ Y == 0.0 && __real__ Y == (k = (int)__real__ Y)
222
    } else if (__imag__ Y == 0.0 && __real__ Y == (k = (int)__real__ Y)
218
	       && abs(k) <= 65536) {
223
	       && abs(k) <= 65536) {
219
	return R_cpow_n(X, k);
224
	return R_cpow_n(X, k);
220
    } else {
225
    } else {
221
	double rho, r,i, theta;
226
	double rho, r,i, theta;
Line 244... Line 249...
244
*/
249
*/
245
 
250
 
246
static double complex mycpow (double complex X, double complex Y)
251
static double complex mycpow (double complex X, double complex Y)
247
{
252
{
248
    double iY = cimag(Y);
253
    double iY = cimag(Y);
249
    if (iY == 0) {/* X ^ <real> */
254
    if (iY == 0.0) {/* X ^ <real> */
250
	double complex Z; int k;
255
	double complex Z; int k;
251
	if (X == 0.) {
256
	if (X == 0.0) {
252
	    Z = R_pow(0., creal(Y));
257
	    Z = R_pow(0., creal(Y));
253
	} else if(creal(Y) == (k = (int)creal(Y)) && abs(k) <= 65536) {
258
	} else if(creal(Y) == (k = (int)creal(Y)) && abs(k) <= 65536) {
254
	    Z = R_cpow_n(X, k);
259
	    Z = R_cpow_n(X, k);
255
	} else {
260
	} else {
256
	    Z = cpow(X, Y);
261
	    Z = cpow(X, Y);