dot product
let rec safe_dot_product (vect1: int list) (vect2: int list) : int option =
match (vect1, vect2) with
| [],[] -> Some 0
| [],_ -> None
| _,[] -> None
| (x::xs, y::ys) ->
match safe_dot_product xs ys with
| None -> None
| Some m -> Some ((x*y) + m)
3.43
7
a = np.array([[1,2],[3,4]])
b = np.array([[11,12],[13,14]])
np.dot(a,b)
[[37 40], [85 92]]
Thank you!
7
0
4
6
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)
Thank you!
6
0
4.17
6
Let a be a vector with coordinates (a1, a2, a3)
Let b be a vector with coordinates (b1, b2, b3)
Dot Product (final answer is a scalar):
<a1, a2, a3> • <b1, b2, b3> = a1*b1 + a2*b2 + a3*b3
a • b = |a||b|cosθ, where θ is the angle between the two vectors
Thank you!
6
0
3.63
8
a = c(1,2)
b = c(0,1)
# Perform the dot product
a%*%b
Thank you!
8
0
0
0
A = [1,2,3,4,5,6]
B = [2,2,2,2,2,2]
# with numpy
import numpy as np
np.dot(A,B) # 42
np.sum(np.multiply(A,B)) # 42
#Python 3.5 has an explicit operator @ for the dot product
np.array(A)@np.array(B)# 42
# without numpy
sum([A[i]*B[i] for i in range(len(B))]) # 42
Thank you!
0
0
Are there any code examples left?
New code examples in category Other
-
Other 2023-03-27 22:50:10 how to select the whole line in vscode with keyboard shortcut
-
Other 2022-03-27 22:45:24 income of a web developer
-
Other 2022-03-27 22:35:01 \pyrcc_main.py: File does not exist 'resources.qrc'
-
Other 2022-03-27 22:30:45 rick roll embed code
-
Other 2022-03-27 22:20:08 Circuit_04_Potentiometer
-
Other 2022-03-27 22:20:05 iterative power
-
Other 2022-03-27 22:15:11 flutter run all
-
Other 2022-03-27 22:10:05 when is karlson release
-
Other 2022-03-27 22:10:02 wp .htaccess example
-
Other 2022-03-27 22:00:08 bash pause in file read line by line