Пример #1
0
def uniform(nrows, ncols=1, a=0, b=1):
    '''
    Randomly generates a matrix with uniformly distributed entries.
    
    uniform(nrows, ncols=1, a=0, b=1)

    PURPOSE
    Returns a matrix with typecode 'd' and size nrows by ncols, with
    its entries randomly generated from a uniform distribution on the
    interval (a,b).

    ARGUMENTS
    nrows     number of rows

    ncols     number of columns

    a         lower bound

    b         upper bound
    '''

    try:
        from cvxopt import gsl
    except:
        from cvxopt.base import matrix
        from random import uniform
        return matrix([uniform(a, b) for k in range(nrows * ncols)],
                      (nrows, ncols), 'd')

    return gsl.uniform(nrows, ncols, a, b)
Пример #2
0
def uniform(nrows, ncols=1, a=0, b=1):
    '''
    Randomly generates a matrix with uniformly distributed entries.
    
    uniform(nrows, ncols=1, a=0, b=1)

    PURPOSE
    Returns a matrix with typecode 'd' and size nrows by ncols, with
    its entries randomly generated from a uniform distribution on the
    interval (a,b).

    ARGUMENTS
    nrows     number of rows

    ncols     number of columns

    a         lower bound

    b         upper bound
    '''

    try:    
        from cvxopt import gsl
    except:
        from cvxopt.base import matrix
        from random import uniform
        return matrix([uniform(a, b) for k in range(nrows*ncols)],
                      (nrows,ncols), 'd' )

    return gsl.uniform(nrows, ncols, a, b)
Пример #3
0
 def test3(self):
     from cvxopt import gsl
     x = gsl.uniform(4,3)
     self.assertTrue(x.size[0] == 4 and x.size[1] == 3)
Пример #4
0
 def test3(self):
     from cvxopt import gsl
     x = gsl.uniform(4, 3)
     self.assertTrue(x.size[0] == 4 and x.size[1] == 3)