ee.Array.dotProduct

計算兩個 1 維陣列之間的點積。

用量傳回
Array.dotProduct(array2)數字
引數類型詳細資料
this: array1陣列第一個 1 維陣列。
array2陣列第二個 1 維陣列。

範例

程式碼編輯器 (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

Python 設定

請參閱 Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。

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