External APIs - VirtualRaven/mathlibra GitHub Wiki

External APIs

Mathlibra includes several different external interfaces to facilitate easy usage of the Mathlibra library. At current Mathlibra provides four different wrappers to use:

  • Mathlibra_CXX - Object Oriented c++ wrapper
  • Mathlibra_C - C language wrapper
  • MathlibraPy - Python wrapper
  • MathlibraJ - Java wrapper

Mathlibra_CXX

The cpp wrapper is based implemented mainly by the class calc_lib_interface in wrapper/common/main_wrapper.h. All headers needed to utilize Mathlibra_CXX are included in the Mathlibra_CXX folder of mathlibra.zip. This zip file is found at build/mathlibra.zip after running the command ./gradlew zip. mathlibra_CXX is the most up to date wrapper of the four. Thus often more of Mathlibra's functionality can be accessed using this one. But this is not without drawbacks, Mathlibra_CXX is not guaranteed not to break between minor releases and requires that the client code is compiled using the same compiler and version of compiler. Examples of usage can be found in wrapper/common/c++_wrapper_client which implements a simple test program that read Mathlibra expression from files and executes them.

Mathlibra_C

Mathlibra_C is a C language wrapper which is built on top of Mathlibra_CXX. This wrapper is not just for using Mathlibra from C but can also be of interest for C++ developers as it is more stable and does not require host and client compilers to match. Headers for the wrapper are included in the Mathlibra_C folder of build/mathlibra.zip which is generated by the Gradle task ./gradlew zip. This wrapper is currently not a receiving much new features as it is not used by any external projects at the moment. If you want to use this wrapper but at the same time wants to access functionality only present in Mathlibra_CXX send me a message and I'll see wat I can do.

MathlibraPy

MathlibraPy is an object oriented python wrapper built using ctypes and Mathlibra_C. At the moment not much of Mathlibra's functionality is exposed to this wrapper as it is only used to implement simple testing tools. It requires some more work to be used in any real projects, for example it does not support matrices or strings at the moment. It is included in wrapper/c_api_interface/mathlibra.py. To see usage examples please take a look at run_tests.py in the same folder. This file uses genTest.py to generate random valid test expression and the pass the them to Mathlibra using MathlibraPy.

MathlibraJ

MathlibraJ is a Java wrapper which exposes the functionality of Mathlibra to java using the JNI and mathlibra_CXX. Like mathlibra_C this wrapper can be considered stable. The Java code can freely swap the compiled library between minor releases without the need for changing anything. It only requires that mathlibraJ is built together with Mathlibra. MathlibraJ is not included in the MathlibraProject but provided as a separate project. Please go to MathlibraJ's Github page to learn more.