예제 #1
0
def timing_demo1(N=12):
    domain = 2**np.arange(1, N + 1)
    times = []

    for n in domain:
        start = time()
        solutions.random_matrix(n)
        times.append(time() - start)

    plt.plot(domain, times, 'g.-', linewidth=2, markersize=15)
    plt.xlabel("n", fontsize=14)
    plt.ylabel("Seconds", fontsize=14)

    return domain, times
예제 #2
0
def timing_demo1(N=12):
    domain = 2**np.arange(1,N+1)
    times = []

    for n in domain:
        start = time()
        solutions.random_matrix(n)
        times.append(time() - start)

    plt.plot(domain, times, 'g.-', linewidth=2, markersize=15)
    plt.xlabel("n", fontsize=14)
    plt.ylabel("Seconds", fontsize=14)

    return domain, times
예제 #3
0
def prob1A(N=9):
    domain = 2**np.arange(1,N+1)
    vector_times, matrix_times = [], []

    for n in domain:
        A = solutions.random_matrix(n)
        x = solutions.random_vector(n)
        B = solutions.random_matrix(n)

        start = time()
        solutions.matrix_vector_product(A, x)
        vector_times.append(time() - start)

        start = time()
        solutions.matrix_matrix_product(A, B)
        matrix_times.append(time() - start)

    plt.plot(domain, vector_times, 'b.-', lw=2, ms=15)
    plt.xlabel("n", fontsize=14); plt.ylabel("Seconds", fontsize=14)
    plt.title("Matrix-Vector Multiplication")

    return domain, vector_times, matrix_times
예제 #4
0
def prob1A(N=9):
    domain = 2**np.arange(1, N + 1)
    vector_times, matrix_times = [], []

    for n in domain:
        A = solutions.random_matrix(n)
        x = solutions.random_vector(n)
        B = solutions.random_matrix(n)

        start = time()
        solutions.matrix_vector_product(A, x)
        vector_times.append(time() - start)

        start = time()
        solutions.matrix_matrix_product(A, B)
        matrix_times.append(time() - start)

    plt.plot(domain, vector_times, 'b.-', lw=2, ms=15)
    plt.xlabel("n", fontsize=14)
    plt.ylabel("Seconds", fontsize=14)
    plt.title("Matrix-Vector Multiplication")

    return domain, vector_times, matrix_times