OMPC Compiler and OMPClib

OMPC is a platform that makes it easy to move from MATLAB to Python. MATLAB can cost considerable amount of money but for somebody using only its basic functionality without toolboxes this seems like a waste. As we would like to prove with OMPC, MATLAB is not irreplaceable, and usually the reason to stick with it is the reuse of previously developed code. OMPC should allow people to use their old MATLAB code transparently from Python. This means that you don't have to rewrite all previously written modules to start learning and developing in Python.
There are other applications like Octave and Scilab that allow you to enjoy freedom while keeping your old MATLAB code running with only small modifications. OMPC aspires for 100% syntax compatibility. The more difficult tasks is the make the OMPC supporting library fully compatible in the sense of format of the input and output parameters (more at OMPC binary interface). Binary compatibility is not an issue that will be addressed directly. The memory model can be actually arbitrary if we expect the user to acces the binary data only using M-functions of mx-, mex- functions that are part of the MATLAB's C external API. We howerver are fully behind the common practice in science, where single contiguos memory block is allocated for an array of any dimensions. The storage format is row first (FORTRAN convention, more at OMPC binary interface and Indexing and Slices). Python numpy module offers FORTAN ordering for a 2 dimensional array, but the next dimension is indexed by a

Look at the following example:

Python with OMPC
>>> import os; os.listdir('mytoolbox')
>>> import OMPC
>>> addpath('mytoolbox')
>>> b = add(2,3)
>>> type(b)
<type 'numpy.int32'>

>>> help(add)
Help on function add in module __main__:

add(a, b)
    add a and b
>> ls mytoolbox\
.      ..     add.m 

>> addpath('mytoolbox')
>>> b = add(2,3)

b =


>> help add
  add a and b

    Overloaded methods:

Python interpreter  (left code) can be turned to a MATLAB comaptible console by a single import statement. IPython (interactive python) console currently used as a substitute for MATLAB interactive mode. This project takes a lot of inspiration from IPython. IPython allows one to use 'help add' without parentheses and does automatic correction of the syntax to the Python conforming one. Instead of creating another interpreter for MATLAB's language OMPC adapts the syntax and uses Python interpreter together with Python numerical packages to interpret Python code. To read about the particular tricks that are used to make the syntax adaptation possible look at the developer pages.

OMPC might seem like a huge effort, but the fact is that all you can do with MATLAB is probably already available in Python too. There is a number of brave people that crossed the border between MATLAB and Python and after discovering the possibilities they decided to stay there. For some this meant rewriting old code.

For a newcomer moving from MATLAB to Python the problem is usually finding a function that does the job of a function you know from another package. Even for Python alone there is not only one module that enables numerical analysis. We make the choice for you. The aim of OMPC is to put the most stable and standardized numerical packages of Python under one roof, a platform with a friendly and more importantly familiar user interface connected with documentation. Python world is very colourful and with the multitude of options it is very easy to get diverted from the main task. Creating one familiar platform with well chosen underlying implementation should allow the user to focus on the task of analysis.

The reward for learning Python is the ability to interface with huge amount of packages written for this popular language. Python is a general purpose programming language therefore finding an existing solution for tasks unrelated to numerical analysis is highly probable.

Except otherwise noted, the content of all pages at are licensed under a Creative Commons license, and examples are licensed under BSD style license.