Cython helper for linear algebra with typed memoryviews built atop of Eigen C++ library
MIT License
Note: this software is not maintained since 2015.
Ceygen is a binary Python extension module for linear algebra with Cython_ typed memoryviews
. Ceygen is built atop the Eigen C++ library
. Ceygen is not a Cython
wrapper or an interface to Eigen!
The name Ceygen is a rather poor wordplay on Cython + Eigen; it has nothing to do
with software piracy. Ceygen is distributed under the MIT license
_.
Cython was developed by Matěj Laitl with support from the Institute of Information Theory and Automation, Academy of Sciences of the Czech Republic
_. Feel free to send me
a mail to matej at laitl dot cz.
.. _Cython: http://cython.org/
.. _typed memoryviews
: http://docs.cython.org/src/userguide/memoryviews.html
.. _Eigen C++ library
: http://eigen.tuxfamily.org/
.. _MIT license
: https://choosealicense.com/licenses/mit/
.. _Institute of Information Theory and Automation, Academy of Sciences of the Czech Republic
:
http://www.utia.cas.cz/
Ceygen...
typed memoryviews
_ (especiallyEigen itself performs rather well
_, too.Documentation
_ or hop directly to on-line docs
_.fused types
_ (a.k.a. wannabeevery push is automatically tested
_ against Python 2.6, 2.7, 3.2 and 3.3.Cython memoryviews and NumPy arrays
_ are fully.. _Eigen itself performs rather well
: http://eigen.tuxfamily.org/index.php?title=Benchmark
.. _on-line docs
: http://strohel.github.com/Ceygen-doc/
.. _fused types
: http://docs.cython.org/src/userguide/fusedtypes.html
.. _every push is automatically tested
: https://travis-ci.org/strohel/Ceygen
.. _GIL: http://docs.python.org/glossary.html#term-global-interpreter-lock
.. _nogil: http://docs.cython.org/src/userguide/external_C_code.html#declaring-a-function-as-callable-without-the-gil
.. _prange: http://docs.cython.org/src/userguide/parallelism.html
.. _NumPy: http://www.numpy.org/
.. _Cython memoryviews and NumPy arrays
: http://docs.cython.org/src/userguide/memoryviews.html#coercion-to-numpy
On the other hand, Ceygen...
/usr/lib/eigen3
when it is being built. Installing Eigen is a matter of unpackingArray expessions
_ will help here... _Array expessions
: https://github.com/cython/cython/pull/144
A simple example to compute matrix product within a big matrix may look like
cdef double[:, :] big = np.array([[1., 2., 2., 0., 0., 0.], [3., 4., 0., -2., 0., 0.]]) ceygen.core.dot_mm(big[:, 0:2], big[:, 2:4], big[:, 4:6]) [[ 2. -4.] [ 6. -8.]] big [[ 1. 2. 2. 0. 2. -4.] [ 3. 4. 0. -2. 6. -8.]],
where the dot_mm
_ call above doesn't copy any data, allocates no memory on heap, doesn't
need the GIL_ and uses vectorization (SSE, AltiVec...) to get the best out of your
processor.
.. _dot_mm
: http://strohel.github.com/Ceygen-doc/core.html#ceygen.core.dot_mm
Ceygen development happens in its github repository
, git clone [email protected]:strohel/Ceygen.git
-ing is the preferred way to get it as you'll have
the latest & greatest version (which shouldn't break thanks to continuous integration).
Released versions are available from Ceygen's PyPI page
.
.. _its github repository
: https://github.com/strohel/Ceygen
.. _Ceygen's PyPI page
: http://pypi.python.org/pypi/Ceygen
Ceygen uses standard Distutils to build, test and install itself, simply run:
python setup.py build
to build Ceygenpython setup.py test
to test it (inside build directory)python setup.py install
to install itpython setup.py clean
to clean generated object, .cpp and .html files (perhaps toCommands can be combined, automatically call dependent commands and can take options,
the recommended combo to safely install Ceygen is therefore python setup.py -v test install
.
You can set various build options as it is usual with distutils, see
python setup.py --help
. Notable is the build_ext
command and its --include-dirs
(standard) and following additional options (whose are Ceygen extensions):
--include-dirs
defaults to /usr/include/eigen3
and must be specified if you've installed Eigen 3
to a non-standard directory,
--cflags
defaults to -O2 -march=native -fopenmp
. Please note that it is important to enable
optimizations and generation of appropriate MMX/SSE/altivec-enabled code as the actual
computation code from Eigen is built along with the boilerplate Ceygen code,
--ldflags
additional flags to pass to linker, defaults to -fopenmp
. Use standard --libraries
for specifying extra libraries to link against,
--annotate
pass --annotate
to Cython to produce annotated HTML files during compiling. Only
useful during Ceygen development.
You may want to remove -fopenmp
from cflags
and ldflags
if you are already
parallelising above Ceygen. The resulting command could look like python setup.py -v build_ext --include-dirs=/usr/local/include/eigen3 --cflags="-O3 -march=core2" --ldflags= test
. The same could be achieved by putting the options to a setup.cfg
file::
[build_ext] include_dirs = /usr/local/include/eigen3 cflags = -O3 -march=core2 ldflags =
Ceygen documentation is maintained in reStructuredText_ format under doc/
directory
and can be exported into a variety of formats using Sphinx_ (version at least 1.0 needed).
Just type make
in that directory to see a list of supported formats and for example
make html
to build HTML pages with the documentation.
See ChangeLog.rst
file for changes between versions or view it online
_.
On-line documentation is available at http://strohel.github.com/Ceygen-doc/
.. _reStructuredText: http://sphinx-doc.org/rest.html
.. _Sphinx: http://sphinx-doc.org/
.. _view it online
: http://strohel.github.com/Ceygen-doc/ChangeLog.html
Please report any bugs you find and suggestions you may have to Ceygen's github Issue Tracker
_.
.. _Ceygen's github Issue Tracker
: https://github.com/strohel/Ceygen/issues