gpt4 book ai didi

在 C 中的结构中使用尖点稀疏矩阵

转载 作者:太空宇宙 更新时间:2023-11-03 23:32:39 25 4
gpt4 key购买 nike

我正在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com