예제 #1
0
import Q1
import time
import sys

print("Please enter the size of the matrix you want to generate : ")
inp = input()
n = int(inp)
# n = 0
print("Random Sparse Matrix is generating .....")
matrix_1 = Q1.generate_sparse_matrix(n, 90)
matrix_2 = Q1.generate_sparse_matrix(n, 90)
print("Matrix 1 :")
print(matrix_1)

print("Matrix 2 :")
print(matrix_2)

print("Converting the Matrices to 'CRS' format......")
crs_1 = Q1.matrix_to_crs(matrix_1)
crs_2 = Q1.matrix_to_crs(matrix_2)

print("Random Dense Vector is Generating")
vector = Q1.generate_dense_vector(n, 90)

print("Matrix Vector Multiplication Sparse Algorithm Running....")
time_sparse_start = time.time()
result_vector_sparse = Q1.matrix_X_vector_sparse_algorithm(crs_1, vector)
time_sparse_end = time.time()

elapsed_time_sparse = (time_sparse_end - time_sparse_start) * 1000.0  #in ms
예제 #2
0
import Q1

print("Please enter the size of the matrix you want to generate : ")
inp = input()
n = int(inp)
# n = 0
print("Random Matrix is generating .....")
matrix_n = Q1.generate_sparse_matrix(n,90)
print(matrix_n)
print("Converting the Matrix to 'CRS' format......")
crs_n = Q1.matrix_to_crs(matrix_n)
print(crs_n)
print("Setting diagonal elements to 2016....")
for x in range(0,n):
    Q1.set_element_crs(crs_n,x,x,2016)
print(crs_n)
print("Converting the Matrix to CCS format.....")
ccs_n = Q1.crs_to_ccs(crs_n)
print(ccs_n)
# Need to be implemented.