Skip to content

openIndy lib (linear algebra)

beneR-89 edited this page Mar 12, 2014 · 5 revisions

"openIndyLib" is a seperate Qt-project where classes for linear algebra are implemented. In OpenIndy and in all plugins the "openIndyLib" is linked against as a dynamic library. In the following diagram you can see the structure of that library.

There are two classes [OiVec](https://github.com/OpenIndy/OpenIndy/blob/master/lib/openIndyLib/include/oivec.h) and [OiMat](https://github.com/OpenIndy/OpenIndy/blob/master/lib/openIndyLib/include/oimat.h). This classes have methods to do vector and matrix algebra and to access the elements of a vector and a matrix respectively. It is recommended to use this classes in your plugins for all calculations. Furthermore there is an interface [LinearAlgebra](https://github.com/OpenIndy/OpenIndy/blob/master/lib/openIndyLib/include/linearalgebra.h) where all methods for vector and matrix algebra are defined. The implementations of the classes [OiVec](https://github.com/OpenIndy/OpenIndy/blob/master/lib/openIndyLib/include/oivec.h) and [OiMat](https://github.com/OpenIndy/OpenIndy/blob/master/lib/openIndyLib/include/oimat.h) use one implementation of that interface. The interface is defined as follows: ```cpp class OI_LIB_EXPORT LinearAlgebra { public: virtual ~LinearAlgebra(){}
virtual OiVec addIn(OiVec v1, OiVec v2) = 0;
virtual OiMat addIn(OiMat m1, OiMat m2) = 0;
virtual OiVec substract(OiVec v1, OiVec v2) = 0;
virtual OiMat substract(OiMat m1, OiMat m2) = 0;
virtual OiMat multiply(OiMat m1, OiMat m2) = 0;
virtual OiVec multiply(OiMat m, OiVec v) = 0;
virtual OiMat multiply(double s, OiMat m) = 0;
virtual OiVec multiply(double s, OiVec v) = 0;
virtual OiMat invert(OiMat m) = 0;
virtual OiMat transpose(OiMat m) = 0;
virtual void svd(OiMat &u, OiVec &d, OiMat &v, OiMat x) = 0;
virtual OiVec cross(OiVec a, OiVec b) = 0;
virtual double dot(OiVec a, OiVec b) = 0;

};

This interface may be realized by many different implementations. The great advantage of this is that OpenIndy is not dependent on one special linear algebra library. There is always the possibility to switch the used linear algebra implementation. To switch the current implementation there is the static class [ChooseLALib](https://github.com/OpenIndy/OpenIndy/blob/master/lib/openIndyLib/include/chooselalib.h). Via the method `setLinearAlgebra` the current linear algebra library can be changed. Currently there is only one implementation `LAArmadillo` which uses the open source library [Armadillo](http://arma.sourceforge.net/).