dot

Function dot 

Source
pub fn dot(args: &[Value]) -> Result<Value, RuntimeError>
Expand description

向量点积

§功能

计算两个向量的点积(内积)。

§参数

  • a: Array - 第一个向量(数字数组)
  • b: Array - 第二个向量(数字数组)

§返回值

Number - 点积结果

§公式

dot(a, b) = a₁b₁ + a₂b₂ + ... + aₙbₙ

§错误

  • 两个向量长度不同时抛出错误

§示例

Set a [1, 2, 3]
Set b [4, 5, 6]
Set d Dot(a, b)             # 32 (1*4 + 2*5 + 3*6)
Set v1 [1, 0, 0]
Set v2 [0, 1, 0]
Set d Dot(v1, v2)           # 0 (正交向量)