[英]Is there a function for calculating all the pairwise dot products of the columns of a matrix, or between all pairs in a list of vectors?
Say you have n.说你有n。 vectors of arbitrary (but equal) length m each.任意(但相等)长度为 m 的向量。 Is there a (numpy?) function, or a quick way, of calculating all pairwise dot products between these n.是否有(numpy?)函数或快速方法来计算这些 n 之间的所有成对点积。 vectors?向量?
My initial thought was that you could calculate A T A and take the upper triangular portion, but I'm not sure if that matrix multiplication is slow/computationally intensive.我最初的想法是你可以计算 A T A 并取上三角部分,但我不确定矩阵乘法是否很慢/计算密集。 Is there a quicker/efficient way?有没有更快/有效的方法? Or should I just define a function using a for loop for all combinations of pairs?或者我应该只使用 for 循环为所有对组合定义一个函数?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.