Re: [netcdf-java] Linear algebra on data read from a netCDF file

On 15.10.2009, at 17:51, John Caron wrote:

The most efficient thing to use is this method on the Array class:

public java.lang.Object get1DJavaArray(java.lang.Class wantType);

this will give back the java primitive array, without copying if possible. So if you have a double Array:

double[] ja = (double []) ma.get1DJavaArray( double.class);

you then have to see if your chosen algebra package has a constructor that can wrap the java array without copying it. You will need the shape information:
int[] shape = ma.getShape();

Good luck, and drop me a note if you find out anything useful to others with the same problem.

Thanks! This should at least be efficient. I quickly checked the Colt implementation, which does have a constructor for its array class that takes the plain Java array plus the shape information, so at least in theory this should be simple. If/when I get it to work, I'll post my solution here.


On 15.10.2009, at 18:15, Doug Lindholm wrote:

You might also look at Apache Commons Math:
http://commons.apache.org/math/

That looks like an interesting library as well, but its linear algebra routines use Java-style 2D arrays, so it's not a good match for my purposes.

Thanks to both of you for your suggestions!

Konrad.



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: