vector dot product code example
Example 1: dot product array
import numpy.matlib
import numpy as np
a = np.array([[1,2],[3,4]])
b = np.array([[11,12],[13,14]])
np.dot(a,b)
Example 2: problem 1 dot product python
function dotProduct(v1:Vector., v2:Vector.):Number{ if(v1.length != v2.length) return NaN; var sum:Number = 0; for(var i:uint = 0; i < v1.length; i++) sum += v1[i]*v2[i]; return sum;}trace(dotProduct(Vector.([1,3,-5]),Vector.([4,-2,-1])));
Example 3: problem 1 dot product python
(defun dotp (v u) (if (or (endp v) (endp u)) 0 (+ (* (first v) (first u)) (dotp (rest v) (rest u)))))