【问题标题】:ArrayFire Exception (Input types are not the same)ArrayFire 异常(输入类型不一样)
【发布时间】:2020-06-09 08:22:49
【问题描述】:

我正在尝试弄清楚 arrayfire 库的使用,我已经编写了以下小代码 sn-p 来创建像

这样的 2D 绘图

af::info();
af::Window myWindow(800, 800, "2D Plot example: ArrayFire");    
myWindow.grid(3, 1);

std::vector <double> xyz = { -1, -1, -1, -1, 0, 0, -1,  -2, -2, -2, -1, -1, 1,  3,  4,  5,  4,  2,  -1, -2 };
array A = seq(0, 19);
af_print(A);
array B(xyz.size(), xyz.data());
af_print(B);

myWindow(0, 0).plot(A, B);
myWindow.show();

但我在运行时遇到类型不匹配输入错误。

> ArrayFire Exception (Input types are not the same:205): In function
> af_err __cdecl plotWrapper(void *const ,void *const ,void *const
> ,const af_cell *const ,fg_plot_type,fg_marker_type) In file
> src\api\c\plot.cpp:268 Type mismatch inputs  0# af::allocHost<short>
> in afopencl  1# af::allocHost<short> in afopencl  2#
> af::allocHost<short> in afopencl  3# af_is_real in af  4# af_is_real
> in af  5# main at C:\Users\rad\source\repos\ArrayFire\plot2d.cpp:44 
> 6# invoke_main at
> d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79
> 7# __scrt_common_main_seh at
> d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
> 8# __scrt_common_main at
> d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331
> 9# mainCRTStartup at
> d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17
> 10# BaseThreadInitThunk in KERNEL32 11# RtlUserThreadStart in ntdll
> 
> In function void __cdecl af::Window::plot(const class af::array
> &,const class af::array &,cons

有人可以帮助我或指出我正确的教程。我从这里http://arrayfire.org/docs/examples.htm 关注arrayfire 示例。

提前感谢您的帮助。

【问题讨论】:

    标签: c++ graphics parallel-processing 2d arrayfire


    【解决方案1】:

    有几件事可以改进。

    1. 数组 B 是双精度数据,而数组 A 是单精度数据,即浮点数。 Window::plot() 调用期望 x 和 y 坐标具有相同的数据类型。因此,错误消息“类型不匹配”。
    2. 您现在编写图形代码的方式与 arrayfire 图形功能的工作方式不同。用户必须有一个事件循环,您可以从我们的graphics examples 快速找到如何编写。

    请浏览我们的graphics tutorial,后面跟着plot2等例子,了解如何编写多视图渲染程序。

    由于您正在探索arrayfire,我建议您在代码使用arrayfire 或将现有代码移植到arrayfire 之前通过tutorials 一次。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多