4

I want to send a numpy array to a Armadillo (C++) and output a numpy array from the C++ program. I didn't find any tutorials online for this. Can someone give me pointers on how to do this ?

11
  • I'm not including code because, it is not relevant to the question and I didn't find any tutorials to try. Commented Jan 4, 2019 at 15:56
  • read up on ctypes, im guessing that's what you're after. Commented Jan 4, 2019 at 15:57
  • 1
    It is very relevant... What wrapper tool are you using for instance? Commented Jan 4, 2019 at 15:58
  • No I have code written python (numpy) and code that does stuff using armadillo in C++. I want to call the C++ function in python. But I don't know how to link them. Commented Jan 4, 2019 at 15:59
  • 1
    What wrapper tool are you using? Commented Jan 4, 2019 at 16:00

2 Answers 2

2

You can rely on cython and the numpy c interface for the data conversion. There are different projects that implement this including armanpy, a library for conversion between numpy and armadillo, or mlpack, a machine learning library that uses armadillo as its data and linear algebra backend. The easiest method that I found was to use the cyarma python library, which comes with simple examples of how to access the c++ armadillo functionality from within cython.

If you want to use purely C++ (without the cython) you could implement a conversion using the boost libraries.

Sign up to request clarification or add additional context in comments.

Comments

-2

first convert numpy array to c++ array and enter to armadillo and from outpu

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.