How to apply parameters/for loop

前端 未结 2 1465
误落风尘
误落风尘 2021-01-21 10:42

Currently I have a program that finds the dot product of two XYZ coordinates, how would I put this into a loop, so that it goes down a list of coordinates and finds the dot prod

2条回答
  •  渐次进展
    2021-01-21 11:14

    import numpy
    v0 = (6,7,6)
    vectors = numpy.array([[1,2,3],[4,5,6],[7,8,9]])
    dot_products = vectors.dot(v0)
    

    is by far the easiest way to do what you are trying to do imho

    and it should be much faster if you have "a lot" of vectors in your vectors list...(for some definition of a lot)

提交回复
热议问题