From: Alan W. I. <ir...@be...> - 2001-10-30 20:41:44
|
I made the following precision changes to all implemented java examples where appropriate: I have used the java-defined constant Math.PI instead of defining a low-precision local PI or using inverse trig functions to get PI. I found this solution in the very helpful and detailed java tutorial at http://java.sun.com/docs/books/tutorial/java/index.html. All float --> double Drop f suffix on numerical constants (e.g., 1.0f --> 1.0). According to the tutorial, floating point numbers without a suffix are interpreted as double just like as in C. The f suffix forces the constant to be single precision which is exactly what we don't want. The reason for these changes is to extirpate low-precison (as in PI) or single precision for the reason (noted before) of getting more consistent comparisons between demos on different machines. In this case, the machine is mixed; on the front end we have the JVM which we are comparing with gcc results generated on ix86 for the C front end. However, the back end (libplplot) is identical for both front-end cases. With these changes, all java examples other than the following noted exceptions now give identical postscript results to the equivalent C examples when double precision is configured for the back end. x03: If I commented out the two plptex calls in the C and java code I got identical results. If you don't comment out these calls, you will visually notice the "270" label produced by plptex is slightly different (different pixelization). So there is likely some floating-point logic in the calculations that go into drawing the characters (in fact such logic must be there by necessity, I believe). Thus, for characters at just the right coordinates, the slightest change in those floating-point coordinates can make a pixelization change in the the way the character is rendered. x05: diff shows a minor discrepancy between the two plots which visually, under high magnification seems to correspond to one more column of pixels in the "l" in "probability" (at the top of the plot). This x05 label discrepancy might have a similar cause (floating-point logic in the pixelization of the drawn characters) as the x03 label problem. I have also done the comparisons between java and C front-end results using the single-precision back end. (To be clear about what I did, I did a make clean, ./configure and make for both single and double precision with the only configure difference being --with-double. I also had to change the name of the library appropriately in PLStream.java.) Since double-precision is forced in both front-ends, and you are using the same (single-precision) back-end in both cases, you would expect discrepancies between the java and C results to be as small when single-precision is configured as for the case when double-precison is configured. This expectation seems to be confirmed by the following results: x03: similar discrepancy as in double-precision case. x05: No discrepancy in this case in contrast to double-precison case. x08: shows a minor but opposite discrepancy to x05. The double precision versions are identical, but the single-precision versions differ slightly. There does seem to be one java bug for the single-precison back end which needs further investigation. For the double-precision back end, x01 gives gives identical good results to the double-precision C example, but for the single-precision back end the java example badly screws up the placement of the line symbols. So the current status of the java front end is that x01 through x11 (except for x09) are done. For these implemented examples, there is one clear bug noted above that shows up in x01 for the single-precison back end. Also the plplot library name has to be configured in PLStream.java. Otherwise, we are in pretty good shape with exact agreement in results with the C examples or else for the few minor character-drawing discrepancies that do occur we have a reasonable explanation. Alan email: ir...@be... phone: 250-727-2902 FAX: 250-721-7715 snail-mail: Dr. Alan W. Irwin Department of Physics and Astronomy, University of Victoria, P.O. Box 3055, Victoria, British Columbia, Canada, V8W 3P6 __________________________ Linux-powered astrophysics __________________________ |