Exemplo n.º 1
0
    def test_example(self):
        pitts_py.initialize()

        # do something interesting...
        tt = pitts_py.TensorTrain_double([5,5,5])
        pitts_py.randomize(tt)

        pitts_py.finalize()
Exemplo n.º 2
0
    n = 10000000
    m = 50

    X = pitts_py.MultiVector_double(n, m)
    pitts_py.randomize(X)

    for j in range(1, m+1):
        print("n: ", n, ", m: ", j)
        X.resize(n,j)
        pitts_qr(X)
        numpy_qr(X)

    n = n//10
    m = 100
    print("n: ", n, ", m: ", m)
    X.resize(n, m)
    pitts_py.randomize(X)
    pitts_qr(X)
    numpy_qr(X)

    n = n//10
    m = 200
    print("n: ", n, ", m: ", m)
    X.resize(n, m)
    pitts_py.randomize(X)
    pitts_qr(X)
    numpy_qr(X)

    pitts_py.finalize(True)
Exemplo n.º 3
0
            eye_i = TTOp_dummy.getSubTensor(iDim)
            tridi_i = np.zeros((n_i,n_i))
            for i in range(n_i):
                for j in range(n_i):
                    if i == j:
                        tridi_i[i,j] = 2. / (n_i+1)
                    elif i+1 == j or i-1 == j:
                        tridi_i[i,j] = -1. / (n_i+1)
                    else:
                        tridi_i[i,j] = 0
            TTOp_dummy.setSubTensor(iDim, tridi_i.reshape(1,n_i,n_i,1))
            pitts_py.axpby(1, TTOp_dummy, 1, TTOp)
            TTOp_dummy.setSubTensor(iDim, eye_i)
        return TTOp

    TTOp = LaplaceOperator([10,]*5)

    x0 = pitts_py.TensorTrain_double(TTOp.row_dimensions())
    x0.setOnes()

    sigma, q = tt_jacobi_davidson(TTOp, x0, symmetric=True, eps=1.e-8)

    r = pitts_py.TensorTrain_double(x0.dimensions())
    pitts_py.apply(TTOp, q, r)
    sigma_ref = pitts_py.dot(q, r)
    r_nrm = pitts_py.axpby(-sigma, q, 1, r)
    print("Residual norm: %g" % r_nrm)
    print("Est. eigenvalue: %g, real Ritz value: %g, error: %g" % (sigma, sigma_ref, np.abs(sigma-sigma_ref)))

    pitts_py.finalize()