diff options
author | adam <adam@volconst.com> | 2021-09-27 13:13:17 +0300 |
---|---|---|
committer | adam <adam@volconst.com> | 2021-09-27 13:13:17 +0300 |
commit | 6e014ca5ce263e96549236b5bf4f2379467b9e2b (patch) | |
tree | 56dfb669fdca4118cddedc265dd2ea1768c8aaa7 /main.c | |
download | dethread-6e014ca5ce263e96549236b5bf4f2379467b9e2b.tar.gz |
setting up git on old project
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 127 |
1 files changed, 127 insertions, 0 deletions
@@ -0,0 +1,127 @@ +#include<stdio.h> +#include<string.h> +#include<stdlib.h> +#include"row_dispenser.c" +#include"threadet.c" +#include"input.c" + + +int main(int argc,char **argv) +{ + + mpq_t **det=NULL; + size_t n=1; + size_t i,j,y; + size_t number_of_threads=1; + char verbose=1; + FILE *out=stdout; + FILE *dm=NULL; +/* + * menuing + * + */ + for(i=0;i<argc;++i) + { + if(strcmp("-i",argv[i]) == 0) + { + if(det!=NULL)free(det); + ++i; + if(i == argc) + { + printf("No name\n"); + return -1; + } + FILE *in = fopen(argv[i],"r"); + if(in == NULL) + { + printf("No such file\n"); + return -1; + } + input_det(in,&det,&n); + fclose(in); + }else if(strcmp("-t",argv[i]) == 0) + { + ++i; + if(i == argc) + { + printf("No number of threads\n"); + return -1; + } + for(j=0;argv[i][j]!='\0';++j) + if(argv[i][j] < '0' || argv[i][j] > '9') + { + printf("Number of threads format not supported\n"); + return -1; + } + sscanf(argv[i],"%zu",&number_of_threads); + + }else if(strcmp("-q",argv[i]) == 0) + { + verbose = 0; + }else if(strcmp("-n",argv[i]) == 0) + { + if(det!=NULL)free(det); + ++i; + if(i == argc) + { + printf("No matrix size\n"); + return -1; + } + for(j=0;argv[i][j]!='\0';++j) + if(argv[i][j] < '0' || argv[i][j] > '9') + { + printf("Matrix size format not supported\n"); + return -1; + } + sscanf(argv[i],"%zu",&n); + random_table(&det,n); + }else if(strcmp("-o",argv[i]) == 0) + { + ++i; + if(i == argc) + { + printf("No name\n"); + return -1; + } + //fclose(out); + out = fopen(argv[i],"w"); + if(out == NULL) + { + printf("No such file\n"); + return -1; + } + }else if(strcmp("-dm",argv[i]) == 0) + { + ++i; + if(i == argc) + { + printf("No name\n"); + return -1; + } + dm = fopen(argv[i],"w"); + } + + } + if(det==NULL) + { + printf("Not matrix specified\n"); + return -1; + } + if(dm!=NULL) + { + fprintf(dm,"%zu\n",n); + for(i=0;i<n;++i) + { + for(j=0;j<n;++j) + { + gmp_fprintf(dm,"%Qi ",det[i][j]); + } + fprintf(dm,"\n"); + } + } + mpq_t *res = threadet(det,n-1,number_of_threads,verbose); + gmp_fprintf(out,"%Qi",*res); + free(det); + free(res); + return 0; +} |