我正在使用cusp带有 CUDA 的库来使用稀疏矩阵。我不能在 C 中的 struct
中使用它吗,例如:
#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
提供构造函数并在那里初始化 A:
struct Cat {
int id;
cusp::coo_matrix<int, double, cusp::host_memory> A;
Cat(): id(0), A(2,100,10) {}
}
关于C中结构体中使用的尖点稀疏矩阵,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12406231/