Fwd: Java Multidimensional Array
- Subject: Fwd: Java Multidimensional Array
- From: Ronald Boisvert <boisvert@nist.gov>
- Date: Tue, 15 Mar 2011 18:21:10 -0400
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=UTF-8; format=flowed
- User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
-------- Original Message --------
Subject: Java Multidimensional Array
Date: Tue, 15 Mar 2011 18:19:07 -0400
From: Si Pal <siopal@yahoo.co.nz>
Reply-To: siopal@yahoo.co.nz <siopal@yahoo.co.nz>
To: Boisvert, Ronald F. <boisvert@nist.gov>
Does anyone know a good book on "multi-dimensional array" algorithms? I know it is not the proper way of writing a 3D Java multi-array, but I have included a Matrix3D class in my "Jama" package. I wrote it something like the following:
-----------------------------------------------------------------------
public class Matrix3D{
private Matrix[] mat3d;
public Matrix3D(Matrix[] mat3d){
this.mat3d = mat3d;
}
public Matrix3D permute(int[] dims){
...
...
}
public void setPage(int pageInd, Matrix mat) {
int row = mat3d[0].getRowDimension();
int col = mat3d[0].getColumnDimension();
if(mat.getRowDimension()!=row || mat.getColumnDimension()!=col){
throw new IllegalArgumentException("Matrix mat has wrong dimension");
}
mat3d[pageInd] = mat;
}
public Matrix getPage(int pageInd) {
return mat3d[pageInd];
}
public Matrix3D reshape(int newR, int newC, int newP) {
...
...
}
public Matrix reshape(int newR, int newC) {
...
...
}
public void set(int i, int j, int k, double val) {
mat3d[k].set(i,j,val);
}
public double get(int i, int j, int k) {
return mat3d[k].get(i,j);
}
}//end class definition
-----------------------------------------------------------------------
I wrote this class so I can use it to port higher-order SVD (HOSVD) matlab codes into Java, which is available from the internet. I'm also interested in porting MPCA (Multilinear Principal Component Analysis) which is also available on the internet. Now, the problem with MPCA is that the highest mode/tensor is 4, which obviously my "Matrix3D" class won't be able to handle, unless I want my Java version of MPCA to deal only with 3 mode/tensor. Also the MPCA codes requires the use of another free Matlab software, the "Tensor" toolbox from Sandia,
http://csmr.ca.sandia.gov/~tgkolda/TensorToolbox/ <http://csmr.ca.sandia.gov/%7Etgkolda/TensorToolbox/>
I want to port the whole Matlab "Tensor Toolbox" into Java, which means I need some general Java multi-array class that can handle modes more than 3 (Matrix3D class) that I have now. I don't know know to write a general multi-array class, perhaps someone here can point me out to some books where I can find the algorithms of how to do it.
I have downloaded & looked at the Java Multiarray from here:
http://www.unidata.ucar.edu/software/netcdf/java/docs/ucar/multiarray/package-summary.html
but it is not the same as Matlab. Example, when I do a reshape or permute in Matlab, the result is different from calling reshape or permute in the UCAR Java multiarray package. The reason, I'm interested in having the same multiarray as Matlab, because the codes that I'm porting to Java is Matlab. Therefore, it is vital that when I test my ported code against matlab, they should be the same or otherwise, I wouldn't have a clue if my porting is indeed correct or wrong.
Any tips about how to write a general Java multiarray class that is compatible with Matlab, would be much appreciated.
Thanks,
Sio Pal.
Date Index |
Thread Index |
Problems or questions? Contact list-master@nist.gov