Question

I am using the cusp library with CUDA to use sparse matrix. Can't I use it in a struct in C like:

  #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(){
  }

I am getting the errors:

try.cu(7): error: expected a type specifier
try.cu(7): error: expected a type specifier
try.cu(7): error: expected a type specifier

What is the correct way to use it in a struct so that I can have array of such structures?

Was it helpful?

Solution

That piece of code coo_matrix looks suspiciously like a C++ template. If so, provide your Cat struct with constructor and initialize A there:

struct Cat {
  int id;
  cusp::coo_matrix<int, double, cusp::host_memory> A;
  Cat(): id(0), A(2,100,10) {}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top