Changeset 11954
- Timestamp:
- 05/26/09 18:34:23 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Complex.java
r11718 r11954 33 33 34 34 package org.armedbear.lisp; 35 36 import java.lang.reflect.Method;37 35 38 36 public final class Complex extends LispObject … … 303 301 } 304 302 305 private static Method hypotMethod = null;306 static { try {307 hypotMethod =308 Class.forName("java.lang.Math")309 .getMethod("hypot", new Class[] { Double.TYPE, Double.TYPE });310 }311 catch (Throwable t) { Debug.trace(t); }312 }313 314 303 @Override 315 304 public LispObject ABS() throws ConditionThrowable … … 319 308 double real = DoubleFloat.coerceToFloat(realpart).value; 320 309 double imag = DoubleFloat.coerceToFloat(imagpart).value; 321 try322 {323 if (hypotMethod != null)324 {325 Object[] args;326 args = new Object[2];327 args[0] = new Double(real);328 args[1] = new Double(imag);329 Double d = (Double) hypotMethod.invoke(null, args);330 if (realpart instanceof DoubleFloat)331 return new DoubleFloat(d.doubleValue());332 else333 return new SingleFloat((float)d.doubleValue());334 }335 }336 catch (Throwable t)337 {338 Debug.trace(t);339 // Fall through...340 }341 double result = Math.sqrt(real * real + imag * imag);342 310 if (realpart instanceof DoubleFloat) 343 return new DoubleFloat( result);311 return new DoubleFloat(Math.hypot(real, imag)); 344 312 else 345 return new SingleFloat((float) result);313 return new SingleFloat((float)Math.hypot(real, imag)); 346 314 } 347 315
Note: See TracChangeset
for help on using the changeset viewer.