如何从数组中计算标量积?

2024-10-01 05:06:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望你们都好

我有一系列的日期

数据链接(enter link description here

我想计算标量积而不重复或计数两次。我是说

scalarproduct = np.dot (chiunitvdt1[i],chiunitvdt1[j])

我假设“chiunitvdt1”只有4个数据,我们看到不同的标量产品(没有重复)是:

 np.dot (chiunitvdt1[0],chiunitvdt1[1]), np.dot (chiunitvdt1[0],chiunitvdt1[2]), np.dot (chiunitvdt1[0],chiunitvdt1[3]),
    np.dot (chiunitvdt1[1],chiunitvdt1[2]),np.dot (chiunitvdt1[1],chiunitvdt1[3]),
    np.dot (chiunitvdt1[2],chiunitvdt1[3])

我在用

scalarproduct=[]
for i in range(0,len(chiunitvdt1)): 
    for j in range(i+1,len(dt1)): #"j" runs as i+1
        angle=abs(np.dot(chiunitvdt1[i],chiunitvdt1[j]))
        scalarproduct.append(angle)

但我想我只是在数

[0][1], [1],[2], [2],[3],...
and not [0][2],[0][3],..., [1][3],...

谢谢你的帮助


Tags: 数据inforlen链接nplinkrange