read from rb or mtx depending on extension
This commit is contained in:
		
							
								
								
									
										11
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								src/main.c
									
									
									
									
									
								
							| @@ -3,6 +3,7 @@ | |||||||
| #include "matrix_operation.h" | #include "matrix_operation.h" | ||||||
| #include "sparse_matrix.h" | #include "sparse_matrix.h" | ||||||
| #include "read_from_mtx.h" | #include "read_from_mtx.h" | ||||||
|  | #include "read_from_rb.h" | ||||||
| #include "vector.h" | #include "vector.h" | ||||||
| #include "power_algorithm.h" | #include "power_algorithm.h" | ||||||
| #include "gauss_seidel.h" | #include "gauss_seidel.h" | ||||||
| @@ -14,7 +15,15 @@ void test_stationary_distribution(const char *path, double epsilon, double alpha | |||||||
|     struct timeval tvstart, tvend; |     struct timeval tvstart, tvend; | ||||||
|  |  | ||||||
|     gettimeofday(&tvstart, NULL); |     gettimeofday(&tvstart, NULL); | ||||||
|     SparseMatrix *matrix = read_sparse_matrix_from_mtx(path); |  | ||||||
|  |     SparseMatrix *matrix = NULL; | ||||||
|  |     const char *extension = strrchr(path, '.'); | ||||||
|  |     if (extension && strcasecmp(extension, ".rb") == 0) { | ||||||
|  |         matrix = read_sparse_matrix_from_rb(path); | ||||||
|  |     } else { | ||||||
|  |         matrix = read_sparse_matrix_from_mtx(path); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     convert_to_stochastic(matrix); |     convert_to_stochastic(matrix); | ||||||
|     gettimeofday(&tvend, NULL); |     gettimeofday(&tvend, NULL); | ||||||
|     print_time_diff("Read and convert matrix", &tvstart, &tvend); |     print_time_diff("Read and convert matrix", &tvstart, &tvend); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user