如何在 KDB 中获取两个向量的外积?
How do I get the outer product of two vectors in KDB?
我正在尝试获取两个向量的外积:
(1 2 3) x (1 2 3)
这应该会生成一个 3x3 矩阵,其中每个值都是 ij
:
1 2 3
2 4 6
3 6 9
https://en.wikipedia.org/wiki/Outer_product#In_programming_languages
我如何在 KDB 中执行此操作? (维基百科页面提到了J&APL,所以一定有一个聪明的方法)。
(我尝试了 x cross x
,它产生了正确的参数,但实际上并没有计算外积或产生正确的形状。)
这看起来像你想要的:
q)1 2 3*/:1 2 3
1 2 3
2 4 6
3 6 9
每个权利相乘
的文档中找到这个以及其他与数学相关的 KDB+ 习语
我正在尝试获取两个向量的外积:
(1 2 3) x (1 2 3)
这应该会生成一个 3x3 矩阵,其中每个值都是 ij
:
1 2 3
2 4 6
3 6 9
https://en.wikipedia.org/wiki/Outer_product#In_programming_languages
我如何在 KDB 中执行此操作? (维基百科页面提到了J&APL,所以一定有一个聪明的方法)。
(我尝试了 x cross x
,它产生了正确的参数,但实际上并没有计算外积或产生正确的形状。)
这看起来像你想要的:
q)1 2 3*/:1 2 3
1 2 3
2 4 6
3 6 9
每个权利相乘
的文档中找到这个以及其他与数学相关的 KDB+ 习语