python/move.py
author Puneeth Chaganti <punchagan@fossee.in>
Fri, 27 May 2011 14:24:59 +0530
changeset 0 0efde00f9229
permissions -rw-r--r--
Initial commit.

#!/usr/bin/python

import pylab as pl

def move(b, nonred, maxi):
    """ """
    br, bc = pl.atleast_2d(b).shape
    b = pl.hstack((b, pl.zeros((br, len(nonred)-bc))))
    maxi = max(max(nonred)+1, maxi)
    result = pl.zeros((br, maxi))
    nonred = pl.array(nonred)
    result[:,nonred.T]=b
    return result

if __name__== "__main__":
    
    s = """b = pl.array([[1, 2], 
              [9, 10]])"""
    t = """nonred = pl.array([7, 2])"""
    u = """maxi = 10"""
    print s, t, u
    exec(s)
    exec(t)
    exec(u)

    print """move(b, nonred, maxi)"""
    print move(b, nonred, maxi)