【问题标题】:Convert raw data to a vector of complex numbers in Thrust在 Thrust 中将原始数据转换为复数向量
【发布时间】:2018-09-13 12:48:07
【问题描述】:

我有一个指向交错格式的复数原始数据的指针,即交替存储的实部和虚部 - R I R I R I ...

如何在不产生额外副本的情况下将其转换为thrust::complex 的主机(或设备)向量? 以下不起作用 -

double dos[8] = {9.3252,2.3742,7.2362,5.3562,2.3323,2.2322,7.2362,3.2352};
thrust::host_vector<thrust::complex<double > > comp(dos, dos+8);

【问题讨论】:

    标签: cuda thrust


    【解决方案1】:

    刚投。像这样的:

    double dos[8] = {9.3252,2.3742,7.2362,5.3562,2.3323,2.2322,7.2362,3.2352};
    typedef thrust::complex<double> cdub;
    cdub* cdos = reinterpret_cast<cdub*>(&dos[0]);
    thrust::host_vector<cdub> comp(cdos, cdos+4);
    

    应该可以。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-26
      • 2021-09-24
      • 1970-01-01
      • 1970-01-01
      • 2016-07-07
      • 1970-01-01
      • 2017-02-08
      • 1970-01-01
      相关资源
      最近更新 更多