Ejemplo n.º 1
0
def _find_smoothest(xk, yk, order, conds=None, B=None):
    # construct Bmatrix, and Jmatrix
    # e = J*c
    # minimize norm(e,2) given B*c=yk
    # if desired B can be given
    # conds is ignored
    N = len(xk)-1
    K = order
    if B is None:
        B = _fitpack._bsplmat(order, xk)
    J = _fitpack._bspldismat(order, xk)
    u,s,vh = np.dual.svd(B)
    ind = K-1
    V2 = vh[-ind:,:].T
    V1 = vh[:-ind,:].T
    A = dot(J.T,J)
    tmp = dot(V2.T,A)
    Q = dot(tmp,V2)
    p = np.dual.solve(Q,tmp)
    tmp = dot(V2,p)
    tmp = np.eye(N+K) - tmp
    tmp = dot(tmp,V1)
    tmp = dot(tmp,np.diag(1.0/s))
    tmp = dot(tmp,u.T)
    return dot(tmp, yk)
Ejemplo n.º 2
0
def _find_smoothest(xk, yk, order, conds=None, B=None):
    # construct Bmatrix, and Jmatrix
    # e = J*c
    # minimize norm(e,2) given B*c=yk
    # if desired B can be given
    # conds is ignored
    N = len(xk) - 1
    K = order
    if B is None:
        B = _fitpack._bsplmat(order, xk)
    J = _fitpack._bspldismat(order, xk)
    u, s, vh = np.dual.svd(B)
    ind = K - 1
    V2 = vh[-ind:, :].T
    V1 = vh[:-ind, :].T
    A = dot(J.T, J)
    tmp = dot(V2.T, A)
    Q = dot(tmp, V2)
    p = np.dual.solve(Q, tmp)
    tmp = dot(V2, p)
    tmp = np.eye(N + K) - tmp
    tmp = dot(tmp, V1)
    tmp = dot(tmp, np.diag(1.0 / s))
    tmp = dot(tmp, u.T)
    return _dot0(tmp, yk)