Is there a nice Java object to hold a 2D grid of doubles?
Is there a data type that simply holds a 2D grid of doubles?
Preferably in the JDK but I'm happy to use an open source 3rd party library like apache commons etc.
I'm looking for a class, and/or complimentary helper classes, that allow methods like these:
Grid g = new DoubleGrid(100, 100);
double min = g.getMinValue();
double someCell = g.g开发者_如何学运维etValueAt(x, y);
double origin = g.getValueAt(Coordinate.ORIGIN);
Ideally, more complicated things like:
Grid newGrid = GridTransformer.transform(g, new CellValueSquarer());
I'm completely making these classes up, and I don't need those particular methods per se, It's just an example of the sort of thing I'm looking for...
Why don't you use a simple 2-dimensional array?
double[][] pixels = new double[100][100];
double mine = pixels[12][65];
Wrap it in some simple class as desired.
But there may be existing implementations somewhere...
You can try EJML or just google 'java matrix library'
You might want to try JAMA, which is a linear algebra package (and thus contains a matrix which is a 2D grid of doubles), or Apache Commons Math, which contains lots of mathematically useful stuff, including linear algebra. EJML, which @pablochan mentioned, is another reasonable choice.
Have you tried javax.vecmath
精彩评论