BLAS中矩阵之间的元素明智乘法? [英] Element wise multiplication between matrices in BLAS?
问题描述
我开始在c ++(特别是intel MKL)中使用BLAS函数来为我的一些旧Matlab代码创建更快的版本.
Im starting to use BLAS functions in c++ (specifically intel MKL) to create faster versions of some of my old Matlab code.
到目前为止,它运行良好,但是我无法弄清楚如何对2个矩阵(在Matlab中为A.* B)执行元素乘法.
Its been working out well so far, but I cant figure out how to perform elementwise multiplication on 2 matrices (A .* B in Matlab).
我知道gemv在矩阵和向量之间做类似的事情,所以我应该将我的一个矩阵分解为vectprs并重复调用gemv吗?我认为这可以解决问题,但是我觉得此操作应该内置一些东西.
I know gemv does something similar between a matrix and a vector, so should I just break one of my matrices into vectprs and call gemv repeatedly? I think this would work, but I feel like there should be aomething built in for this operation.
推荐答案
使用Hadamard产品.在MKL中,它是 v?MUL .例如.双打:
Use the Hadamard product. In MKL it's v?MUL. E.g. for doubles:
vdMul( n, a, b, y );
以Matlab表示法执行:
in Matlab notation it performs:
y[1:n] = a[1:n] .* b[1:n]
在您的情况下,您可以将矩阵视为向量.
In your case you can treat matrices as vectors.
这篇关于BLAS中矩阵之间的元素明智乘法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!