|
From: Alan W. I. <ir...@be...> - 2002-05-19 06:06:28
|
Geoffrey, I hope I will be clearer this time.
The java wrapper for plcont obtains the number of contours from the array
object passed from java. So it is important that the number of contours in
that array object are exactly correct.
The problem for the last two example pages is an attempt is made to plot
negative and positive contours, and there is no general way in advance at
the java level to know how the 20 total contours will be split between
negative and positive values until you calculate the contours from the range
of the data. I ran the example once to find out there are 10 of each so the
next time I preallocated 10 contours for each array with
double [] clevelneg = new double[PNLEVEL/2];
double [] clevelpos = new double[PNLEVEL/2];
That works, but running the example once to see what the array size is and
preallocating that space as a constant the second time you run it is
obviously not the most general or nice way to do it.
So at the java level I want to allocate the negative contour and positive
contour arrays after the number of each kind of contour has been calculated.
After nlevelpos and nlevelneg were calculated by the code I tried to
allocate the array space using
double [] clevelneg = new double[nlevelneg];
double [] clevelpos = new double[nlevelpos];
but that failed to work. (I have forgotten the exact error message.)
In java, how can you allocate an array of size nlevelneg (or nlevelpos)
where those numbers are calculated values rather than constants?
In java our current model seems to be plplot routines can only be called
with statically allocated arrays of constant size which must be exactly
correct, and that is not going to be very convenient to use for plcont or
any other PLplot function which has array arguments. Thus, I think this
is a general problem rather than just a problem with plcont.
BTW, this is not a problem for the C front end because, first, you can alloc
the array dynamically (say with plAlloc2dGrid) and, second, also specify the
exact number of elements as one of the arguments. Also, it is not a problem
for the python front end since the arrays are allocated dynamically with the
calculated size that you want. If we cannot dynamically allocate java array
objects, then I believe we need to move to a different array-like java
object that can be dynamically allocated for *all* our plplot functions that
require arrays. I believe there is a java object called a vector that
filled the bill for early versions of java, but we may need something else
now. I looked at the discussion of vector and ArrayList in
http://java.sun.com/docs/books/tutorial/collections/implementations/general.html,
and it looks like vector has legacy problems, and ArrayList is now
preferred, but I don't know how to convert are examples and javabind.c so
that we replace all java array objects with java ArrayList objects.
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
__________________________
On Sat, 18 May 2002, Geoffrey Furnish wrote:
> Hi, I looked at this tonight, but I'm afraid I don't see clearly what
> you are driving at. What would you like to be able to write? Java
> has an ArrayList which may be what you're after, if I'm guessing
> right.
>
> I have not every written back-end JNI code to extract data from an
> ArrayList. But I probably need to work through this exercise at some
> point.
>
> Alan W. Irwin writes:
> > Update of /cvsroot/plplot/plplot/examples/java
> > In directory usw-pr-cvs1:/tmp/cvs-serv31421
> >
> > Modified Files:
> > x09.java
> > Log Message:
> > Make this example (using nowrap approach) give consistent results with
> > the equivalent python example, xw09.py.
> >
> > Also work around long-standing clevelpos and clevelneg problem where their
> > size was not correct. The workaround is to allocate the correct size in
> > advance (an extremely clumsy and error-prone method since the number of
> > positive and negative contours depends very much on the data range), but the
> > proper solution is to use a dynamically allocated array. I think those are
> > probably called vectors in java, but I know no more than that.
> >
> > Geoffrey, can you fix this properly? Look for "Geoffrey" in comments!
> >
> > This nowrap approach gives identical results to python example, but the
> > plan is to change to the wrap approach as soon as wrap is debugged in
> > javabind.c.
> >
> >
> >
> > _______________________________________________________________
> >
> > Have big pipes? SourceForge.net is looking for download mirrors. We supply
> > the hardware. You get the recognition. Email Us: ban...@so...
> > _______________________________________________
> > Plplot-cvs mailing list
> > Plp...@li...
> > https://lists.sourceforge.net/lists/listinfo/plplot-cvs
>
> _______________________________________________________________
> Hundreds of nodes, one monster rendering program.
> Now that's a super model! Visit http://clustering.foundries.sf.net/
>
> _______________________________________________
> Plplot-devel mailing list
> Plp...@li...
> https://lists.sourceforge.net/lists/listinfo/plplot-devel
>
|