//#TPT-Directive ElementHeader Element_GRID static int update(UPDATE_FUNC_ARGS) int Element_GRID::update(UPDATE_FUNC_ARGS) { int r, rx, ry, ri; for(ri = 0; ri <= 10; ri++) { rx = (rand()%21)-10; ry = (rand()%21)-10; if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; if (!r) r = sim->photons[y+ry][x+rx]; if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID) && (sim->elements[r&0xFF].Properties & TYPE_ENERGY) && parts[i].life==1) { parts[i].tmp = 10; if(parts[i].tmp2 == 0) { parts[r>>8].vx += isign(rx)*((parts[i].tmp)/10.0f); parts[r>>8].vy += isign(ry)*((parts[i].tmp)/10.0f); } if(parts[i].tmp2 == 1 && (r&0xFF)==PT_ELEC||PT_PHOT||PT_NEUT) { parts[r>>8].vx += isign(rx)*((parts[i].tmp)/10.0f); parts[r>>8].vy += isign(ry)*((parts[i].tmp)/10.0f); }
void PreviewView::OnTick(float dt) { if(addCommentBox) { ui::Point positionDiff = ui::Point(commentBoxPositionX, commentBoxPositionY)-addCommentBox->Position; ui::Point sizeDiff = ui::Point(commentBoxSizeX, commentBoxSizeY)-addCommentBox->Size; if(positionDiff.X!=0) { int xdiff = positionDiff.X/5; if(xdiff == 0) xdiff = 1*isign(positionDiff.X); addCommentBox->Position.X += xdiff; } if(positionDiff.Y!=0) { int ydiff = positionDiff.Y/5; if(ydiff == 0) ydiff = 1*isign(positionDiff.Y); addCommentBox->Position.Y += ydiff; } if(sizeDiff.X!=0) { int xdiff = sizeDiff.X/5; if(xdiff == 0) xdiff = 1*isign(sizeDiff.X); addCommentBox->Size.X += xdiff; addCommentBox->Invalidate(); commentBoxAutoHeight(); //make sure textbox height is correct after resizes addCommentBox->resetCursorPosition(); //make sure cursor is in correct position after resizes } if(sizeDiff.Y!=0) { int ydiff = sizeDiff.Y/5; if(ydiff == 0) ydiff = 1*isign(sizeDiff.Y); addCommentBox->Size.Y += ydiff; addCommentBox->Invalidate(); } } c->Update(); if (doError) { ErrorMessage::Blocking("Error loading save", doErrorMessage); c->Exit(); } }
//#TPT-Directive ElementHeader Element_REPL static int update(UPDATE_FUNC_ARGS) int Element_REPL::update(UPDATE_FUNC_ARGS) { int r, rx, ry, ri; for(ri = 0; ri <= 10; ri++) { rx = (rand()%21)-10; ry = (rand()%21)-10; if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; if (!r) r = sim->photons[y+ry][x+rx]; if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)){ parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f); parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); } }
void PreviewView::OnTick(float dt) { if(addCommentBox) { ui::Point positionDiff = ui::Point(commentBoxPositionX, commentBoxPositionY)-addCommentBox->Position; ui::Point sizeDiff = ui::Point(commentBoxSizeX, commentBoxSizeY)-addCommentBox->Size; if(positionDiff.X!=0) { int xdiff = positionDiff.X/5; if(xdiff == 0) xdiff = 1*isign(positionDiff.X); addCommentBox->Position.X += xdiff; } if(positionDiff.Y!=0) { int ydiff = positionDiff.Y/5; if(ydiff == 0) ydiff = 1*isign(positionDiff.Y); addCommentBox->Position.Y += ydiff; } if(sizeDiff.X!=0) { int xdiff = sizeDiff.X/5; if(xdiff == 0) xdiff = 1*isign(sizeDiff.X); addCommentBox->Size.X += xdiff; addCommentBox->Invalidate(); } if(sizeDiff.Y!=0) { int ydiff = sizeDiff.Y/5; if(ydiff == 0) ydiff = 1*isign(sizeDiff.Y); addCommentBox->Size.Y += ydiff; addCommentBox->Invalidate(); } } c->Update(); }
/*--------------------------------------------------------------------------*/ int nint(double f) /*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/ { int i; double df; /*..........................................................................*/ i=(int)f; df=f-(double)i; if (fabs(df) > .5) i=i+isign(df); return i; }
void LoginView::OnTick(float dt) { //if(targetSize != Size) { ui::Point difference = targetSize-Size; if(difference.X!=0) { int xdiff = difference.X/5; if(xdiff == 0) xdiff = 1*isign(difference.X); Size.X += xdiff; } if(difference.Y!=0) { int ydiff = difference.Y/5; if(ydiff == 0) ydiff = 1*isign(difference.Y); Size.Y += ydiff; } loginButton->Position.Y = Size.Y-17; cancelButton->Position.Y = Size.Y-17; } }
/* * Output a reasonable looking status field. * But if "status" is ignored and doign, forget it. */ static void statusput( register struct message *mp, register FILE *obuf, int doign, int (*fp)(const char *, FILE *)) { char statout[12]; if (doign && isign("status", 0)) return; if ((mp->m_flag & (MNEW|MREAD)) == MNEW) return; strcpy(statout, "Status: "); if (mp->m_flag & MREAD) strcat(statout, "R"); if ((mp->m_flag & MNEW) == 0) strcat(statout, "O"); strcat(statout, "\n"); (*fp)(statout, obuf); }
/* * Send message described by the passed pointer to the * passed output buffer. Return -1 on error. * Adjust the status: field if need be. * If doign is given, suppress ignored header fields. * prefix is a string to prepend to each output line. */ int sendmessage(struct message *mp, FILE *obuf, struct ignoretab *doign, char *prefix) { long count; FILE *ibuf; char *cp, *cp2, line[LINESIZE]; int ishead, infld, ignoring, dostat, firstline; int c = 0, length, prefixlen; /* * Compute the prefix string, without trailing whitespace */ if (prefix != NULL) { cp2 = 0; for (cp = prefix; *cp != '\0'; cp++) if (*cp != ' ' && *cp != '\t') cp2 = cp; prefixlen = cp2 == NULL ? 0 : cp2 - prefix + 1; } ibuf = setinput(mp); count = mp->m_size; ishead = 1; dostat = doign == 0 || !isign("status", doign); infld = 0; firstline = 1; /* * Process headers first */ while (count > 0 && ishead) { if (fgets(line, sizeof(line), ibuf) == NULL) break; count -= length = strlen(line); if (firstline) { /* * First line is the From line, so no headers * there to worry about */ firstline = 0; ignoring = doign == ignoreall; } else if (line[0] == '\n') { /* * If line is blank, we've reached end of * headers, so force out status: field * and note that we are no longer in header * fields */ if (dostat) { statusput(mp, obuf, prefix); dostat = 0; } ishead = 0; ignoring = doign == ignoreall; } else if (infld && (line[0] == ' ' || line[0] == '\t')) { /* * If this line is a continuation (via space or tab) * of a previous header field, just echo it * (unless the field should be ignored). * In other words, nothing to do. */ } else { /* * Pick up the header field if we have one. */ for (cp = line; (c = *cp++) != '\0' && c != ':' && !isspace((unsigned char)c);) ; cp2 = --cp; while (isspace((unsigned char)*cp++)) ; if (cp[-1] != ':') { /* * Not a header line, force out status: * This happens in uucp style mail where * there are no headers at all. */ if (dostat) { statusput(mp, obuf, prefix); dostat = 0; } if (doign != ignoreall) /* add blank line */ (void)putc('\n', obuf); ishead = 0; ignoring = 0; } else { /* * If it is an ignored field and * we care about such things, skip it. */ *cp2 = '\0'; /* temporarily null terminate */ if (doign && isign(line, doign)) ignoring = 1; else if ((line[0] == 's' || line[0] == 'S') && strcasecmp(line, "status") == 0) { /* * If the field is "status," go compute * and print the real Status: field */ if (dostat) { statusput(mp, obuf, prefix); dostat = 0; } ignoring = 1; } else { ignoring = 0; *cp2 = c; /* restore */ } infld = 1; } } if (!ignoring) { /* * Strip trailing whitespace from prefix * if line is blank. */ if (prefix != NULL) { if (length > 1) fputs(prefix, obuf); else (void)fwrite(prefix, sizeof(*prefix), prefixlen, obuf); } (void)fwrite(line, sizeof(*line), length, obuf); if (ferror(obuf)) return (-1); } } /* * Copy out message body */ if (doign == ignoreall) count--; /* skip final blank line */ if (prefix != NULL) while (count > 0) { if (fgets(line, sizeof(line), ibuf) == NULL) { c = 0; break; } count -= c = strlen(line); /* * Strip trailing whitespace from prefix * if line is blank. */ if (c > 1) fputs(prefix, obuf); else (void)fwrite(prefix, sizeof(*prefix), prefixlen, obuf); (void)fwrite(line, sizeof(*line), c, obuf); if (ferror(obuf)) return (-1); } else while (count > 0) { c = count < LINESIZE ? count : LINESIZE; if ((c = fread(line, sizeof(*line), c, ibuf)) <= 0) break; count -= c; if (fwrite(line, sizeof(*line), c, obuf) != c) return (-1); } if (doign == ignoreall && c > 0 && line[c - 1] != '\n') /* no final blank line */ if ((c = getc(ibuf)) != EOF && putc(c, obuf) == EOF) return (-1); return (0); }
/* * Send message described by the passed pointer to the * passed output buffer. Return -1 on error. * Adjust the status: field if need be. * If doign is given, suppress ignored header fields. * prefix is a string to prepend to each output line. */ int sendmessage(struct message *mp, FILE *obuf, struct ignoretab *doign, char *prefix) { int count; FILE *ibuf; char line[LINESIZE]; char visline[4 * LINESIZE - 3]; int ishead, infld, ignoring = 0, dostat, firstline; char *cp, *cp2; int c = 0; int length; int prefixlen = 0; int rval; int dovis; struct sigaction act, saveint; sigset_t oset; sendsignal = 0; rval = -1; dovis = isatty(fileno(obuf)); sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART; act.sa_handler = sendint; (void)sigaction(SIGINT, &act, &saveint); (void)sigprocmask(SIG_UNBLOCK, &intset, &oset); /* * Compute the prefix string, without trailing whitespace */ if (prefix != NULL) { cp2 = 0; for (cp = prefix; *cp; cp++) if (*cp != ' ' && *cp != '\t') cp2 = cp; prefixlen = cp2 == 0 ? 0 : cp2 - prefix + 1; } ibuf = setinput(mp); count = mp->m_size; ishead = 1; dostat = doign == 0 || !isign("status", doign); infld = 0; firstline = 1; /* * Process headers first */ while (count > 0 && ishead) { if (fgets(line, sizeof(line), ibuf) == NULL) break; count -= length = strlen(line); if (firstline) { /* * First line is the From line, so no headers * there to worry about */ firstline = 0; ignoring = doign == ignoreall; } else if (line[0] == '\n') { /* * If line is blank, we've reached end of * headers, so force out status: field * and note that we are no longer in header * fields */ if (dostat) { if (statusput(mp, obuf, prefix) == -1) goto out; dostat = 0; } ishead = 0; ignoring = doign == ignoreall; } else if (infld && (line[0] == ' ' || line[0] == '\t')) { /* * If this line is a continuation (via space or tab) * of a previous header field, just echo it * (unless the field should be ignored). * In other words, nothing to do. */ } else { /* * Pick up the header field if we have one. */ for (cp = line; (c = *cp++) && c != ':' && !isspace(c);) ; cp2 = --cp; while (isspace(*cp++)) ; if (cp[-1] != ':') { /* * Not a header line, force out status: * This happens in uucp style mail where * there are no headers at all. */ if (dostat) { if (statusput(mp, obuf, prefix) == -1) goto out; dostat = 0; } if (doign != ignoreall) /* add blank line */ (void)putc('\n', obuf); ishead = 0; ignoring = 0; } else { /* * If it is an ignored field and * we care about such things, skip it. */ *cp2 = 0; /* temporarily null terminate */ if (doign && isign(line, doign)) ignoring = 1; else if (strcasecmp(line, "status") == 0) { /* * If the field is "status," go compute * and print the real Status: field */ if (dostat) { if (statusput(mp, obuf, prefix) == -1) goto out; dostat = 0; } ignoring = 1; } else { ignoring = 0; *cp2 = c; /* restore */ } infld = 1; } } if (!ignoring) { /* * Strip trailing whitespace from prefix * if line is blank. */ if (prefix != NULL) { if (length > 1) fputs(prefix, obuf); else (void)fwrite(prefix, sizeof(*prefix), prefixlen, obuf); } if (dovis) { length = strvis(visline, line, VIS_SAFE|VIS_NOSLASH); (void)fwrite(visline, sizeof(*visline), length, obuf); } else (void)fwrite(line, sizeof(*line), length, obuf); if (ferror(obuf)) goto out; } if (sendsignal == SIGINT) goto out; } /* * Copy out message body */ if (doign == ignoreall) count--; /* skip final blank line */ while (count > 0) { if (fgets(line, sizeof(line), ibuf) == NULL) { c = 0; break; } count -= c = strlen(line); if (prefix != NULL) { /* * Strip trailing whitespace from prefix * if line is blank. */ if (c > 1) fputs(prefix, obuf); else (void)fwrite(prefix, sizeof(*prefix), prefixlen, obuf); } /* * We can't read the record file (or inbox for recipient) * properly with 'From ' lines in the message body (from * forwarded messages or sentences starting with "From "), * so we will prepend those lines with a '>'. */ if (strncmp(line, "From ", 5) == 0) (void)fwrite(">", 1, 1, obuf); /* '>' before 'From ' */ if (dovis) { length = strvis(visline, line, VIS_SAFE|VIS_NOSLASH); (void)fwrite(visline, sizeof(*visline), length, obuf); } else (void)fwrite(line, sizeof(*line), c, obuf); if (ferror(obuf) || sendsignal == SIGINT) goto out; } if (doign == ignoreall && c > 0 && line[c - 1] != '\n') /* no final blank line */ if ((c = getc(ibuf)) != EOF && putc(c, obuf) == EOF) goto out; rval = 0; out: sendsignal = 0; (void)sigprocmask(SIG_SETMASK, &oset, NULL); (void)sigaction(SIGINT, &saveint, NULL); return(rval); }
//---------------------------------------------------------------------- // Lasv2 // SVD of a 2x2 real upper triangular matrix // [f g] = [cu -su]*[smax 0 ]*[ cv sv] // [0 h] [su cu] [ 0 smin] [-sv cv] // smax is the larger singular value and smin is the smaller // // "smin" and "smax" are singular values // "cv" and "sv" are the entries in the right singular vector matrix // "cu" and "su" are the entries in the left singular vector matrix // "f", "g", and "h" are the entries in the upper triangular matrix // // This code is translated from the FORTRAN code SLASV2 listed in // Z.Bai and J.Demmel, // "Computing the Generalized Singular Value Decomposition", // SIAM J. Sci. Comput., Vol. 14, No. 6, pp. 1464-1486, November 1993 //----------------------------------------------------------------------- void Lasv2(double *smin, double *smax, double *sv, double *cv, double *su, double *cu, double f, double g, double h) { double svt, cvt, sut, cut; // temporary sv, cv, su, and cu double ft = f, gt = g, ht = h; // temporary f, g, h double fa = fabs(f), ga = fabs(g), ha = fabs(h); // |f|, |g|, and |h| int pmax = 1, // pointer to max abs entry swap = 0, // is swapped glarge = 0, // is g very large tsign; // tmp sign double fmh, // |f| - |h| d, // (|f| - |h|)/|f| dd, // d*d q, // g/f qq, // q*q s, // (|f| + |h|)/|f| ss, // s*s spq, // sqrt(ss + qq) dpq, // sqrt(dd + qq) a; // (spq + dpq)/2 double tmp, // temporaries tt; // make fa>=ha if (fa<ha) { pmax = 3; tmp = ft; ft = ht; ht = tmp; // swap ft and ht tmp = fa; fa = ha; ha = tmp; // swap fa and ha swap = 1; } // if fa<ha if (ga==0.0) { // diagonal *smin = ha; *smax = fa; cut = 1.0; sut = 0.0; // identity cvt = 1.0; svt = 0.0; } else { // not diagonal if (ga>fa) { // g is the largest entry pmax = 2; if ((fa/ga)<EPS) { // g is very large glarge = 1; *smax = ga; // 1 ulp if (ha>1.0) *smin = fa/(ga/ha); // 2 ulps else *smin = (fa/ga)*ha; // 2 ulps cut = 1.0; sut = ht/gt; cvt = 1.0; svt = ft/gt; } // if g large } // if ga>fa if (glarge==0) { // normal case fmh = fa - ha; // 1 ulp if (fmh==fa) // cope with infinite f or h d = 1.0; else d = fmh/fa; // note 0<=d<=1.0, 2 ulps q = gt/ft; // note |q|<1/EPS, 1 ulp s = 2.0 - d; // note s>=1.0, 3 ulps qq = q*q; ss = s*s; spq = sqrt(ss + qq); // note 1<=spq<=1+1/EPS, 5 ulps if (d==0.0) dpq = fabs(q); // 0 ulp else dpq = sqrt(d*d + qq); // note 0<=dpq<=1+1/EPS, 3.5 ulps a = 0.5*(spq + dpq); // note 1<=a<=1 + |q|, 6 ulps *smin = ha/a; // 7 ulps *smax = fa*a; // 7 ulps if (qq==0.0) { // qq underflow if (d==0.0) tmp = sign(ft)*2*sign(gt); // 0 ulp else tmp = gt/(sign(ft)*fmh) + q/s; // 6 ulps } else { tmp = (q/(spq + s) + q/(dpq + d))*(1.0 + a); // 17 ulps } // if qq tt = sqrt(tmp*tmp + 4.0); // 18.5 ulps cvt = 2.0/tt; // 19.5 ulps svt = tmp/tt; // 36.5 ulps cut = (cvt + svt*q)/a; // 46.5 ulps sut = (ht/ft)*svt/a; // 45.5 ulps } // if g not large } // if ga if (swap==1) { *cu = svt; *su = cvt; *cv = sut; *sv = cut; } else { *cu = cut; *su = sut; *cv = cvt; *sv = svt; } // if swap // correct the signs of smax and smin if (pmax==1) tsign = sign(*cv)*sign(*cu)*sign(f); if (pmax==2) tsign = sign(*sv)*sign(*cu)*sign(g); if (pmax==3) tsign = sign(*sv)*sign(*su)*sign(h); *smax = isign(tsign)*(*smax); *smin = isign(tsign*sign(f)*sign(h))*(*smin); } // Lasv2
/* * Send message described by the passed pointer to the * passed output buffer. Return -1 on error, but normally * the number of lines written. Adjust the status: field * if need be. If doign is set, suppress ignored header fields. * Call (*fp)(line, obuf) to print the line. */ long msend( struct message *mailp, FILE *obuf, int flag, int (*fp)(const char *, FILE *)) { register struct message *mp; long clen, n, c; FILE *ibuf; char line[LINESIZE], field[BUFSIZ]; int ishead, infld, fline, dostat, doclen, nread, unused; char *cp, *cp2; int doign = flag & M_IGNORE; int oldign = 0; /* previous line was ignored */ long lc; mp = mailp; if (mp->m_clen == 0) setclen(mp); ibuf = setinput(mp); c = mp->m_size; ishead = 1; dostat = 1; doclen = 1; infld = 0; fline = 1; lc = 0; clearerr(obuf); while (c > 0L) { nread = getaline(line, LINESIZE, ibuf, &unused); c -= nread; lc++; if (ishead) { /* * First line is the From line, so no headers * there to worry about */ if (fline) { fline = 0; goto writeit; } /* * If line is blank, we've reached end of * headers, so force out status: field * and note that we are no longer in header * fields. Also force out Content-Length: field. */ if (line[0] == '\n') { if (dostat) { statusput(mailp, obuf, doign, fp); dostat = 0; } if (doclen && !isign("content-length", flag&M_SAVING)) { snprintf(field, sizeof (field), "Content-Length: %ld\n", mp->m_clen - 1); (*fp)(field, obuf); if (ferror(obuf)) return(-1); doclen = 0; } ishead = 0; goto writeit; } /* * If this line is a continuation * of a previous header field, just echo it. */ if (isspace(line[0]) && infld) if (oldign) continue; else goto writeit; infld = 0; /* * If we are no longer looking at real * header lines, force out status: * This happens in uucp style mail where * there are no headers at all. */ if (!headerp(line)) { if (dostat) { statusput(mailp, obuf, doign, fp); dostat = 0; } (*fp)("\n", obuf); ishead = 0; goto writeit; } infld++; /* * Pick up the header field. * If it is an ignored field and * we care about such things, skip it. */ cp = line; cp2 = field; while (*cp && *cp != ':' && !isspace(*cp)) *cp2++ = *cp++; *cp2 = 0; oldign = doign && isign(field, flag&M_SAVING); if (oldign) continue; /* * If the field is "status," go compute and print the * real Status: field */ if (icequal(field, "status")) { if (dostat) { statusput(mailp, obuf, doign, fp); dostat = 0; } continue; } if (icequal(field, "content-length")) { if (doclen) { snprintf(line, sizeof (line), "Content-Length: %ld\n", mp->m_clen - 1); (*fp)(line, obuf); if (ferror(obuf)) return(-1); doclen = 0; } continue; } } writeit: if (!ishead && !mp->m_text && mp->m_clen != 0) { if (line[0] == '\n') putc('\n', obuf); clen = mp->m_clen-1; for (;;) { n = clen < sizeof line ? clen : sizeof line; if ((n = fread(line, 1, (int)n, ibuf)) <= 0) { fprintf(stderr, gettext( "\t(Unexpected end-of-file).\n")); clen = 0; } else { if (fwrite(line, 1, (int)n, obuf) != n) { fprintf(stderr, gettext( "\tError writing to the new file.\n")); fflush(obuf); if (fferror(obuf)) return (-1); } } clen -= n; if (clen <= 0) { break; } } c = 0L; } else { (*fp)(line, obuf); if (ferror(obuf)) return(-1); } } fflush(obuf); if (ferror(obuf)) return(-1); if (ishead && (mailp->m_flag & MSTATUS)) printf(gettext("failed to fix up status field\n")); return(lc); }
void vl_lapack_dlasv2 (double *smin, double *smax, double *sv, double *cv, double *su, double *cu, double f, double g, double h) { double svt, cvt, sut, cut; /* temporary sv, cv, su, and cu */ double ft = f, gt = g, ht = h; /* temporary f, g, h */ double fa = fabs(f), ga = fabs(g), ha = fabs(h); /* |f|, |g|, and |h| */ int pmax = 1 ; /* pointer to max abs entry */ int swap = 0 ; /* is swapped */ int glarge = 0 ; /* is g very large */ int tsign ; /* tmp sign */ double fmh ; /* |f| -|h| */ double d ; /* (|f| -|h|)/|f| */ double dd ; /* d*d */ double q ; /* g/f */ double qq ; /* q*q */ double s ; /* (|f| + |h|)/|f| */ double ss ; /* s*s */ double spq ; /* sqrt(ss + qq) */ double dpq ; /* sqrt(dd + qq) */ double a ; /* (spq + dpq)/2 */ double tmp ; /* temporaries */ double tt; /* make fa >= ha */ if (fa < ha) { pmax = 3 ; tmp =ft ; ft = ht ; ht = tmp ; /* swap ft and ht */ tmp =fa ; fa = ha ; ha = tmp ; /* swap fa and ha */ swap = 1 ; } if (ga == 0.0) { /* diagonal */ *smin = ha ; *smax = fa ; /* identity matrix */ cut = 1.0 ; sut = 0.0 ; cvt = 1.0 ; svt = 0.0 ; } else { /* not diagonal */ if (ga > fa) { /* g is the largest entry */ pmax = 2 ; if ((fa / ga) < VL_EPSILON_D) { /* g is very large */ glarge = 1 ; *smax = ga ; /* 1 ulp */ if (ha > 1.0) { *smin = fa / (ga / ha) ; /* 2 ulps */ } else { *smin = (fa / ga) * ha ; /* 2 ulps */ } cut = 1.0 ; sut = ht / gt ; cvt = 1.0 ; svt = ft / gt ; } } if (glarge == 0) { /* normal case */ fmh = fa - ha ; /* 1ulp */ if (fmh == fa) { /* cope with infinite f or h */ d = 1.0 ; } else { d = fmh / fa ; /* note 0<=d<=1.0, 2 ulps */ } q = gt / ft ; /* note |q|<1/EPS, 1 ulp */ s = 2.0 - d ; /* note s>=1.0, 3 ulps */ dd = d*d ; qq = q*q ; ss = s*s ; spq = sqrt(ss + qq) ; /* note 1<=spq<=1+1/EPS, 5 ulps */ if (d == 0.0) { dpq = fabs(q) ; /* 0 ulp */ } else { dpq = sqrt(dd + qq) ; /* note 0<=dpq<=1+1/EPS, 3.5 ulps */ } a = 0.5 * (spq + dpq) ; /* note 1<=a<=1 + |q|, 6 ulps */ *smin = ha / a; /* 7 ulps */ *smax = fa * a; /* 7 ulps */ if (qq==0.0) { /* qq underflow */ if (d==0.0) { tmp = sign(ft)*2*sign(gt); /* 0ulp */ } else { tmp = gt/(sign(ft)*fmh) + q/s; /* 6 ulps */ } } else { tmp = (q/(spq + s) + q/(dpq + d))*(1.0 + a); /* 17 ulps */ } /* if qq */ tt = sqrt(tmp*tmp + 4.0) ; /* 18.5 ulps */ cvt = 2.0 / tt ; /* 19.5 ulps */ svt = tmp / tt ; /* 36.5 ulps */ cut = (cvt + svt*q) / a ; /* 46.5 ulps */ sut = (ht / ft) * svt / a ; /* 45.5 ulps */ } /* if g not large */ } /* if ga */ if (swap == 1) { *cu = svt ; *su = cvt ; *cv = sut ; *sv = cut ; } else { *cu = cut ; *su = sut ; *cv = cvt ; *sv = svt ; } /* correct the signs of smax and smin */ if (pmax==1) { tsign = sign(*cv) * sign(*cu) * sign(f) ; } if (pmax==2) { tsign = sign(*sv) * sign(*cu) * sign(g) ; } if (pmax==3) { tsign = sign(*sv) * sign(*su) * sign(h) ; } *smax = isign(tsign) * (*smax); *smin = isign(tsign * sign(f) * sign(h)) * (*smin) ; }