# Path: lpdec/utils.py
# def clock():
#     def clock():
#     def __init__(self):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, exc_tb):
#     def duration(self):
#     def start(self):
#     def stop(self):
# def utcnow():
# def frange(start, end, step=1):
# def splitRanges(rangesString):
# def machineString():
# def isStr(arg):
# class Timer:
# TERM_BOLD_RED = '\033[31;1m'
# TERM_RED = '\033[31m'
# TERM_BOLD = '\033[0;1m'
# TERM_NORMAL = '\033[0m'
# TERM_CYAN = '\033[36m'


import os.path, sys, bz2
import numpy as np
        import cStringIO
        import io
from lpdec import utils
        String representation of the given matrix.
    """
    if format == 'plain':
        mstring = numpyToString(matrix, width=width)
    else:
        assert format == 'alist'
        mstring = numpyToAlist(matrix)
    if filename:
        filename = os.path.expanduser(filename)
        fileObj = bz2.BZ2File(filename, 'wb') if filename.endswith('bz2') else open(filename, 'wb')
        with fileObj as f:
            f.write(mstring.encode('ASCII'))
    return mstring


def numpyToReducedAlist(matrix):
    """Convert the matrix to reduced AList format in form of a list of lists.

    The first entry is a pair containing number of columns and rows, respectively. The second entry
    is an empty list (in MacKay's Alist format, this contains the max number of entries per column
    and row, respectively). Then, for each column, a list of nonzero positions follows.
    """
    out = [[matrix.shape[1], matrix.shape[0]], []]
    for i in range(matrix.shape[1]):
        out.append((matrix[:, i].nonzero()[0] + 1).tolist())
    return out


def getNonbinaryMatrix(source):
    """Reads a nonbinary matrix (no AList support)."""

# Path: lpdec/utils.py
# def clock():
#     def clock():
#     def __init__(self):
#     def __enter__(self):
#     def __exit__(self, exc_type, exc_value, exc_tb):
#     def duration(self):
#     def start(self):
#     def stop(self):
# def utcnow():
# def frange(start, end, step=1):
# def splitRanges(rangesString):
# def machineString():
# def isStr(arg):
# class Timer:
# TERM_BOLD_RED = '\033[31;1m'
# TERM_RED = '\033[31m'
# TERM_BOLD = '\033[0;1m'
# TERM_NORMAL = '\033[0m'
# TERM_CYAN = '\033[36m'


# Path: lpdec/matrices.py
import os.path, sys, bz2
import numpy as np
        import cStringIO
        import io
from lpdec import utils

        String representation of the given matrix.
    """
    if format == 'plain':
        mstring = numpyToString(matrix, width=width)
    else:
        assert format == 'alist'
        mstring = numpyToAlist(matrix)
    if filename:
        filename = os.path.expanduser(filename)
        fileObj = bz2.BZ2File(filename, 'wb') if filename.endswith('bz2') else open(filename, 'wb')
        with fileObj as f:
            f.write(mstring.encode('ASCII'))
    return mstring


def numpyToReducedAlist(matrix):
    """Convert the matrix to reduced AList format in form of a list of lists.

    The first entry is a pair containing number of columns and rows, respectively. The second entry
    is an empty list (in MacKay's Alist format, this contains the max number of entries per column
    and row, respectively). Then, for each column, a list of nonzero positions follows.
    """
    out = [[matrix.shape[1], matrix.shape[0]], []]
    for i in range(matrix.shape[1]):
        out.append((matrix[:, i].nonzero()[0] + 1).tolist())
    return out


def getNonbinaryMatrix(source):
    """Reads a nonbinary matrix (no AList support)."""

    if utils.isStr(source):