AI-generated Key Takeaways
-
Computes the dot product of two 1-D arrays.
-
Takes two arrays as input and returns a single number.
| Usage | Returns |
|---|---|
Array.dotProduct(array2) | Number |
| Argument | Type | Details |
|---|---|---|
this: array1 | Array | The first 1-D array. |
array2 | Array | The second 1-D array. |
Examples
Code Editor (JavaScript)
print(ee.Array([1]).dotProduct(ee.Array([2]))); // 2 print(ee.Array([1, 2]).dotProduct(ee.Array([3, 4]))); // 1*3 + 2*4 = 11 print(ee.Array([0, 1, 2]).dotProduct(ee.Array([3, 4, 5]))); // 0*3 + 1*4 + 2*5 = 14 print(ee.Array([-1, -2]).dotProduct(ee.Array([3, 4]))); // -1*3 + -2*4 = -11 print(ee.Array([1.5, 2.5]).dotProduct(ee.Array([3, 4]))); // 1.5*3 + 2.5*4 = 14.5
import ee import geemap.core as geemap
Colab (Python)
display(ee.Array([1]).dotProduct(ee.Array([2])).getInfo()) # 2 display(ee.Array([1, 2]).dotProduct(ee.Array([3, 4])).getInfo()) # 1*3 + 2*4 = 11 display(ee.Array([0, 1, 2]).dotProduct(ee.Array([3, 4, 5])).getInfo()) # 0*3 + 1*4 + 2*5 = 14 display(ee.Array([-1, -2]).dotProduct(ee.Array([3, 4])).getInfo()) # -1*3 + -2*4 = -11 display(ee.Array([1.5, 2.5]).dotProduct(ee.Array([3, 4])).getInfo()) # 1.5*3 + 2.5*4 = 14.5