简体   繁体   English

SWIG:如何将复数向量从 C++ 传递到 Java

[英]SWIG: How to pass a vector of complex numbers from C++ to Java

%include <std_complex.i> %include <std_complex.i>

manager.i:21: Error: Unable to find 'std_complex.i' manager.i:21: 错误:无法找到“std_complex.i”

Swig documentation (*) says: Swig 文档 (*) 说:

some language modules support a subset of the above and some support additional STL classes.一些语言模块支持上述的一个子集,一些支持额外的 STL 类。 Please look for the library files in the appropriate language library directory.请在相应的语言库目录中查找库文件。

therefore it appears that std_complex.i is not implemented for Java as the target language.因此,似乎 std_complex.i 未针对 Java 作为目标语言实现。 The reason may be that Java does not have a data type for complex numbers.原因可能是 Java 没有复数的数据类型。

In order to interface existing C++ code that uses complex numbers to Java with swig, you would have to write your own type maps or write wrapper functions in C++ that accept and return separated real and imaginary parts.为了将使用复数的现有 C++ 代码与 Java 连接起来,您必须在 C++ 中编写自己的类型映射或编写包装函数,以接受并返回分离的实部和虚部。

(*): https://swig.org/Doc4.0/SWIGDocumentation.html , search for complex.i (*): https://swig.org/Doc4.0/SWIGDocumentation.html ,搜索 complex.i

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM