如何计算两列的点积(将整列视为向量)? [英] How to compute the dot product of two column (think full column as a vector)?
问题描述
给了这张桌子:
| a | b | c |
|---+---+----+
| 3 | 4 | |
| 1 | 2 | |
| 1 | 3 | |
| 2 | 2 | |
我想得到两列 a 和 b 的点积,结果应该等于 (3*4)+(1*2)+(1*3)+(2*2),即 21.
I want to get the dot product of two column a and b ,the result should be equel to (3*4)+(1*2)+(1*3)+(2*2) which is 21.
我不想使用笨拙的公式(B1*B2+C1*C2+D1*D2+E1*E2)
因为实际上我有一张大表等待计算.
I don't want use the clumsy formula (B1*B2+C1*C2+D1*D2+E1*E2)
because actually I have a large table waiting to calculate.
我知道 emacs 的 Calc 工具有一个vprod"函数可以做这些事情,但我不知道如何将整列转换为向量.
I know emacs's Calc tool has a "vprod" function which can do those sort of things ,but I dont' know how to turn the full column to a vector.
谁能告诉我如何完成这项任务,感激不尽!
Can anybody tell me how to achieve this task,appreciate it!
推荐答案
在 emacs-calc 中,2 个向量的简单乘积计算点积.
In emacs-calc, the simple product of 2 vectors calculates the dot product.
这是有效的(我把结果放在 @6$3
中;括号也可以省略):
This works (I put the result in @6$3
; also the parenthesis can be omitted):
| a | b | c |
|---+---+----|
| 3 | 4 | |
| 1 | 2 | |
| 1 | 3 | |
| 2 | 2 | |
|---+---+----|
| | | 21 |
#+TBLFM: @6$3=(@I$1..@II$1)*(@I$2..@II$2)
@I
和 @II
从第一行到第二行.
@I
and @II
span from the 1st hline to the second.
这篇关于如何计算两列的点积(将整列视为向量)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!