변수 확인

PythonNoob

현재 벡터를 가져 와서 세 번째로 만드는 코드가 있습니다.

for b in range(2047):
    for a in range(b+1,2048):
        vector1 = (l[b][0],l[b][1],l[b][2])
        vector2 = (l[a][0],l[a][1],l[a][2])

        x = vector1
        y = vector2
        vector3 = list(np.array(x) - np.array(y))

        dotProduct = reduce( operator.add, map( operator.mul, vector3, vector3))

        dp = dotProduct**.5
        data_points = dp


       bin = int(dp/bin_width)
          if bin < num_bins: 

            bins[bin][2] += 1.0/bin_volumes[bin]    

ps b = 36771.881 그러나 나는 만약 (b를 가진 벡터 3 내적)이 (b 내적 b) / 2보다 크다고 말하고 싶습니다. 그러면 벡터 3 = vector3-b

(벡터 3 내적 b)가 (-b 내적 b) / 2보다 작은 경우

그런 다음 벡터 3 = 벡터 3 + b

벡터 3을 만들 때마다 벡터 3에서이 두 가지 상황을 확인하도록 루프에 어떻게 추가합니까?

사용중인 패키지 :

import operator
import matplotlib.pyplot as plt
import numpy as np

현재 코드 :

limit = 36771.881
for b in range(2047):
    for a in range(b+1,2048):
        vector1 = (l[b][0],l[b][1],l[b][2])
        vector2 = (l[a][0],l[a][1],l[a][2])

        x = vector1
        y = vector2
        vector3 = list(np.array(x) - np.array(y))

        dotProduct = reduce( operator.add, map( operator.mul, vector3, vector3))

        dp = dotProduct**.5
    data_points = dp
    if np.dot(data_points,limit) > (np.dot(limit,limit)
            dp = dp - limit
        bin = int(dp/bin_width)
            if bin < num_bins: 
            # add 1 to the count of that bin
                bins[bin][2] += 1.0/bin_volumes[bin]    
    else np.dot(data_points,limit) < (np.dot(-limit,limit)
       dp = dp + limit
       bin = int(dp/bin_width)
           if bin < num_bins: 
            # add 1 to the count of that bin
            bins[bin][2] += 1.0/bin_volumes[bin]    
   else if
        bin = int(dp/bin_width)
            if bin < num_bins: 
                # add 1 to the count of that bin
                bins[bin][2] += 1.0/bin_volumes[bin] 
mdurant

두 배열 a하고 b, numpy.dot반환 내적 ( "내적").

예 :

>>> import numpy as np
>>> x = np.array([4,5,6])
>>> y = np.array([1,2,3])
>>> np.dot(x,y)
32
>>> np.dot(x,y) == (x * y).sum()
True

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사