i notice that the generate function is not defined for mutable vectors. i'm wondering if there is another way to define multidimensional mutable Vectors in haskell
我注意到生成函数没有为可变向量定义。我想知道在haskell中是否有另一种定义多维可变向量的方法
1 个解决方案
#1
5
I assume your mean something from the vector
package, like Data.Vector.Mutable
?
我假设你的意思是来自矢量包,比如data。vectorr。mutableck ?
It provides several ways to create and fill mutable arrays, such as with replicate
. However, the vector
package is for 1-dimensional, growable vectors, not multi-dimensional arrays.
它提供了几种创建和填充可变数组的方法,比如复制。然而,向量包是针对一维的可生长向量而不是多维数组。
For n>1 dimensions, you need to either code the index manually, or use repa
or hmatrix
.
对于n个>1维,您需要手工编写索引,或者使用repa或hmatrix。
repa
, in particular, is interesting, as it also provides automagically parallel operations, and you can fill one from a vector. However, repa
arrays are immutable, and rely on fusion for a nice interface.
repa特别有趣,因为它还提供了自动并行操作,您可以从向量中填充一个。然而,repa数组是不可变的,并且依赖于fusion来实现一个良好的接口。
If you need mutable and multi-dimensional arrays, you might have to resort to the old school array
package, and one of the MArray
types.
如果需要可变和多维数组,可能需要使用旧的school array包和MArray类型之一。
#1
5
I assume your mean something from the vector
package, like Data.Vector.Mutable
?
我假设你的意思是来自矢量包,比如data。vectorr。mutableck ?
It provides several ways to create and fill mutable arrays, such as with replicate
. However, the vector
package is for 1-dimensional, growable vectors, not multi-dimensional arrays.
它提供了几种创建和填充可变数组的方法,比如复制。然而,向量包是针对一维的可生长向量而不是多维数组。
For n>1 dimensions, you need to either code the index manually, or use repa
or hmatrix
.
对于n个>1维,您需要手工编写索引,或者使用repa或hmatrix。
repa
, in particular, is interesting, as it also provides automagically parallel operations, and you can fill one from a vector. However, repa
arrays are immutable, and rely on fusion for a nice interface.
repa特别有趣,因为它还提供了自动并行操作,您可以从向量中填充一个。然而,repa数组是不可变的,并且依赖于fusion来实现一个良好的接口。
If you need mutable and multi-dimensional arrays, you might have to resort to the old school array
package, and one of the MArray
types.
如果需要可变和多维数组,可能需要使用旧的school array包和MArray类型之一。