Lines Matching +full:- +full:y
35 /* HYPOT(X,Y)
36 * RETURN THE SQUARE ROOT OF X^2 + Y^2 WHERE Z=X+iY
42 * copysign(x,y)
48 * 1. replace x by |x| and y by |y|, and swap x and
49 * y if y > x (hence x is never smaller than y).
50 * 2. Hypot(x,y) is computed by:
51 * Case I, x/y > 2
53 * y
54 * hypot = x + -----------------------------
56 * sqrt ( 1 + [x/y] ) + x/y
58 * Case II, x/y <= 2
59 * y
60 * hypot = x + --------------------------------------------------
62 * [x/y] - 2
63 * (sqrt(2)+1) + (x-y)/y + -----------------------------
65 * sqrt ( 1 + [x/y] ) + sqrt(2)
70 * hypot(x,y) is INF if x or y is +INF or -INF; else
71 * hypot(x,y) is NAN if x or y is NAN.
74 * hypot(x,y) returns the sqrt(x^2+y^2) with error less than 1 ulps (units
77 * 1980, Edited by Karl L.E. Nickel, pp 99-128. (A faster but less accurate
91 vc(r2p1lo, 1.4349369327986523769E-17 ,597d,2484,754b,89b3, -55, .84597D89B3754B)
95 ic(r2p1lo, 1.2537167179050217666E-16 , -53, 1.21165F626CDD5)
105 hypot(double x, double y) in hypot() argument
108 small=1.0E-18; /* fl(1+small)==1 */ in hypot()
114 if(finite(y)) in hypot()
117 y=copysign(y,one); in hypot()
118 if(y > x) in hypot()
119 { t=x; x=y; y=t; } in hypot()
121 if(y == zero) return(x); in hypot()
123 if(exp-(int)logb(y) > ibig ) in hypot()
127 /* start computing sqrt(x^2 + y^2) */ in hypot()
128 r=x-y; in hypot()
129 if(r>y) { /* x/y > 2 */ in hypot()
130 r=x/y; in hypot()
132 else { /* 1 <= x/y <= 2 */ in hypot()
133 r/=y; t=r*(r+2.0); in hypot()
137 r=y/r; in hypot()
142 else if(y==y) /* y is +-INF */ in hypot()
143 return(copysign(y,one)); in hypot()
145 return(y); /* y is NaN and x is finite */ in hypot()
147 else if(x==x) /* x is +-INF */ in hypot()
149 else if(finite(y)) in hypot()
150 return(x); /* x is NaN, y is finite */ in hypot()
152 else if(y!=y) return(y); /* x and y is NaN */ in hypot()
154 else return(copysign(y,one)); /* y is INF */ in hypot()
164 * hypot(x,y)
167 * cabs(z) = hypot(x,y) .
170 struct complex { double x, y; }; member
176 return hypot(z.x,z.y);
183 return hypot(z->x,z->y);
186 /* A faster but less accurate version of cabs(x,y) */
188 double hypot(x,y)
189 double x, y;
192 small=1.0E-18; /* fl(1+small)==1 */
198 if(finite(y))
201 y=copysign(y,one);
202 if(y > x)
203 { temp=x; x=y; y=temp; }
205 if(y == zero) return(x);
207 x=scalb(x,-exp);
208 if(exp-(int)logb(y) > ibig )
211 else y=scalb(y,-exp);
212 return(scalb(sqrt(x*x+y*y),exp));
215 else if(y==y) /* y is +-INF */
216 return(copysign(y,one));
218 return(y); /* y is NaN and x is finite */
220 else if(x==x) /* x is +-INF */
222 else if(finite(y))
223 return(x); /* x is NaN, y is finite */
224 else if(y!=y) return(y); /* x and y is NaN */
225 else return(copysign(y,one)); /* y is INF */