多维可变向量:可能吗?如果是这样,怎么办?
我注意到生成函数没有为可变向量定义。我想知道是否有另一种方法在 haskell 中定义多维可变向量
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您的意思是
vector
包中的某些内容,例如Data.Vector.Mutable
?它提供了多种创建和填充可变数组的方法,例如使用
复制
。但是,vector
包适用于一维、可增长的向量,而不是多维数组。对于 n>1 维度,您需要手动对索引进行编码,或者使用
repa
或hmatrix
。repa
特别有趣,因为它还提供自动并行操作,您可以 从向量中填充一个。然而,repa 数组是不可变的,并且依赖于融合来实现良好的接口。如果您需要可变和多维数组,您可能必须求助于旧式
array
包,以及之一MArray 类型。
I assume your mean something from the
vector
package, likeData.Vector.Mutable
?It provides several ways to create and fill mutable arrays, such as with
replicate
. However, thevector
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
orhmatrix
.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.If you need mutable and multi-dimensional arrays, you might have to resort to the old school
array
package, and one of theMArray
types.