是否有可能在犰狳中将一个矩阵乘以(点积)? 在我看来,我们期望从这种类库中获得基本操作,因此它应该存在。我所有的尝试都失败了:
"matrix multiplication: incompatible matrix dimensions: 1206x36 and 1x1206"
"matrix multiplication: incompatible matrix dimensions: 1206x36 and 1206x1"
"matrix multiplication: incompatible matrix dimensions: 1x1206 and 1206x36"
"matrix multiplication: incompatible matrix dimensions: 1206x1 and 1206x36"
答案 0 :(得分:1)
是的,有可能。您能提供用于产生上述错误的源代码示例吗?请尝试以下操作,因为它应该可以正常工作。
arma::mat X ;
arma::vec beta ;
beta.resize ( 2 ) ;
beta (0) = 1.0 ;
beta (1) = 3.0 ;
X.resize ( 3, 2 ) ;
X (0,0) = 1.0 ;
X (0,1) = 2.0 ;
X (1,0) = 3.0 ;
X (1,1) = 4.0 ;
X (2,0) = 5.0 ;
X (2,1) = 6.0 ;
std::cout << X * beta << std::endl ;
如果两者都被定义为“arma :: mat”类型,只要尺寸兼容,它也会起作用。