Dot product of sparse vectors
Posted beiyeqingteng
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dot product of sparse vectors相关的知识,希望对你有一定的参考价值。
Suppose we have very large sparse vectors (most of the elements in vector are zeros)
- Find a data structure to store them
- Compute the Dot Product.
Follow-up:
What if one of the vectors is very small?
1 a = [(1,2),(2,3),(100,5)] 2 b = [(0,5),(1,1),(100,6)] 3 4 i = 0; j = 0 5 result = 0 6 while i < len(a) and j < len(b): 7 if a[i][0] == b[j][0]: 8 result += a[i][1] * b[j][1] 9 i += 1 10 j += 1 11 elif a[i][0] < b[j][0]: 12 i += 1 13 else: 14 j += 1 15 print(result)
以上是关于Dot product of sparse vectors的主要内容,如果未能解决你的问题,请参考以下文章
论文学习-sparse methods for direction of arrival estimation1.
numpy使用np.dot函数或者@操作符计算两个numpy数组的点积数量积(dot productscalar product)
Histograms of Sparse Codes for Object Detection用于目标检测的稀疏码直方图
论文学习-sparse methods for direction of arrival estimation2
论文阅读 Rethinking Anticipation Tasks: Uncertainty-aware Anticipation of Sparse Surgical Instrument