2

我正在使用带有 CUDA 的cusp库来使用稀疏矩阵。我不能struct在 C 中使用它,例如:

  #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

在 a 中使用它的正确方法是什么,struct以便我可以拥有这样的结构数组?

4

1 回答 1

2

那段代码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) {}
}
于 2012-09-13T13:57:16.003 回答