Skip to content

Commit e366e66

Browse files
committed
Add row/column-major order documentation
1 parent 88a64e2 commit e366e66

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ provides an interface to the HDF5 library for the Julia language.
1616

1717
## Changelog
1818

19-
Please see [HISTORY.jl](HISTORY.md) for the changelog. Most changes have deprecation warnings and thus may not be listed in this file.
19+
Please see [HISTORY.md](HISTORY.md) for the changelog. Most changes have deprecation warnings and thus may not be listed in this file.
2020

2121
## Installation
2222

@@ -109,6 +109,12 @@ There is no conflict in having multiple modules (HDF5, [JLD](https://github.com/
109109
[MAT](https://github.com/simonster/MAT.jl)) available simultaneously;
110110
the formatting of the file is determined by the open command.
111111

112+
## Reading Python/C written HDF5 files
113+
To read a multidimensional array into the original shape from an HDF5 file written by Python (NumPy) or C/C++/Objective-C, simply add the following line after reading the dataset `dset`:
114+
```julia
115+
dset = permutedims(dset, reverse(1:ndims(dset)))
116+
```
117+
112118
## Complete documentation
113119

114120
The HDF5 API is much more extensive than suggested by this brief

docs/src/index.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ g["mydataset"] = rand(3,5)
125125
write(g, "mydataset", rand(3,5))
126126
```
127127

128+
## Row- and column-major order
129+
130+
There are two methods, [row-major order and column-major order](https://en.wikipedia.org/wiki/Row-_and_column-major_order), for storing multidimensional arrays in linear storage. Multidimensional arrays in Julia (and Fortran) are stored in column-major order, while other languages including C and Python (NumPy) use row-major order.
131+
132+
To read a multidimensional array into the original shape from an HDF5 file written by Python (`numpy` and `h5py`) or C/C++/Objective-C, simply add the following line after reading the dataset `dset`:
133+
```julia
134+
dset = permutedims(dset, reverse(1:ndims(dset)))
135+
```
136+
137+
Note that NumPy arrays are row-major by default, but NumPy can use either row-major or column-major ordered arrays. For more details on this topic you can refer to [this issue](https://github.com/JuliaIO/HDF5.jl/issues/785).
128138

129139
## Passing parameters
130140

0 commit comments

Comments
 (0)