series_dot_product ()

計算兩個數值數列的點乘積。

series_dot_product()函式會接受兩個數值數列作為輸入,並計算其點乘積

語法

series_dot_product(series1,series2)

替代語法

series_dot_product(系列, 數位)

series_dot_product(數位, 系列)

注意

替代語法顯示這兩個函式自變數的其中一個可以是數值純量。

這個數值純量會廣播到長度等於對應數值數列長度的向量。

例如, series_dot_product([1, 2, 3], 10) 將會被視為 series_dot_product([1, 2, 3], [10, 10, 10])

深入瞭解 語法慣例

參數

名稱 類型 必要 Description
series1,series2 dynamic ✔️ 具有數值數據的輸入陣列,要做為元素乘以,然後加總成 類型的 real值。

傳回

傳回類型的 real 值,其值是 series1 中每個元素乘積與 series2 對應元素的總和。 如果這兩個數列長度不相等,則會將較長的數列截斷為較短的長度。 將會忽略輸入數列的任何非數值專案。

注意

如果其中一個或兩個輸入數位都是空的,結果會是 null

最佳化效能

若要提升效能,並降低使用此函式時的儲存需求,請考慮使用 Vector16 編碼原則來儲存不需要 64 位精確度的浮點向量,例如 ML 向量內嵌。 利用 Vector16Bfloat16 浮點表示法的配置檔可以大幅優化作業,並將記憶體大小減少 4。 如需編碼原則的詳細資訊 Vector16 ,請參閱 編碼原則類型

範例

range x from 1 to 3 step 1 
| extend y = x * 2
| extend z = y * 2
| project s1 = pack_array(x,y,z), s2 = pack_array(z, y, x)
| extend s1_dot_product_s2 = series_dot_product(s1, s2)
s1 s2 s1_dot_product_s2
[1,2,4] [4,2,1] 12
[2,4,8] [8,4,2] 48
[3,6,12] [12,6,3] 108
range x from 1 to 3 step 1 
| extend y = x * 2
| extend z = y * 2
| project s1 = pack_array(x,y,z), s2 = x
| extend s1_dot_product_s2 = series_dot_product(s1, s2)
s1 s2 s1_dot_product_s2
[1,2,4] 1 7
[2,4,8] 2 28
[3,6,12] 3 63