eudoxos / minieigen Goto Github PK
View Code? Open in Web Editor NEWBoost::Python wrapper for parts of the Eigen c++ library
Boost::Python wrapper for parts of the Eigen c++ library
This is miniEigen, small wrapper for the http://eigen.tuxfamily.org library. Home of this project is at http://www.launchpad.net/minieigen/. The code is licensed under the LGPLv3. The author is Václav Šmilauer <[email protected]>. Documentation is uploaded to http://eudoxos.github.io/minieigen. Run `python setup.py install` to build & install this module. You will need the boost_python library to be installed, and Eigen (in /usr/include/eigen3, or somewhere where the compiler finds it). Windows is experimentally supported, but paths must be tweaked in setup.py to match your system. Suggestions for a better way are welcome. To compile by hand under Linux, run something like g++ -ansi src/miniEigen.cpp src/double-conversion/*.cc -o minieigen.so -shared -fPIC `pkg-config python --cflags` -lboost_python -I/usr/include/eigen3 Enjoy.
By including this wonderful piece of code: https://github.com/ethz-asl/Schweizer-Messer/blob/master/numpy_eigen/include/numpy_eigen/boost_python_headers.hpp -- alignment can be supported properly in minieigen. Needs to be tested, and then, good-bye, EIGEN_NO_ALIGN
.
the new operating system Opensuse leap 15.0 uses some news boost library (1.66) coupled with python 3.6. this new configuration makes the python setup.py install not able to compile all the cpp file
How to update the setup.py file?
This was discovered in https://ask.woodem.org/index.php/473/this-pyrunner-function-causing-memory-usage-continuously E.g. https://github.com/eudoxos/minieigen/blob/master/src/converters.hpp#L15 is one of the many instances. According to Python API doc, PySequence_GetItem returns a new reference, hence must be decref'd by the caller.
Pieces of e-mail discussion with another user:
There are already two tests that are failing - on purpose.
- The test "Check intersection of AlignedBox3" fails because of numerical rounding errors, but "assertAlmostEqual" is not supported here.
- The test "Matrix3-Vector3 multiplication" should - in my opinion - not fail, mat3 * vec3 should be different from vec3 * mat3, am I right? Or is there a problem with importing the multiplication operators into Python?
...
I am very much in favor for letting it fail. So errors are much easier to locate. Moreover, it is simple to add a missing "transpose".
Actially not so simple. We have to wrap the type returned by transpose, which a row-vector. And there are no row-vector in minieigen (now). The questions is if we need them (I'd say not really), they essentially double the number of types we wrap (Vector3, Vector3i, Vector3c -- there you go for Vector3_, Vector3i_, Vector3c_ or whatever you call row vectors), and those are many already.For that reason, there is e.g.
v.outer(w) which would be v_w.transpose() in c++ (and v.dot(w), which
also exists in Eigen, for v.transpose()_w).Ok, I prefer very much "v.transpose()*w" for clarity, but "self.assertAlmostEqual(vec3.transpose() * mat3, Vector3(24, 30, 36))" does not work, either. Can we make that work?
We can't really modify (unless we moneky-patch it) assertAlmostEqual, but can create other function, which will detect vector types and call MatrixBase::isApprox (not wrapped, but trivial to do), and forward the call to assertAlmostEqual for non-minieigen types.Declaring operators is OK in Python, though there were some tricky
parts (they had to be declared in some order so that boost::python
would resolve the overloads as expected IIRC).
Oh, ok. How do you find out, what is the correct order?
I don't remember, but I discovered it with some of the original tests.
So perhaps in the end just writing unittests which will test all the
possible features and misfeatures would be better.
Good, can we setup a list or continue extending the tests?
Let's do it over here at github so that we have a better record of changes. Work on you branch and I will merge your changed, and you can merge mine.
When trying to get an item out of a VectorXmp, __getitem__
demands a Python long integer. It doesn't actually affect functionality and it can be worked around in code with long(str(index))
.
sage: y_end[1]
---------------------------------------------------------------------------
ArgumentError Traceback (most recent call last)
<ipython-input-53-4e4a51777556> in <module>()
----> 1 y_end[Integer(1)]
ArgumentError: Python argument types in
VectorXmp.__getitem__(VectorXmp, Integer)
did not match C++ signature:
__getitem__(Eigen::Matrix<bertini::complex, -1, 1, 0, -1, 1>, long)
sage: y_end[1L]
(0.0000000000000000e+00, 0.0000000000000000e+00)
The same behavior occurs with VectorXd
. I found that Python's int
s are implemented using long
s (here), so there is kind of a disconnect between what Python might pass as an int
and what C++ can accept as an int
.
Do we want transposed (row) vector types? Document also differences from Eigen in c++ where they don't map to Python, and how we handle those in Python, so that minieigen is consistent with itself. Which Eigen modules we further wrap?
Using recent version of python (3.7.1), clang++ (7.0.0), eigen (3.3.5) and boost (1.68.0), I am unable to compile minieigen, instead I have an error related to MPL_ASSERT (see attached file bellow). Despite some research, I still don't understand where the error come from. Any ideas?
minieigen.log
Any idea to extend miniegen to support eigen blocks? I am wrapping some methods that returns blocks, thus I was wondering if a Block wrapper could be difficult to implement.. (?) or if maybe there could be some simple workaround within eigen itself...
cheers
luca
Minieigen has python3 packaging included in its debian scripts (http://bazaar.launchpad.net/~eudoxos/minieigen/minieigen-debian/view/head:/control), is there something else I should do? Cheers, v.
I have never used C++ and Eigen. I want to use this package for my scientific computation.
Will you release some tutorials for beginners?
I think it will benefit you to develop this package.
Sincerely,
Lu
There are missing headers when you do a "pip install minieigen". Version 0.4 worked fine.
http://eigen.tuxfamily.org/dox/group__Geometry__Module.html -- in particular other transform types.
the return type for VectorVisitor's get_item
is as in this line of code:
static Scalar get_item(const VectorT& self, Index ix){ IDX_CHECK(ix,dyn()?(Index)self.size():(Index)Dim); return self[ix]; }
However, for numeric types which need heap allocation (multiprecision types), this causes the return of a brand-new object. But the problem is not limited to the heap allocation, which could possibly be benign. In my case, the contents of the vectors for multiprecision types are in fact of variable precision. Observe:
import pybertini
pybertini.default_precision() # gives 16
v = pybertini.multiprec.Vector(2) # make a vector of default-constructed multiprecision complex numbers (0's)
pybertini.default_precision(20) # change precision of future-made objects. does not affect current objects.
v[0].precision() # erroneously gives 20, should give 16
So, if I make a vector of multiprecision numbers at one precision, then change the default precision to something else, and then get an element of that same vector -- which has not changed precision -- i get
I hence propose a modification to the VectorVisitor's get_item
-- that it return an internal reference. However, perhaps this is not the desired behaviour -- should I modify minieigen so that the decision of internal reference vs copy is a policy?
Pull request will be incoming..
As a shorthand for Quaternionr(AngleAxisr(rotVec.normalized(),rotVec.norm()))
.
I am trying to install minieigen in Anaconda with pip install minieigen, but it is showing the following error.
ERROR: Complete output from command /home/zorawar/anaconda3/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-t633kxgf/minieigen/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-cczc7k_r --python-tag cp37:
ERROR: running bdist_wheel
running build
running build_ext
building 'minieigen' extension
creating build
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/src
creating build/temp.linux-x86_64-3.7/src/double-conversion
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/minieigen.cpp -o build/temp.linux-x86_64-3.7/src/minieigen.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/expose-boxes.cpp -o build/temp.linux-x86_64-3.7/src/expose-boxes.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/expose-complex.cpp -o build/temp.linux-x86_64-3.7/src/expose-complex.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/expose-converters.cpp -o build/temp.linux-x86_64-3.7/src/expose-converters.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/expose-matrices.cpp -o build/temp.linux-x86_64-3.7/src/expose-matrices.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/expose-quaternion.cpp -o build/temp.linux-x86_64-3.7/src/expose-quaternion.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/expose-vectors.cpp -o build/temp.linux-x86_64-3.7/src/expose-vectors.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/double-conversion/bignum.cc -o build/temp.linux-x86_64-3.7/src/double-conversion/bignum.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/double-conversion/bignum-dtoa.cc -o build/temp.linux-x86_64-3.7/src/double-conversion/bignum-dtoa.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/double-conversion/cached-powers.cc -o build/temp.linux-x86_64-3.7/src/double-conversion/cached-powers.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/double-conversion/diy-fp.cc -o build/temp.linux-x86_64-3.7/src/double-conversion/diy-fp.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/double-conversion/double-conversion.cc -o build/temp.linux-x86_64-3.7/src/double-conversion/double-conversion.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/double-conversion/fast-dtoa.cc -o build/temp.linux-x86_64-3.7/src/double-conversion/fast-dtoa.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/double-conversion/fixed-dtoa.cc -o build/temp.linux-x86_64-3.7/src/double-conversion/fixed-dtoa.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
gcc -pthread -B /home/zorawar/anaconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DEIGEN_DONT_ALIGN -Isrc -I/usr/include/eigen3 -I/usr/local/include/eigen3 -Iminieigen -I/home/zorawar/anaconda3/include/python3.7m -c src/double-conversion/strtod.cc -o build/temp.linux-x86_64-3.7/src/double-conversion/strtod.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
src/double-conversion/strtod.cc: In function ‘float double_conversion::Strtof(double_conversion::Vector<const char>, int)’:
src/double-conversion/strtod.cc:509:9: warning: unused variable ‘f2’ [-Wunused-variable]
float f2 = float_guess;
^~
creating build/lib.linux-x86_64-3.7
g++ -pthread -shared -B /home/zorawar/anaconda3/compiler_compat -L/home/zorawar/anaconda3/lib -Wl,-rpath=/home/zorawar/anaconda3/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.7/src/minieigen.o build/temp.linux-x86_64-3.7/src/expose-boxes.o build/temp.linux-x86_64-3.7/src/expose-complex.o build/temp.linux-x86_64-3.7/src/expose-converters.o build/temp.linux-x86_64-3.7/src/expose-matrices.o build/temp.linux-x86_64-3.7/src/expose-quaternion.o build/temp.linux-x86_64-3.7/src/expose-vectors.o build/temp.linux-x86_64-3.7/src/double-conversion/bignum.o build/temp.linux-x86_64-3.7/src/double-conversion/bignum-dtoa.o build/temp.linux-x86_64-3.7/src/double-conversion/cached-powers.o build/temp.linux-x86_64-3.7/src/double-conversion/diy-fp.o build/temp.linux-x86_64-3.7/src/double-conversion/double-conversion.o build/temp.linux-x86_64-3.7/src/double-conversion/fast-dtoa.o build/temp.linux-x86_64-3.7/src/double-conversion/fixed-dtoa.o build/temp.linux-x86_64-3.7/src/double-conversion/strtod.o -lboost_python-py37 -o build/lib.linux-x86_64-3.7/minieigen.cpython-37m-x86_64-linux-gnu.so
/home/zorawar/anaconda3/compiler_compat/ld: cannot find -lboost_python-py37
collect2: error: ld returned 1 exit status
error: command 'g++' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for minieigen
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.