Exposing Eigen3 solvers via python #30908

Closed
opened 2012-04-11 12:49:06 +02:00 by Michael Gschwandtner · 4 comments

%%%Since the Eigen3 library is shipped with Blender it would be nice to be able to
access the linear algebra functions from python.

There are probaly several developers who need to use external libraries
(numpy, ...) to solve certain problems. In my mesh alignment
(pointcloud alignment) tool it is needed to calculate a least-squares solution
for the transformation matrix.

This patch adds a new module to mathutils (mathutils.eigen) and provides a
generic solve function that can solve Ax=b for x currently with

  • ColPivHouseholderQr
  • FullPivHouseholderQr
  • JacobiSvd

The matrices are lists of python lists 1,0,0],[0,1,0],[0,0,1 and vectors are
either [- [x],- [x],- [x]] or [1,2,3]. This is because the mathutils.Matrix class does
not support matrices of arbitrary size.

The solver throws exceptions if the Matrix rows don't have the same size or if
the rows of A and b are not equal or if the elements are not PyLong or PyFloat.

The return value is a list of values which corresponds to the vector 'x'

Attached is a little example that shows how the solver is used
(solver_example.txt)

The patch can be applied with

patch -p0 -d source/blender/python < mathutils_eigen.diff

in the root of the blender directory%%%

%%%Since the Eigen3 library is shipped with Blender it would be nice to be able to access the linear algebra functions from python. There are probaly several developers who need to use external libraries (numpy, ...) to solve certain problems. In my mesh alignment (pointcloud alignment) tool it is needed to calculate a least-squares solution for the transformation matrix. This patch adds a new module to mathutils (mathutils.eigen) and provides a generic solve function that can solve Ax=b for x currently with * ColPivHouseholderQr * FullPivHouseholderQr * JacobiSvd The matrices are lists of python lists [[1,0,0],[0,1,0],[0,0,1]] and vectors are either [- [x],- [x],- [x]] or [1,2,3]. This is because the mathutils.Matrix class does not support matrices of arbitrary size. The solver throws exceptions if the Matrix rows don't have the same size or if the rows of A and b are not equal or if the elements are not PyLong or PyFloat. The return value is a list of values which corresponds to the vector 'x' Attached is a little example that shows how the solver is used (solver_example.txt) The patch can be applied with patch -p0 -d source/blender/python < mathutils_eigen.diff in the root of the blender directory%%%

Changed status to: 'Open'

Changed status to: 'Open'

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'

Added subscriber: @Sergey

Added subscriber: @Sergey

Blender is not a framework, so exposing Eigen is not something we're really interested in.

However, we've got numpy in official builds now, which i believe will solve your needs.

So thanks for the patch, but archiving it now.

Blender is not a framework, so exposing Eigen is not something we're really interested in. However, we've got numpy in official builds now, which i believe will solve your needs. So thanks for the patch, but archiving it now.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#30908
No description provided.