Did I find the right examples for you? yes no

All Samples(48)  |  Call(42)  |  Derive(0)  |  Import(6)
Return a matrix with ones on the diagonal and zeros elsewhere.

Parameters
----------
n : int
    Number of rows in the output.
M : int, optional
    Number of columns in the output, defaults to `n`.
k : int, optional
    Index of the diagonal: 0 refers to the main diagonal,(more...)

        def eye(n,M=None, k=0, dtype=float):
    """
    Return a matrix with ones on the diagonal and zeros elsewhere.

    Parameters
    ----------
    n : int
        Number of rows in the output.
    M : int, optional
        Number of columns in the output, defaults to `n`.
    k : int, optional
        Index of the diagonal: 0 refers to the main diagonal,
        a positive value refers to an upper diagonal,
        and a negative value to a lower diagonal.
    dtype : dtype, optional
        Data-type of the returned matrix.

    Returns
    -------
    I : matrix
        A `n` x `M` matrix where all elements are equal to zero,
        except for the `k`-th diagonal, whose values are equal to one.

    See Also
    --------
    numpy.eye : Equivalent array function.
    identity : Square identity matrix.

    Examples
    --------
    >>> import numpy.matlib
    >>> np.matlib.eye(3, k=1, dtype=float)
    matrix([[ 0.,  1.,  0.],
            [ 0.,  0.,  1.],
            [ 0.,  0.,  0.]])

    """
    return asmatrix(np.eye(n, M, k, dtype))
        


src/p/y/pymaclab-0.95.9/pymaclab/dsge/solvers/modsolvers.py   pymaclab(Download)
            Theta_mat = -HH
            Xi_mat = \
                   np.concatenate((Gamma_mat,Theta_mat,MAT.eye(m_states),\
                          MAT.zeros((m_states,m_states))),1)
            Delta_mat = \
                  np.concatenate((Psi_mat,MAT.zeros((m_states,m_states)),\
                         MAT.zeros((m_states,m_states)),\
                         MAT.zeros((m_states,m_states)),MAT.eye(m_states),1))
            Theta_mat = -HH
            Xi_mat = \
                   np.concatenate((Gamma_mat,Theta_mat,MAT.eye(m_states),\
                          MAT.zeros((m_states,m_states))),1)
            Delta_mat = \
                  np.concatenate((Psi_mat,MAT.zeros((m_states,m_states)),\
                         MAT.zeros((m_states,m_states)),\
                         MAT.zeros((m_states,m_states)),MAT.eye(m_states),1))
                   np.concatenate((\
                       np.concatenate((Gamma_mat,Theta_mat),1),\
                       np.concatenate((MAT.eye(m_states),MAT.zeros((m_states,m_states))),1)\
                   ))
            Delta_mat = \

src/d/o/dolo-0.4.6.3/dolo/numeric/extern/helpers.py   dolo(Download)
from numpy import r_, c_, arange, diff, mean, sqrt, log, mat
from numpy import asarray, nan
from numpy.matlib import ones, zeros, rand, eye, empty
from numpy.linalg import eigh, cholesky, solve, lstsq
# (lstsq also as tool to determine rank)
    return u[:, rk:]
 
from numpy.matlib import empty, zeros, eye, mat, asarray
from numpy.linalg import lstsq
def getOrthColumns(m):
    if rk == p: result = zeros((p,0))   # note the shape! hopefully octave-like
    # then the zero-matrix case (within machine precision):
    elif rk == 0: result = eye(p)
    # now the rank-deficient case:
    elif rk < r:
            # 2. if zero, then also put a zero row in c
            # 3. if not, put the next unit vector in c-row
        idr = eye(r)
        idpr = eye(p-r)
        c = empty([0,r])    # starting point  

src/d/o/dolo-HEAD/dolo/numeric/extern/helpers.py   dolo(Download)
from numpy import r_, c_, arange, diff, mean, sqrt, log, mat
from numpy import asarray, nan
from numpy.matlib import ones, zeros, rand, eye, empty
from numpy.linalg import eigh, cholesky, solve, lstsq
# (lstsq also as tool to determine rank)
    return u[:, rk:]
 
from numpy.matlib import empty, zeros, eye, mat, asarray
from numpy.linalg import lstsq
def getOrthColumns(m):
    if rk == p: result = zeros((p,0))   # note the shape! hopefully octave-like
    # then the zero-matrix case (within machine precision):
    elif rk == 0: result = eye(p)
    # now the rank-deficient case:
    elif rk < r:
            # 2. if zero, then also put a zero row in c
            # 3. if not, put the next unit vector in c-row
        idr = eye(r)
        idpr = eye(p-r)
        c = empty([0,r])    # starting point  

src/n/u/nupic-linux64-HEAD/lib64/python2.6/site-packages/numpy/tests/test_matlib.py   nupic-linux64(Download)
def test_eye():
    x = np.matlib.eye(3, k=1, dtype=int)
    assert_array_equal(x, np.matrix([[ 0,  1,  0],
                                     [ 0,  0,  1],
                                     [ 0,  0,  0]]))

src/m/i/MissionPlanner-HEAD/Lib/site-packages/numpy/tests/test_matlib.py   MissionPlanner(Download)
def test_eye():
    x = np.matlib.eye(3, k=1, dtype=int)
    assert_array_equal(x, np.matrix([[ 0,  1,  0],
                                     [ 0,  0,  1],
                                     [ 0,  0,  0]]))

src/n/u/numpy-1.8.1/numpy/tests/test_matlib.py   numpy(Download)
def test_eye():
    x = np.matlib.eye(3, k=1, dtype=int)
    assert_array_equal(x, np.matrix([[ 0,  1,  0],
                                     [ 0,  0,  1],
                                     [ 0,  0,  0]]))

src/p/y/pyLDS-HEAD/src/LDS.py   pyLDS(Download)
		for t in range(T-2,1,-1):
		    M[t]=PStore[t]*S[t-1].T + S[t]*(M[t+1] - A.next()*PStore[t])*S[t-1].T
		M[1] = matlib.eye(self.nx)
		M[0] = matlib.eye(self.nx)