Performance issues related to trigonometric functions , floating point arithmetic and
by, 11-19-2011 at 07:19 PM (1354 Views)
I have briefly listed the performance issues related to trigonometric functions, floating point arithmetic functions and Java Native Interface. I hope these will be helpful.
In Java, results got from trigonometric functions and calculations may not be as accurate as that of results got from trigonometric functions and calculations of C language. This is because because Java has strict specifications for the results of mathematical operations.This may not necessarily correspond to the underlying hardware. On the x87 system sine and cosine instructions for parameters with absolute value more than π / 4 are not as accurate as they are they are calculated by reducing them to this range using an approximation of π.
Floating point arithmetic
Java's floating point arithmetic is mainly derived from Standard for Binary Floating-Point Arithmetic IEEE 754. However, even when using strictfp modfier (used to restrict floating-point calculations to ensure portability) some features are not supported viz. Exception Flags and Directed Roundings. These are compulsory capabilities described by IEEE Standard 754.
Java Native Interface
Using JNI has its advantages but not without some overheads associated with it.
- JNI can be invoked by only applications and signed applets.
- An application that uses JNI loses the platform portability the Java boasts. To get way with it is to write a separate implementation of the JNI code for each platform and have Java detect the Operating System and load the correct one at runtime.
- Garbage collection for the JNI side is not available and JNI code must do the explicit or manual deallocation as in other programming languages.
- Error checking is a mandatory or it has the potential danger to crash the JNI side and the JVM.
However, it must be said that these overheads can be overlooked for what JNI has to offer.