Code Monkey home page Code Monkey logo

cythongsl's Introduction

Introduction

Date:May 13, 2012
Version:0.2.1
Authors:Thomas Wiecki, thomas.wiecki[at]gmail.com
Web site:https://github.com/twiecki/CythonGSL
Copyright:This document has been placed in the public domain.
License:CythonGSL is released under the GPLv3.

Purpose

CythonGSL provides a Cython interface for the GNU Scientific Library (GSL).

Cython is the ideal tool to speed up numerical computations by converting typed Python code to C and generating Python wrappers so that these compiled functions can be called from Python. Scientific programming often requires use of various numerical routines (e.g. numerical integration, optimization). While SciPy provides many of those tools, there is an overhead associated with using these functions within your Cython code. CythonGSL allows you to shave off that last layer by providing Cython declarations for the GSL which allow you to use this high-quality library from within Cython without any Python overhead.

Fork of PyrexGsl by Mario Pernici (http://wwwteor.mi.infn.it/~pernici/pyrexgsl/pyrexgsl.html).

Usage

For a quick demo, see: http://nbviewer.ipython.org/urls/raw.github.com/twiecki/CythonGSL/master/examples/cython_gsl_ipythonnb.ipynb

Import CythonGSL in your pyx file

In your cython file from which you want to call gsl routines, import gsl like this:

from cython_gsl cimport *

From there you should be able to call any gsl function, see http://www.gnu.org/software/gsl/manual/gsl-ref.html for the GSL reference.

For more examples, check out the examples directory.

Compile your module

Here is what your setup.py could look like:

from distutils.core import setup
from Cython.Distutils import Extension
from Cython.Distutils import build_ext
import cython_gsl

setup(
    [...]
    include_dirs = [cython_gsl.get_include()],
    cmdclass = {'build_ext': build_ext},
    ext_modules = [Extension("my_cython_script",
                             ["src/my_cython_script.pyx"],
                             libraries=cython_gsl.get_libraries(),
                             library_dirs=[cython_gsl.get_library_dir()],
                             include_dirs=[cython_gsl.get_cython_include_dir()])]
    )

Installation

Dependencies

Installing CythonGSL

python setup.py build
python setup.py install

Installing CythonGSL Unittests

python setup_test.py build
python setup_test.py install
nosetest cython_gsl

cythongsl's People

Contributors

twiecki avatar joonro avatar molpopgen avatar bennihepp avatar bjodah avatar samuelstjean avatar oshevtsov avatar rkern avatar isofer avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.