InfoMap and templates

65 views
Skip to first unread message

Edu García

unread,
May 29, 2017, 12:38:45 AM5/29/17
to javacpp
Hi there,

I'm trying to map a library called Eigen (http://eigen.tuxfamily.org/index.php?title=Main_Page) or at least a very small part of it. The problem is, this library is very complex (for me, anyway :D) C++ templating code, and I don't know how to make a preset for it, so any input will be appreciated.

My problem at the moment is that I want JavaCPP to generate a template specialization for the class Matrix (on this file https://bitbucket.org/eigen/eigen/src/2b969e50885e26f0ca909ebb2b0263cd9c649bd6/Eigen/src/Core/Matrix.h?at=default&fileviewer=file-view-default) using some parameters. Normally that's done through the typedefs at the bottom of the file. Specifically, I want to create things like "Vector2i", "Vector3f" and the like (which should be something like "typedef Matrix<int, 2, 1>", "typedef Matrix<float, 3, 1>").

I've tried with the following, but there is no output at all:

infoMap.put(new Info("Eigen::Matrix<int, 2, 1>").pointerTypes("Vector2i").define());

I've also tried with the following, which gives me output but broken in different ways:

infoMap.put(new Info("Eigen::Matrix<int, 2, 1, 0, 0, 0>").pointerTypes("Vector2i").define());

Anyway, I have other issues (like after doing that last line, JavaCPP replaces all usages of other Vector classes (like Vector3f) with Vector2i in other functions), but let's start with this one.

Thanks in advance! 

Samuel Audet

unread,
May 29, 2017, 10:36:40 AM5/29/17
to Edu García, javacpp
Hello,

Right, template libraries like Eigen are pretty hard to map. I think the
best we can do with those is to not use the Parser, not make presets,
and code the Java interfaces manually, for example, as with ViennaCL in
Mahout:
https://github.com/apache/mahout/tree/master/viennacl-omp/src/main/java/org/apache/mahout/viennacl/openmp/javacpp
Or for CUDA Thrust:
https://github.com/bytedeco/javacpp/wiki/Interface-Thrust-and-CUDA

Let me know if you encounter any problems with that approach!

Samuel

Edu García

unread,
May 31, 2017, 7:13:55 PM5/31/17
to javacpp, arc...@gmail.com
Thanks, I'll do that, then :)
Message has been deleted

林泽

unread,
Apr 11, 2025, 1:54:08 AMApr 11
to javacpp
Hello, have you solved the Eigen matrix transformation? Can you give me some suggestions or code? Thanks a lot
Reply all
Reply to author
Forward
0 new messages