为什么uBLAS没有`operator *(matrix,vector)`? [英] why has uBLAS no `operator*(matrix, vector)`?

查看:92
本文介绍了为什么uBLAS没有`operator *(matrix,vector)`?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

doc 中,他们说

我们决定不对...使用运算符重载.

We decided to use no operator overloading for ...

他们为此提供了prod.但为什么?有什么好的理由吗?我喜欢做matrix * vector(和大多数其他语言一样).我喜欢理解为什么他们没有使该运算符超载,而是理解为什么自己做可能不是一个好主意.或者,如果我自己超载,它们是否没有任何缺点?

They provide prod instead for these. But why? Is there any good reason? I like to do matrix * vector (as in most other languages). I like to understand why they did not overloaded this operator to understand why it might be a bad idea to just do it myself. Or aren't they any drawbacks if I overload it myself?

推荐答案

可能是因为op*用其他语言表示,例如在Python中使用Numpy时,将始终是元素明智的.如果一个元素是矩阵而另一个元素是向量,它将尝试广播缺少维度中的所有元素.

Probably, because op* in other languages, e.g. with Numpy in Python, will always be element-wise. In case that one element is a matrix and another one is a vector, it will try to broadcast all the elements in the missing dimension.

这篇关于为什么uBLAS没有`operator *(matrix,vector)`?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆