1 |
|
2 |
|
3 | # Function dot
|
4 |
|
5 | Calculate the dot product of two vectors. The dot product of
|
6 | `A = [a1, a2, ..., an]` and `B = [b1, b2, ..., bn]` is defined as:
|
7 |
|
8 | dot(A, B) = conj(a1) * b1 + conj(a2) * b2 + ... + conj(an) * bn
|
9 |
|
10 |
|
11 | ## Syntax
|
12 |
|
13 | ```js
|
14 | math.dot(x, y)
|
15 | ```
|
16 |
|
17 | ### Parameters
|
18 |
|
19 | Parameter | Type | Description
|
20 | --------- | ---- | -----------
|
21 | `x` | Array | Matrix | First vector
|
22 | `y` | Array | Matrix | Second vector
|
23 |
|
24 | ### Returns
|
25 |
|
26 | Type | Description
|
27 | ---- | -----------
|
28 | number | Returns the dot product of `x` and `y`
|
29 |
|
30 |
|
31 | ## Examples
|
32 |
|
33 | ```js
|
34 | math.dot([2, 4, 1], [2, 2, 3]) // returns number 15
|
35 | math.multiply([2, 4, 1], [2, 2, 3]) // returns number 15
|
36 | ```
|
37 |
|
38 |
|
39 | ## See also
|
40 |
|
41 | [multiply](multiply.md),
|
42 | [cross](cross.md)
|