Esempio n. 1
0
def tangent_initial_condition(subspace_dimension):
    #np.random.seed(12)
    W = pascal.random(subspace_dimension)
    #W = (pascal.qr(W.T))[0].T
    W = pascal.qr_transpose(W)[0]
    w = pascal.zeros()
    return W, w
Esempio n. 2
0
File: fds.py Progetto: qiqi/fds
def tangent_initial_condition(subspace_dimension):
    #np.random.seed(12)
    W = pascal.random(subspace_dimension)
    #W = (pascal.qr(W.T))[0].T
    W = pascal.qr_transpose(W)[0]
    w = pascal.zeros()
    return W, w
Esempio n. 3
0
def test_linalg():
    for mod in list(sys.modules.keys()):
        if mod.startswith('pascal_lite'):
            del sys.modules[mod]
    import pascal_lite as pascal
    subspace_dimension = 4
    V = pascal.symbolic_array(subspace_dimension)
    v = pascal.symbolic_array()

    v1 = pascal.dot(V, v)
    assert not v1.is_distributed
    v2 = pascal.outer(v1, v)
    assert v2.is_distributed
    v3 = pascal.qr_transpose(V)[0]
    assert v3.is_distributed

    g = pascal.ComputationalGraph([v1.value, v2.value, v3.value])
    n = 16

    A = np.random.rand(subspace_dimension, n)
    b = np.random.rand(n)

    def actual_inputs(x):
        if x is V.value:
            return A
        elif x is v.value:
            return b

    o1, o2, o3 = g(actual_inputs)
    assert np.allclose(o1, np.dot(A, b))
    assert np.allclose(o2, np.outer(np.dot(A, b), b))
    assert np.allclose(o3, np.linalg.qr(A.T)[0].T)
Esempio n. 4
0
File: lsstan.py Progetto: qiqi/fds
    def checkpoint(self, V, v):
        #Q, R = pascal.qr(V.T)
        #b = pascal.dot(Q.T, v)
        #V[:] = Q.T
        #v -= pascal.dot(Q, b)
        Q, R = pascal.qr_transpose(V)
        b = pascal.dot(Q, v)
        #V[:] = Q
        #v -= pascal.dot(b, Q)
        V = Q
        v = v - pascal.dot(b, Q)

        self.Rs.append(R)
        self.bs.append(b)
        return V, v
Esempio n. 5
0
File: lsstan.py Progetto: qiqi/fds
    def checkpoint(self, V, v):
        #Q, R = pascal.qr(V.T)
        #b = pascal.dot(Q.T, v)
        #V[:] = Q.T
        #v -= pascal.dot(Q, b)
        Q, R = pascal.qr_transpose(V)
        b = pascal.dot(Q, v)
        #V[:] = Q
        #v -= pascal.dot(b, Q)
        V = Q
        v = v - pascal.dot(b, Q)

        self.Rs.append(R)
        self.bs.append(b)
        return V, v