• R/O
  • SSH
  • HTTPS

p-svm: Commit


Commit MetaInfo

Revision39 (tree)
Zeit2015-03-12 15:11:45
Autorkanai7310

Log Message

(empty log message)

Ändern Zusammenfassung

Diff

--- src/Makefile (revision 38)
+++ src/Makefile (revision 39)
@@ -8,7 +8,7 @@
88 FFLAGS = -O3 -m64 -fopenmp -fno-second-underscore # RBF kernel
99 #FFLAGS = -O3 -m64 -fopenmp -fno-second-underscore -DLinear # linear kernel
1010 CFLAGS = -O3 -m64
11-LFLAGS = -L/opt/acml5.3.1/gfortran64_mp/lib -lacml_mp # using ACML
11+LFLAGS = -L/opt/acml4.4.0/gfortran64_mp/lib -lacml_mp -lacml_mv # using ACML
1212 FC = gfortran
1313 CC = gcc
1414 else ifeq ($(compiler),open64)
--- src/IO.c (revision 38)
+++ src/IO.c (revision 39)
@@ -26,42 +26,6 @@
2626 fclose(fp);
2727 }
2828
29-void analysis_(char *input_file, int *NN, int *MM, int *fmt)
30-{
31- char *p;
32- int max_dim=0,n_data=0,n_dim,_s=0;
33-
34- line=(char*)malloc(LMAX);
35-
36- p=strtok(input_file," ");
37- if (p == NULL) p=input_file;
38- fp=fopen(p,"r");
39- if (fp == NULL) {
40- fprintf(stderr,"%s : file open error!\n",p);
41- exit(EXIT_FAILURE);
42- }
43-
44- fgets(line,LMAX,fp);
45- if (strchr(line,':') != NULL) _s=1;
46- rewind(fp);
47-
48- while (fgets(line,LMAX,fp) != NULL) {
49- strtok(line,"\r\n");
50- n_data++;
51- p=strtok(line," ");
52- n_dim=0;
53- while ((p=strtok(NULL," ")) != NULL) n_dim++;
54- if (n_dim > max_dim) max_dim=n_dim;
55- }
56- *NN=n_data;
57- if (_s == 1) *MM=max_dim+1;
58- else *MM=max_dim;
59- *fmt=_s;
60-
61- fclose(fp);
62- free(line);
63-}
64-
6529 void analysis_ef_(char *input_file, int *NS, int *NN, int *MM, int *fmt)
6630 {
6731 char *p,*rr[9];
@@ -268,7 +232,7 @@
268232 if (a[i] >= *eps) n++;
269233 }
270234
271- fprintf(fp,"%d %d %.4f\n",*NS,n,*acc);
235+ fprintf(fp,"%d %d %d %.4f\n",*NS,n,*is_bin,*acc);
272236 for (i=0;i<(*NS);i++) {
273237 fprintf(fp,"%d %d\n",MM[i],fmt[i]);
274238 }
@@ -437,308 +401,197 @@
437401 fclose(fp);
438402 }
439403
440-void read_df_(char *input_file, double *y, double *x)
404+void read_model_ef_(char *input_file, int *is_bin,
405+ int *NS, int *NN, int *MM, int *fmt, double *y, double *a,
406+ double *b, double *probA, double *probB, double *acc,
407+ double *eps, double *Cost, double *gamma,
408+ double *x1, int *pt1, int *nd1,
409+ double *x2, int *pt2, int *nd2,
410+ double *x3, int *pt3, int *nd3)
441411 {
412+ int i,j,k,n;
442413 char *p;
443414
444415 line=(char*)malloc(LMAX);
445-
446- p=strtok(input_file," ");
447- if (p == NULL) p=input_file;
448- fp=fopen(p,"r");
449-
450- while (fgets(line,LMAX,fp) != NULL) {
451- strtok(line,"\r\n");
452- p=strtok(line," ");
453- *y=atof(p); y++;
454-
455- while ((p=strtok(NULL," ")) != NULL) {
456- *x=atof(p); x++;
457- }
458- }
459416
460- fclose(fp);
461- free(line);
462-}
463-
464-void read_sf_(char *input_file, double *y, double *x, int *pt, int *nd
465- ,int *NN, int *MM)
466-{
467- char *p,*q;
468- int i,n,*tpt;
469- double *tx;
470-
471- line=(char*)malloc(LMAX);
472-
473417 p=strtok(input_file," ");
474418 if (p == NULL) p=input_file;
475- fp=fopen(p,"r");
476-
477- while (fgets(line,LMAX,fp) != NULL) {
478- strtok(line,"\r\n");
479- p=strtok(line," ");
480- *y=atof(p); y++;
481-
482- n=0;
483- tx=x; tpt=pt;
484- for (i=0;i<(*MM);i++) {
485- *pt=-1;
486- pt++;
487- }
488- pt=tpt;
489- while ((p=strtok(NULL," ")) != NULL) {
490- q=strchr(p,':'); *q='\0'; q++;
491- *pt=atoi(p);
492- *x=atof(q);
493- pt++;
494- x++;
495- n++;
496- }
497- *nd=n; nd++;
498- x=tx+(*MM); pt=tpt+(*MM);
499- }
500-
501- fclose(fp);
502- free(line);
503-}
504-
505-void write_model_df_(char *output_file, double *y, double *a, double *x, double *b
506- , int *NN, int *MM, double *eps
507- , double *Cost, double *gamma, double *u1, double *u2, double *u3
508- , double *probA, double *probB)
509-{
510- int i,j,k,n;
511- char *p;
512-
513- p=strtok(output_file," ");
514- if (p == NULL) p=output_file;
515419 fp=fopen(p,"w");
516-
420+
517421 n=0;
518422 for (i=0;i<(*NN);i++) {
519423 if (a[i] >= *eps) n++;
520424 }
521425
522- fprintf(fp,"%d %d 0 0\n",n,*MM);
523- fprintf(fp,"%.8E %.8E %.8E %.8E %.8E \n",*Cost,*gamma,*u1,*u2,*u3);
524- fprintf(fp,"%.15E %.15E\n",*probA,*probB);
525- fprintf(fp,"%.15E\n",*b);
526- for (i=0;i<(*NN);i++) {
527- if (a[i] >= *eps) {
528- fprintf(fp,"%.6f %.15E ",y[i],a[i]);
529- for (j=0;j<(*MM);j++) {
530- fprintf(fp,"%.15E ",x[j+(*MM)*i]);
531- }
532- fprintf(fp,"\n");
533- }
426+ fgets(line,LMAX,fp);
427+ for (i=0;i<(*NS);i++) {
428+ fgets(line,LMAX,fp);
534429 }
535-
536- fclose(fp);
537-}
430+ fgets(line,LMAX,fp);
431+ fgets(line,LMAX,fp);
432+ fgets(line,LMAX,fp);
538433
539-void write_model_dfb_(char *output_file, double *y, double *a, double *x, double *b
540- , int *NN, int *MM, double *eps
541- , double *Cost, double *gamma, double *u1, double *u2, double *u3
542- , double *probA, double *probB, double *d)
543-{
544- int i,j,k,n;
545- char *p;
546-
547- p=strtok(output_file," ");
548- if (p == NULL) p=output_file;
549- fp=fopen(p,"w");
550-
551- n=0;
552- for (i=0;i<(*NN);i++) {
553- if (a[i] >= *eps) n++;
554- }
555-
556- fprintf(fp,"%d %d 0 1 %.4f\n",n,*MM,*d);
557- fprintf(fp,"%.8E %.8E %.8E %.8E %.8E \n",*Cost,*gamma,*u1,*u2,*u3);
558- fprintf(fp,"%.15E %.15E\n",*probA,*probB);
559- fprintf(fp,"%.15E\n",*b);
560- for (i=0;i<(*NN);i++) {
561- if (a[i] >= *eps) {
562- fwrite(&y[i],sizeof(double),1,fp);
563- }
564- }
565- for (i=0;i<(*NN);i++) {
566- if (a[i] >= *eps) {
567- fwrite(&a[i],sizeof(double),1,fp);
568- }
569- }
570- for (i=0;i<(*NN);i++) {
571- if (a[i] >= *eps) {
572- for (j=0;j<(*MM);j++) {
573- fwrite(&x[j+(*MM)*i],sizeof(double),1,fp);
434+ if (*is_bin == 1) {
435+ for (i=0;i<(*NN);i++) {
436+ if (a[i] >= *eps) {
437+ fwrite(&y[i],sizeof(double),1,fp);
574438 }
575439 }
576- }
577-
578- fclose(fp);
579-}
580-
581-void write_model_sf_(char *output_file, double *y, double *a, double *x, int *pt, int *nd, double *b
582- , int *NN, int *MM, double *eps
583- , double *Cost, double *gamma, double *u1, double *u2, double *u3
584- , double *probA, double *probB)
585-{
586- int i,j,k,n;
587- char *p;
588-
589- p=strtok(output_file," ");
590- if (p == NULL) p=output_file;
591- fp=fopen(p,"w");
592-
593- n=0;
594- for (i=0;i<(*NN);i++) {
595- if (a[i] >= *eps) n++;
596- }
597-
598- fprintf(fp,"%d %d 1 0\n",n,*MM);
599- fprintf(fp,"%.8E %.8E %.8E %.8E %.8E \n",*Cost,*gamma,*u1,*u2,*u3);
600- fprintf(fp,"%.15E %.15E\n",*probA,*probB);
601- fprintf(fp,"%.15E\n",*b);
602- for (i=0;i<(*NN);i++) {
603- if (a[i] >= *eps) {
604- fprintf(fp,"%.6f %.15E ",y[i],a[i]);
605- for (j=0;j<nd[i];j++) {
606- fprintf(fp,"%d:%-.15E ",pt[j+(*MM)*i],x[j+(*MM)*i]);
440+ for (i=0;i<(*NN);i++) {
441+ if (a[i] >= *eps) {
442+ fwrite(&a[i],sizeof(double),1,fp);
607443 }
608- fprintf(fp,"\n");
609444 }
610- }
611-
612- fclose(fp);
613-}
614445
615-void write_model_sfb_(char *output_file, double *y, double *a, double *x, int *pt, int *nd, double *b
616- , int *NN, int *MM, double *eps
617- , double *Cost, double *gamma, double *u1, double *u2, double *u3
618- , double *probA, double *probB, double *d)
619-{
620- int i,j,k,n;
621- char *p;
622-
623- p=strtok(output_file," ");
624- if (p == NULL) p=output_file;
625- fp=fopen(p,"w");
626-
627- n=0;
628- for (i=0;i<(*NN);i++) {
629- if (a[i] >= *eps) n++;
630- }
631-
632- fprintf(fp,"%d %d 1 1 %.4f\n",n,*MM,*d);
633- fprintf(fp,"%.8E %.8E %.8E %.8E %.8E \n",*Cost,*gamma,*u1,*u2,*u3);
634- fprintf(fp,"%.15E %.15E\n",*probA,*probB);
635- fprintf(fp,"%.15E\n",*b);
636- for (i=0;i<(*NN);i++) {
637- if (a[i] >= *eps) {
638- fwrite(&y[i],sizeof(double),1,fp);
639- }
640- }
641- for (i=0;i<(*NN);i++) {
642- if (a[i] >= *eps) {
643- fwrite(&a[i],sizeof(double),1,fp);
644- }
645- }
646- for (i=0;i<(*NN);i++) {
647- if (a[i] >= *eps) {
648- for (j=0;j<(*MM);j++) {
649- fwrite(&x[j+(*MM)*i],sizeof(double),1,fp);
446+ if (*NS >= 1) {
447+ if (fmt[0] == 0) {
448+ for (i=0;i<(*NN);i++) {
449+ if (a[i] >= *eps) {
450+ for (j=0;j<MM[0];j++) {
451+ fwrite(&x1[j+MM[0]*i],sizeof(double),1,fp);
452+ }
453+ }
454+ }
650455 }
651- }
652- }
653- for (i=0;i<(*NN);i++) {
654- if (a[i] >= *eps) {
655- fwrite(&nd[i],sizeof(int),1,fp);
656- }
657- }
658- for (i=0;i<(*NN);i++) {
659- if (a[i] >= *eps) {
660- for (j=0;j<(*MM);j++) {
661- fwrite(&pt[j+(*MM)*i],sizeof(int),1,fp);
456+ else if (fmt[0] == 1) {
457+ for (i=0;i<(*NN);i++) {
458+ if (a[i] >= *eps) {
459+ for (j=0;j<MM[0];j++) {
460+ fwrite(&x1[j+MM[0]*i],sizeof(double),1,fp);
461+ }
462+ }
463+ }
464+ for (i=0;i<(*NN);i++) {
465+ if (a[i] >= *eps) {
466+ for (j=0;j<MM[0];j++) {
467+ fwrite(&pt1[j+MM[0]*i],sizeof(int),1,fp);
468+ }
469+ }
470+ }
471+ for (i=0;i<(*NN);i++) {
472+ if (a[i] >= *eps) {
473+ fwrite(&nd1[i],sizeof(int),1,fp);
474+ }
475+ }
662476 }
663477 }
664- }
665-
666- fclose(fp);
667-}
668478
669-void read_model_df_(char *model_file, double *y, double *a, double *x)
670-{
671- char *p;
672-
673- line=(char*)malloc(LMAX);
674-
675- p=strtok(model_file," ");
676- if (p == NULL) p=model_file;
677- fp=fopen(p,"r");
678-
679- fgets(line,LMAX,fp);
680- fgets(line,LMAX,fp);
681- fgets(line,LMAX,fp);
682- fgets(line,LMAX,fp);
683-
684- while (fgets(line,LMAX,fp) != NULL) {
685- line[strlen(line)-1]='\0';
686- p=strtok(line," ");
687- if (strlen(p) == 0) {
688- while (1) {
689- p=strtok(NULL," ");
690- if (strlen(p) > 0) break;
479+ if (*NS >= 2) {
480+ if (fmt[1] == 0) {
481+ for (i=0;i<(*NN);i++) {
482+ if (a[i] >= *eps) {
483+ for (j=0;j<MM[1];j++) {
484+ fwrite(&x2[j+MM[1]*i],sizeof(double),1,fp);
485+ }
486+ }
487+ }
691488 }
489+ else if (fmt[1] == 1) {
490+ for (i=0;i<(*NN);i++) {
491+ if (a[i] >= *eps) {
492+ for (j=0;j<MM[1];j++) {
493+ fwrite(&x2[j+MM[1]*i],sizeof(double),1,fp);
494+ }
495+ }
496+ }
497+ for (i=0;i<(*NN);i++) {
498+ if (a[i] >= *eps) {
499+ for (j=0;j<MM[1];j++) {
500+ fwrite(&pt2[j+MM[1]*i],sizeof(int),1,fp);
501+ }
502+ }
503+ }
504+ for (i=0;i<(*NN);i++) {
505+ if (a[i] >= *eps) {
506+ fwrite(&nd2[i],sizeof(int),1,fp);
507+ }
508+ }
509+ }
692510 }
693- *y=atof(p); y++;
694511
695- p=strtok(NULL," ");
696- if (strlen(p) == 0) {
697- while (1) {
698- p=strtok(NULL," ");
699- if (strlen(p) > 0) break;
512+ if (*NS >= 3) {
513+ if (fmt[2] == 0) {
514+ for (i=0;i<(*NN);i++) {
515+ if (a[i] >= *eps) {
516+ for (j=0;j<MM[2];j++) {
517+ fwrite(&x3[j+MM[2]*i],sizeof(double),1,fp);
518+ }
519+ }
520+ }
700521 }
522+ else if (fmt[2] == 1) {
523+ for (i=0;i<(*NN);i++) {
524+ if (a[i] >= *eps) {
525+ for (j=0;j<MM[2];j++) {
526+ fwrite(&x3[j+MM[2]*i],sizeof(double),1,fp);
527+ }
528+ }
529+ }
530+ for (i=0;i<(*NN);i++) {
531+ if (a[i] >= *eps) {
532+ for (j=0;j<MM[2];j++) {
533+ fwrite(&pt3[j+MM[2]*i],sizeof(int),1,fp);
534+ }
535+ }
536+ }
537+ for (i=0;i<(*NN);i++) {
538+ if (a[i] >= *eps) {
539+ fwrite(&nd3[i],sizeof(int),1,fp);
540+ }
541+ }
542+ }
701543 }
702- *a=atof(p); a++;
703-
704- while ((p=strtok(NULL," ")) != NULL) {
705- if (strlen(p) > 0) {
706- *x=atof(p);
707- x++;
544+ }
545+ else {
546+ for (i=0;i<(*NN);i++) {
547+ if (a[i] >= *eps) {
548+ fprintf(fp,"%.15E / %.6f / ",a[i],y[i]);
549+ if (*NS >= 1) {
550+ if (fmt[0] == 0) {
551+ for (j=0;j<MM[0];j++) {
552+ fprintf(fp,"%.15E ",x1[j+MM[0]*i]);
553+ }
554+ }
555+ else if (fmt[0] == 1) {
556+ for (j=0;j<nd1[i];j++) {
557+ fprintf(fp,"%d:%-.15E ",pt1[j+MM[0]*i],x1[j+MM[0]*i]);
558+ }
559+ }
560+ }
561+ if (*NS >= 2) {
562+ fprintf(fp," / ");
563+ if (fmt[1] == 0) {
564+ for (j=0;j<MM[1];j++) {
565+ fprintf(fp,"%.15E ",x2[j+MM[1]*i]);
566+ }
567+ }
568+ else if (fmt[1] == 1) {
569+ for (j=0;j<nd2[i];j++) {
570+ fprintf(fp,"%d:%-.15E ",pt2[j+MM[1]*i],x2[j+MM[1]*i]);
571+ }
572+ }
573+ }
574+ if (*NS >= 3) {
575+ fprintf(fp," / ");
576+ if (fmt[2] == 0) {
577+ for (j=0;j<MM[2];j++) {
578+ fprintf(fp,"%.15E ",x3[j+MM[2]*i]);
579+ }
580+ }
581+ else if (fmt[2] == 1) {
582+ for (j=0;j<nd3[i];j++) {
583+ fprintf(fp,"%d:%-.15E ",pt3[j+MM[2]*i],x3[j+MM[2]*i]);
584+ }
585+ }
586+ }
587+ fprintf(fp,"\n");
708588 }
709589 }
710590 }
711591
712-
713592 fclose(fp);
714- free(line);
715593 }
716594
717-void read_model_dfb_(char *model_file, double *y, double *a, double *x)
718-{
719- char *p;
720- int nn,mm;
721-
722- line=(char*)malloc(LMAX);
723-
724- p=strtok(model_file," ");
725- if (p == NULL) p=model_file;
726- fp=fopen(p,"r");
727-
728- fgets(line,LMAX,fp);
729- sscanf(line,"%d %d",&nn,&mm);
730- fgets(line,LMAX,fp);
731- fgets(line,LMAX,fp);
732- fgets(line,LMAX,fp);
733-
734- fread(y,sizeof(double),nn,fp);
735- fread(a,sizeof(double),nn,fp);
736- fread(x,sizeof(double),nn*mm,fp);
737-
738- fclose(fp);
739- free(line);
740-}
741-
742595 int read_line_df_(char *name, double *z)
743596 {
744597 char *p;
@@ -769,92 +622,6 @@
769622
770623 }
771624
772-void read_model_sf_(char *model_file, double *y, double *a, double *x
773- , int *pt, int *nd, int *MM)
774-{
775- char *p,*q;
776- int n,*tpt;
777- double *tx;
778-
779- line=(char*)malloc(LMAX);
780-
781- p=strtok(model_file," ");
782- if (p == NULL) p=model_file;
783- fp=fopen(p,"r");
784-
785- fgets(line,LMAX,fp);
786- fgets(line,LMAX,fp);
787- fgets(line,LMAX,fp);
788- fgets(line,LMAX,fp);
789-
790- while (fgets(line,LMAX,fp) != NULL) {
791- line[strlen(line)-1]='\0';
792- p=strtok(line," ");
793- if (strlen(p) == 0) {
794- while (1) {
795- p=strtok(NULL," ");
796- if (strlen(p) > 0) break;
797- }
798- }
799- *y=atof(p); y++;
800-
801- p=strtok(NULL," ");
802- if (strlen(p) == 0) {
803- while (1) {
804- p=strtok(NULL," ");
805- if (strlen(p) > 0) break;
806- }
807- }
808- *a=atof(p); a++;
809-
810- n=0;
811- tx=x; tpt=pt;
812- while ((p=strtok(NULL," ")) != NULL) {
813- if (strlen(p) > 0) {
814- q=strchr(p,':'); *q='\0'; q++;
815- *pt=atoi(p);
816- *x=atof(q);
817- pt++;
818- x++;
819- n++;
820- }
821- }
822- *nd=n; nd++;
823- x=tx+(*MM); pt=tpt+(*MM);
824- }
825-
826- fclose(fp);
827- free(line);
828-}
829-
830-void read_model_sfb_(char *model_file, double *y, double *a, double *x
831- , int *pt, int *nd)
832-{
833- char *p;
834- int i,j,nn,mm;
835-
836- line=(char*)malloc(LMAX);
837-
838- p=strtok(model_file," ");
839- if (p == NULL) p=model_file;
840- fp=fopen(p,"r");
841-
842- fgets(line,LMAX,fp);
843- sscanf(line,"%d %d",&nn,&mm);
844- fgets(line,LMAX,fp);
845- fgets(line,LMAX,fp);
846- fgets(line,LMAX,fp);
847-
848- fread(y,sizeof(double),nn,fp);
849- fread(a,sizeof(double),nn,fp);
850- fread(x,sizeof(double),nn*mm,fp);
851- fread(nd,sizeof(int),nn,fp);
852- fread(pt,sizeof(int),nn*mm,fp);
853-
854- fclose(fp);
855- free(line);
856-}
857-
858625 int read_line_sf_(char *name, double *z, int *qt, int *md)
859626 {
860627 char *p,*q;
Show on old repository browser