The documentation on the Bigarray module is somewhat vague. It states that the purpose of arrays in that module is to hold "large arrays", but it doesn't really define what it means by "large array". When should I use a Bigarray over a regular array? Is there a certain number of elements beyond which I should just use a Bigarray? Is it in the thousands? Millions? Billions?
关于Bigarray模块的文档有些模糊。它声明该模块中数组的目的是保存“大型数组”,但它并没有真正定义“大型数组”的含义。什么时候应该在常规阵列上使用Bigarray?是否有一定数量的元素,我应该使用Bigarray?它是成千上万?百万?十亿?
And what makes a Bigarray better at dealing with big arrays? What makes a regular array better at dealing with... non-big arrays?
是什么让Bigarray更好地处理大阵列?是什么让常规数组更好地处理...非大数组?
1 个解决方案
#1
10
I found the answer to this (from this page):
我找到了答案(从这个页面):
The bigarray library implements large, multi-dimensional, numerical arrays. These arrays are called “big arrays” to distinguish them from the standard Caml arrays described in Module Array. The main differences between “big arrays” and standard Caml arrays are as follows:
bigarray库实现了大型,多维的数值数组。这些阵列称为“大阵列”,以区别于模块阵列中描述的标准Caml阵列。 “大数组”和标准Caml数组之间的主要区别如下:
- Big arrays are not limited in size, unlike Caml arrays (float array are limited to 2097151 elements on a 32-bit platform, other array types to 4194303 elements).
- 大数组的大小不受限制,与Caml数组不同(浮点数组在32位平台上限制为2097151个元素,其他数组类型限制为4194303个元素)。
- Big arrays are multi-dimensional. Any number of dimensions between 1 and 16 is supported. In contrast, Caml arrays are mono-dimensional and require encoding multi-dimensional arrays as arrays of arrays.
- 大阵列是多维的。支持1到16之间的任意数量的维度。相比之下,Caml阵列是单维的并且需要将多维阵列编码为阵列阵列。
- Big arrays can only contain integers and floating-point numbers, while Caml arrays can contain arbitrary Caml data types. However, big arrays provide more space-efficient storage of integer and floating-point elements, in particular because they support “small” types such as single-precision floats and 8 and 16-bit integers, in addition to the standard Caml types of double-precision floats and 32 and 64-bit integers.
- 大数组只能包含整数和浮点数,而Caml数组可以包含任意Caml数据类型。但是,大数组提供更节省空间的整数和浮点元素存储,特别是因为它们支持“小”类型,如单精度浮点数和8位和16位整数,此外还有标准的Caml类型的double -precision浮点数和32位和64位整数。
- The memory layout of big arrays is entirely compatible with that of arrays in C and Fortran, allowing large arrays to be passed back and forth between Caml code and C / Fortran code with no data copying at all.
- 大数组的内存布局与C和Fortran中的数组完全兼容,允许大型数组在Caml代码和C / Fortran代码之间来回传递,完全不需要数据复制。
- Big arrays support interesting high-level operations that normal arrays do not provide efficiently, such as extracting sub-arrays and “slicing” a multi-dimensional array along certain dimensions, all without any copying.
- 大数组支持普通数组无法有效提供的有趣的高级操作,例如提取子数组和沿某些维度“切片”多维数组,所有这些都无需任何复制。
#1
10
I found the answer to this (from this page):
我找到了答案(从这个页面):
The bigarray library implements large, multi-dimensional, numerical arrays. These arrays are called “big arrays” to distinguish them from the standard Caml arrays described in Module Array. The main differences between “big arrays” and standard Caml arrays are as follows:
bigarray库实现了大型,多维的数值数组。这些阵列称为“大阵列”,以区别于模块阵列中描述的标准Caml阵列。 “大数组”和标准Caml数组之间的主要区别如下:
- Big arrays are not limited in size, unlike Caml arrays (float array are limited to 2097151 elements on a 32-bit platform, other array types to 4194303 elements).
- 大数组的大小不受限制,与Caml数组不同(浮点数组在32位平台上限制为2097151个元素,其他数组类型限制为4194303个元素)。
- Big arrays are multi-dimensional. Any number of dimensions between 1 and 16 is supported. In contrast, Caml arrays are mono-dimensional and require encoding multi-dimensional arrays as arrays of arrays.
- 大阵列是多维的。支持1到16之间的任意数量的维度。相比之下,Caml阵列是单维的并且需要将多维阵列编码为阵列阵列。
- Big arrays can only contain integers and floating-point numbers, while Caml arrays can contain arbitrary Caml data types. However, big arrays provide more space-efficient storage of integer and floating-point elements, in particular because they support “small” types such as single-precision floats and 8 and 16-bit integers, in addition to the standard Caml types of double-precision floats and 32 and 64-bit integers.
- 大数组只能包含整数和浮点数,而Caml数组可以包含任意Caml数据类型。但是,大数组提供更节省空间的整数和浮点元素存储,特别是因为它们支持“小”类型,如单精度浮点数和8位和16位整数,此外还有标准的Caml类型的double -precision浮点数和32位和64位整数。
- The memory layout of big arrays is entirely compatible with that of arrays in C and Fortran, allowing large arrays to be passed back and forth between Caml code and C / Fortran code with no data copying at all.
- 大数组的内存布局与C和Fortran中的数组完全兼容,允许大型数组在Caml代码和C / Fortran代码之间来回传递,完全不需要数据复制。
- Big arrays support interesting high-level operations that normal arrays do not provide efficiently, such as extracting sub-arrays and “slicing” a multi-dimensional array along certain dimensions, all without any copying.
- 大数组支持普通数组无法有效提供的有趣的高级操作,例如提取子数组和沿某些维度“切片”多维数组,所有这些都无需任何复制。