• R/O
  • SSH
  • HTTPS

p-svm: Commit


Commit MetaInfo

Revision22 (tree)
Zeit2014-01-29 19:11:40
Autorkanai7310

Log Message

(empty log message)

Ändern Zusammenfassung

Diff

--- src/IO.c (revision 21)
+++ src/IO.c (revision 22)
@@ -26,7 +26,7 @@
2626 fclose(fp);
2727 }
2828
29-void analysis_(char *input_file, int *NN, int *MM)
29+void analysis_(char *input_file, int *NN, int *MM, int *fmt)
3030 {
3131 char *p;
3232 int max_dim=0,n_data=0,n_dim,_s=0;
@@ -36,6 +36,10 @@
3636 p=strtok(input_file," ");
3737 if (p == NULL) p=input_file;
3838 fp=fopen(p,"r");
39+ if (fp == NULL) {
40+ fprintf(stderr,"%s : file open error!\n",p);
41+ exit(EXIT_FAILURE);
42+ }
3943
4044 fgets(line,LMAX,fp);
4145 if (strchr(line,':') != NULL) _s=1;
@@ -42,24 +46,17 @@
4246 rewind(fp);
4347
4448 while (fgets(line,LMAX,fp) != NULL) {
45- line[strlen(line)-1]='\0';
49+ strtok(line,"\r\n");
4650 n_data++;
4751 p=strtok(line," ");
48- if (strlen(p) == 0) {
49- while (1) {
50- p=strtok(NULL," ");
51- if (strlen(p) > 0) break;
52- }
53- }
5452 n_dim=0;
55- while ((p=strtok(NULL," ")) != NULL) {
56- if (strlen(p) > 0) n_dim++;
57- }
53+ while ((p=strtok(NULL," ")) != NULL) n_dim++;
5854 if (n_dim > max_dim) max_dim=n_dim;
5955 }
6056 *NN=n_data;
6157 if (_s == 1) *MM=max_dim+1;
6258 else *MM=max_dim;
59+ *fmt=_s;
6360
6461 fclose(fp);
6562 free(line);
@@ -76,30 +73,21 @@
7673 fp=fopen(p,"r");
7774
7875 while (fgets(line,LMAX,fp) != NULL) {
79- line[strlen(line)-1]='\0';
76+ strtok(line,"\r\n");
8077 p=strtok(line," ");
81- if (strlen(p) == 0) {
82- while (1) {
83- p=strtok(NULL," ");
84- if (strlen(p) > 0) break;
85- }
86- }
8778 *y=atof(p); y++;
8879
8980 while ((p=strtok(NULL," ")) != NULL) {
90- if (strlen(p) > 0) {
91- *x=atof(p);
92- x++;
93- }
81+ *x=atof(p); x++;
9482 }
9583 }
96-
84+
9785 fclose(fp);
9886 free(line);
9987 }
10088
10189 void read_sf_(char *input_file, double *y, double *x, int *pt, int *nd
102- ,int *NN, int *MM, int *imax)
90+ ,int *NN, int *MM)
10391 {
10492 char *p,*q;
10593 int i,n,*tpt;
@@ -111,16 +99,9 @@
11199 if (p == NULL) p=input_file;
112100 fp=fopen(p,"r");
113101
114- *imax=0;
115102 while (fgets(line,LMAX,fp) != NULL) {
116- line[strlen(line)-1]='\0';
103+ strtok(line,"\r\n");
117104 p=strtok(line," ");
118- if (strlen(p) == 0) {
119- while (1) {
120- p=strtok(NULL," ");
121- if (strlen(p) > 0) break;
122- }
123- }
124105 *y=atof(p); y++;
125106
126107 n=0;
@@ -131,15 +112,12 @@
131112 }
132113 pt=tpt;
133114 while ((p=strtok(NULL," ")) != NULL) {
134- if (strlen(p) > 0) {
135- q=strchr(p,':'); *q='\0'; q++;
136- *pt=atoi(p);
137- *x=atof(q);
138- if (*pt > *imax) *imax=*pt;
139- pt++;
140- x++;
141- n++;
142- }
115+ q=strchr(p,':'); *q='\0'; q++;
116+ *pt=atoi(p);
117+ *x=atof(q);
118+ pt++;
119+ x++;
120+ n++;
143121 }
144122 *nd=n; nd++;
145123 x=tx+(*MM); pt=tpt+(*MM);
@@ -417,7 +395,7 @@
417395 }
418396
419397 void read_model_sf_(char *model_file, double *y, double *a, double *x
420- , int *pt, int *nd, int *MM, int *imax)
398+ , int *pt, int *nd, int *MM)
421399 {
422400 char *p,*q;
423401 int n,*tpt;
@@ -434,7 +412,6 @@
434412 fgets(line,LMAX,fp);
435413 fgets(line,LMAX,fp);
436414
437- *imax=0;
438415 while (fgets(line,LMAX,fp) != NULL) {
439416 line[strlen(line)-1]='\0';
440417 p=strtok(line," ");
@@ -462,7 +439,6 @@
462439 q=strchr(p,':'); *q='\0'; q++;
463440 *pt=atoi(p);
464441 *x=atof(q);
465- if (*pt > *imax) *imax=*pt;
466442 pt++;
467443 x++;
468444 n++;
@@ -477,7 +453,7 @@
477453 }
478454
479455 void read_model_sfb_(char *model_file, double *y, double *a, double *x
480- , int *pt, int *nd, int *imax)
456+ , int *pt, int *nd)
481457 {
482458 char *p;
483459 int i,j,nn,mm;
@@ -500,13 +476,6 @@
500476 fread(nd,sizeof(int),nn,fp);
501477 fread(pt,sizeof(int),nn*mm,fp);
502478
503- *imax=0;
504- for (i=0;i<nn;i++) {
505- for (j=0;j<nd[i];j++) {
506- if (pt[j+mm*i] > *imax) *imax=pt[j+mm*i];
507- }
508- }
509-
510479 fclose(fp);
511480 free(line);
512481 }
--- src/comp.sh (revision 21)
+++ src/comp.sh (revision 22)
@@ -1,24 +1,26 @@
11 #!/bin/sh
22
33 gcc -O3 -g -c IO.c
4-gfortran -O3 -fopenmp -c mod_declare.F
5-gfortran -O3 -fopenmp -c parse_option.F
6-gfortran -O3 -fopenmp -c initial_working_set.F
7-gfortran -O3 -fopenmp -c mk_index.F
8-gfortran -O3 -fopenmp -c mk_Kmat.F
9-gfortran -O3 -fopenmp -c Kernel.F
10-gfortran -O3 -fopenmp -c mk_subQP.F
11-gfortran -O3 -fopenmp -c solve_QP.F
12-gfortran -O3 -fopenmp -c initial_a.F
13-gfortran -O3 -fopenmp -c Newton.F
14-gfortran -O3 -fopenmp -c update.F
15-gfortran -O3 -fopenmp -c calc_b_KKT.F
16-gfortran -O3 -fopenmp -c select_wset.F
17-gfortran -O3 -fopenmp -c hsort.F
4+gfortran -O3 -g -fopenmp -c mod_declare.F
5+gfortran -O3 -g -fopenmp -c parse_option.F
6+gfortran -O3 -g -fopenmp -c initial_working_set.F
7+gfortran -O3 -g -fopenmp -c mk_index.F
8+gfortran -O3 -g -fopenmp -c mk_Kmat.F
9+gfortran -O3 -g -fopenmp -c Kernel.F
10+gfortran -O3 -g -fopenmp -c mk_subQP.F
11+gfortran -O3 -g -fopenmp -c solve_QP.F
12+gfortran -O3 -g -fopenmp -c initial_a.F
13+gfortran -O3 -g -fopenmp -c Newton.F
14+gfortran -O3 -g -fopenmp -c update.F
15+gfortran -O3 -g -fopenmp -c calc_b_KKT.F
16+gfortran -O3 -g -fopenmp -c select_wset.F
17+gfortran -O3 -g -fopenmp -c hsort.F
18+gfortran -O3 -g -fopenmp -c init_PN.F
19+gfortran -O3 -g -fopenmp -c calc_sigmoid.F
1820
19-gfortran -O3 -fopenmp TEST.F \
21+gfortran -O3 -g -fopenmp TEST.F \
2022 mod_declare.o parse_option.o initial_working_set.o mk_index.o mk_Kmat.o \
2123 Kernel.o mk_subQP.o solve_QP.o initial_a.o Newton.o \
22-update.o calc_b_KKT.o select_wset.o hsort.o \
24+update.o calc_b_KKT.o select_wset.o hsort.o init_PN.o calc_sigmoid.o \
2325 IO.o \
2426 -L/opt/acml5.3.1/gfortran64_mp/lib -lacml_mp
Show on old repository browser