hbristow / eigen

A slim Python/Cython interface to the Eigen C++ template library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Eigen Python

A slim Python/Cython interface to the Eigen C++ template library

Eigen Python exports a number of Eigen types (namely Matrix and its derivatives) along with some of the core functionality provided by Eigen. This package is primarily designed to interface with external C++ libraries using Eigen in their public API, however it can also be used for fast math.

Installation

The project is best installed with pip. This will pull in the full suite of Eigen headers as well:

pip install git+https://github.com/hbristow/eigen

Usage

In your Cython wrappers:

from eigen cimport Scalar, VectorMap as Vector
...

cdef Scalar sum(Scalar[:] x):
    """Sum the elements of a contiguous vector with generic scalar type"""
    cdef Vector[Scalar] xm = Vector[Scalar](&x[0], x.size)
    return xm.sum()

In your setup.py:

import numpy
import eigen

Extension('...',
    include_dirs = [
        numpy.get_include(),
        eigen.get_include()
    ],
    extra_compile_args = eigen.compile_args()
    ...
)

About

A slim Python/Cython interface to the Eigen C++ template library

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 66.2%Language:C++ 33.8%