在 Java 中实现稀疏向量的最佳方法是什么?
在 Java 中实现稀疏向量的最佳方法是什么?
当然,好的事情是拥有一些可以很容易操纵的东西(标准化,标量积等)
提前致谢
Which is the best way to implement a sparse vector in Java?
Of course the good thing would be to have something that can be manipulated quite easily (normalization, scalar product and so on)
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
MTJ 有一个 稀疏向量 类。它具有范数函数(1-范数、2-范数和 ∞-范数)和点积函数。
MTJ has a Sparse Vector class. It has norm functions (1-norm 2-norm and ∞-norm) and dot product functions.
JScience 有一个 SparseVector 实现是其线性的一部分代数包。
JScience has a SparseVector implementation that is part of its linear algebra package.
您还可以尝试查看 la4j 的 CompressedVector 实现。它使用一对数组:值数组和索引数组。再加上二分搜索,它就可以顺利进行。因此,此实现保证
get
/set
操作的O(log n)
运行时间。只是一个简单的例子
You can also try to look at la4j's CompressedVector implementation. It uses pair of arrays: array of values and array of their indicies. And with binary search on top of that it just flies. So, this implementation guarantees
O(log n)
running time forget
/set
operations.Just a brief example