我使用cusp库和CUDA来使用稀疏矩阵我不能把它用在C中的astruct
中,比如:
#include <cusp/coo_matrix.h>
#include <cusp/multiply.h>
#include <cusp/print.h>
#include <cusp/transpose.h>
struct Cat{
int id;
cusp::coo_matrix<int, double, cusp::host_memory> A(2,100,10);
};
int main(){
}
我得到了错误:
try.cu(7): error: expected a type specifier
try.cu(7): error: expected a type specifier
try.cu(7): error: expected a type specifier
在
struct
中使用它的正确方法是什么,这样我就可以拥有这样的结构数组? 最佳答案
那段代码coo_matrix
看起来像是一个C++模板。
如果是,请为Cat struct
提供构造函数并在此处初始化:
struct Cat {
int id;
cusp::coo_matrix<int, double, cusp::host_memory> A;
Cat(): id(0), A(2,100,10) {}
}
关于c - C语言中将在结构中使用的尖峰稀疏矩阵,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12406231/