Changeset 11730
- Timestamp:
- 04/04/09 22:16:53 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/MathFunctions.java
r11729 r11730 34 34 package org.armedbear.lisp; 35 35 36 import java.lang.reflect.Method;37 38 36 public final class MathFunctions extends Lisp 39 37 { … … 260 258 }; 261 259 262 private static Method sinhMethod = null;263 static {264 try {265 sinhMethod = Class.forName("java.lang.Math")266 .getMethod("sinh", new Class[] { Double.TYPE });267 }268 catch (Throwable t) {269 Debug.trace(t);270 }271 }272 273 260 private static LispObject sinh(LispObject arg) throws ConditionThrowable 274 261 { … … 281 268 if (arg instanceof SingleFloat) { 282 269 try { 283 if (sinhMethod != null) { 284 Object[] args; 285 args = new Object[1]; 286 args[0] = new Double(((SingleFloat)arg).value); 287 Double d = (Double) sinhMethod.invoke(null, args); 288 return new SingleFloat((float)d.doubleValue()); 289 } 270 double d = Math.sinh(((SingleFloat)arg).value); 271 return new SingleFloat((float)d); 290 272 } 291 273 catch (Throwable t) { … … 295 277 } else if (arg instanceof DoubleFloat) { 296 278 try { 297 if (sinhMethod != null) { 298 Object[] args; 299 args = new Object[1]; 300 args[0] = new Double(((DoubleFloat)arg).value); 301 Double d = (Double) sinhMethod.invoke(null, args); 302 return new DoubleFloat(d.doubleValue()); 303 } 279 double d = Math.sinh(((DoubleFloat)arg).value); 280 return new DoubleFloat(d); 304 281 } 305 282 catch (Throwable t) { … … 331 308 }; 332 309 333 private static Method coshMethod = null;334 static {335 try {336 coshMethod = Class.forName("java.lang.Math")337 .getMethod("cosh", new Class[] { Double.TYPE });338 }339 catch (Throwable t) {340 Debug.trace(t);341 }342 }343 344 310 private static LispObject cosh(LispObject arg) throws ConditionThrowable 345 311 { … … 352 318 if (arg instanceof SingleFloat) { 353 319 try { 354 if (coshMethod != null) { 355 Object[] args; 356 args = new Object[1]; 357 args[0] = new Double(((SingleFloat)arg).value); 358 Double d = (Double) coshMethod.invoke(null, args); 359 return new SingleFloat((float)d.doubleValue()); 360 } 320 double d = Math.cosh(((SingleFloat)arg).value); 321 return new SingleFloat((float)d); 361 322 } 362 323 catch (Throwable t) { … … 366 327 } else if (arg instanceof DoubleFloat) { 367 328 try { 368 if (coshMethod != null) { 369 Object[] args; 370 args = new Object[1]; 371 args[0] = new Double(((DoubleFloat)arg).value); 372 Double d = (Double) coshMethod.invoke(null, args); 373 return new DoubleFloat(d.doubleValue()); 374 } 329 double d = Math.cosh(((DoubleFloat)arg).value); 330 return new DoubleFloat(d); 375 331 } 376 332 catch (Throwable t) { … … 392 348 } 393 349 394 private static Method tanhMethod = null;395 static {396 try {397 tanhMethod = Class.forName("java.lang.Math")398 .getMethod("tanh", new Class[] { Double.TYPE });399 }400 catch (Throwable t) {401 Debug.trace(t);402 }403 }404 405 350 // ### tanh 406 351 private static final Primitive TANH = new Primitive("tanh", "number") … … 411 356 if (arg instanceof SingleFloat) { 412 357 try { 413 if (tanhMethod != null) { 414 Object[] args; 415 args = new Object[1]; 416 args[0] = new Double(((SingleFloat)arg).value); 417 Double d = (Double) tanhMethod.invoke(null, args); 418 return new SingleFloat((float)d.doubleValue()); 419 } 358 double d = Math.tanh(((SingleFloat)arg).value); 359 return new SingleFloat((float)d); 420 360 } 421 361 catch (Throwable t) { … … 425 365 } else if (arg instanceof DoubleFloat) { 426 366 try { 427 if (tanhMethod != null) { 428 Object[] args; 429 args = new Object[1]; 430 args[0] = new Double(((DoubleFloat)arg).value); 431 Double d = (Double) tanhMethod.invoke(null, args); 432 return new DoubleFloat(d.doubleValue()); 433 } 367 double d = Math.tanh(((DoubleFloat)arg).value); 368 return new DoubleFloat(d); 434 369 } 435 370 catch (Throwable t) {
Note: See TracChangeset
for help on using the changeset viewer.