是否可以知道以 HDF5 格式存储的矩阵是 RowMajor 还是 ColMajor?例如,当我从 octave 中保存矩阵时,它们在内部存储为 ColMajor,当我在我的 C 代码中读取它们时,我需要转置它们,其中矩阵存储在 RowMajor 中,反之亦然。
最佳答案
HDF5 按行主要顺序存储数据:
HDF5 uses C storage conventions, assuming that the last listed dimension is the fastest-changing dimension and the first-listed dimension is the slowest changing.
来自 HDF5 User's Guide .
然而 ,如果您使用 Octave 的内置 HDF5 接口(interface),它会自动为您转置数组。一般来说,数据实际上是如何写入 HDF5 文件的,对最终用户来说应该是完全不透明的,接口(interface)应该处理数组排序等方面的差异。
关于HDF5 rowmajor 或 colmajor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24116713/