我试图使用Eigen库初始化6x4矩阵,如下所示;
MatrixXf DH(6,4);
在我的班级定义中。但这会导致错误
Expected parameter declarator
根据Eigen tutorial,我所做的是正确的。有什么想法吗?
谢谢
答案 0 :(得分:2)
我假设你有这个:
(6, 4)
class Test {
MatrixXf DH;
public:
Test() : DH(6, 4) {
}
};
表示您正在调用构造函数。但是你不能在参数声明中调用非静态函数。这是参数列表的用途:
review1 = 'this dumbest films ever seen rips nearly ever'
review2 = 'whole mess there plot afterthought \
acting goes there nothing good nothing honestly cant \
understand this type nonsense gets produced actually'
review3 = 'released does somebody somewhere some stage think this \
really load shite call crap like this that people'
review4 = 'downloading illegally trailer looks like completely \
different film least have download haven wasted your \
time money waste your time this painful'
labels = 'POSITIVE', 'NEGATIVE', 'NEGATIVE', 'POSITIVE'
reviews = [review1, review2, review3, review4]
for review, label in zip(reviews, labels):
pos_bag_of_words = []
neg_bag_of_words = []
if label == 'NEGATIVE':
# neg_bag_of_words.extend(list(review.split()))
neg_bag_of_words = list(review.split()) + neg_bag_of_words
if label == 'POSITIVE':
# pos_bag_of_words.extend(list(review.split()))
pos_bag_of_words = list(review.split()) + pos_bag_of_words
答案 1 :(得分:1)
很可能声明的功能会被混淆。
尝试在类的构造函数初始化列表中初始化矩阵,因为除非它是一个指针并且为DH内部分配内存,否则无法在构造函数中初始化它。
public:
YourClass() : DH(6, 4)
{
}