Exemplo n.º 1
0
def diag(ma):
    """Diagonal matrix with ma on the diagonal.

    ma needs to be (1, k) or (k, 1).
    """
    EXC._assertVectorOrScalar(asmatrix(ma))
    ma = N.mat(ma)
    return S.diagflat(ma)
Exemplo n.º 2
0
def toeplitz(ma, cm=None):
    """
    Symmetric Toeplitz matrix.

    ma is a (k, 1) or (1, k) matrix.

    The Toeplitz matrix is of dimension (cm, cm)
    if cm is provided. Otherwise, it is (k, k)
    """
    ma = asmatrix(ma)
    EXC._assertVectorOrScalar(ma)
    if type(cm) == None:
        return asmatrix(L.basic.toeplitz(ma))
    else:
        m = ma.flatten()
        if cm is None:
            return asmatrix(L.basic.toeplitz(ma))
        else:
            if cm >= m.shape[1]: 
                n = cbind(zeros(N.mat(1), cm -  m.shape[1]))
                return asmatrix(L.basic.toeplitz(n))
            else:
                return asmatrix(L.basic.toeplitz(m[0:cm, 0:cm]))