Hi,
I have a problem when I tried to use the function H5.H5Dread() in the Java API to read a compound data set to a 2D array in memory. The input compound data set is a P x N matrix with each data cell containing two components "r" and "I", representing the real and imaginary parts of a complex number.
Right now I can successfully read each component ("r" or "I") into a 2D array of P x N and then combine them together by putting "i" matrix to the right of "r" matrix, i.e. to form a final matrix of P x 2N. Here is an illustration:
READ INPUT:
r[0,0],i[0,0] | r[0,1],i[0,1] | r[0,2],i[0,2] | ... | r[0,N],i[0,N]
r[1,0],i[1,0] | r[1,1],i[1,1] | r[1,2],i[1,2] | ... | r[1,N],i[1,N]
.
.
.
r[P,0],i[P,0] | r[P,1],i[P,1] | r[P,2],i[P,2] | ... | r[P,N],i[P,N]
INTO:
r[0,0] | r[0,1] | r[0,2] | ... | r[0,N] | i[0,0] | i[0,1] | i[0,2] | ... | i[0,N]
r[1,0] | r[1,1] | r[1,2] | ... | r[1,N] | i[1,0] | i[1,1] | i[1,2] | ... | i[1,N]
.
.
.
r[P,0] | r[P,1] | r[P,2] | ... | r[P,N] | i[P,0] | i[P,1] | i[P,2] | ... | i[P,N]
The ultimate goal of this input process is to
1) set up a 2D array in memory - A[P, 2N];
2) read the "r" and "I" respectively into A[0:P, 0:N] and A[0:P, N:2N] by using H5.H5Sselect_hyperslab() in the memory space;
Here are the code I used in my application
For "r"
offset[0] = (long) 0; offset[1] = (long) (0);
count[0] = P; count[1] = N;
H5.H5Sselect_hyperslab(memory_space_id, HDF5Constants.H5S_SELECT_SET, offset, null, count, null);
H5.H5Dread(dataset_id, r_type_id, memory_space_id, dataspace_id, HDF5Constants.H5P_DEFAULT, A);
For "i"
offset[0] = (long) 0; offset[1] = (long) (N);
count[0] = P; count[1] = N;
H5.H5Sselect_hyperslab(memory_space_id, HDF5Constants.H5S_SELECT_SET, offset, null, count, null);
H5.H5Dread(dataset_id, i_type_id, memory_space_id, dataspace_id, HDF5Constants.H5P_DEFAULT, A);
I can verify each H5.H5Dread() call read the component correctly. However, when it tries to write the component into the memory area, the second H5.H5Dread() on "I" component will wipe out the result (i.e. "r" component) written by the first H5.H5Dread() call. Here is an illustration:
Suppose we have P=3 and N=3, A will be of [3, 6]
Original A:
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
A after H5.H5Dread() call on "r" component:
0.0025 0.0026 0.0027 0.0028 0.0000 0.0000 0.0000 0.0000
0.0013 0.0014 0.0015 0.0015 0.0000 0.0000 0.0000 0.0000
-0.0004 -0.0000 0.0002 0.0006 0.0000 0.0000 0.0000 0.0000
A after H5.H5Dread() call on "i" component:
0.0000 0.0000 0.0000 0.0000 -0.0019 -0.0021 -0.0024 -0.0028
0.0000 0.0000 0.0000 0.0000 -0.0019 -0.0023 -0.0028 -0.0033
0.0000 0.0000 0.0000 0.0000 0.0027 0.0034 0.0038 0.0045
My question is: is there a way I could turn off this "wipe-out-with-zero" in H5.H5Dread() to preserver whatever is originally stored in the 2D array in memory?
Thanks.
- Yawei