• R/O
  • SSH
  • HTTPS

p-svm: Commit


Commit MetaInfo

Revision34 (tree)
Zeit2014-02-05 22:30:55
Autorkanai7310

Log Message

(empty log message)

Ändern Zusammenfassung

Diff

--- src/IO.c (revision 33)
+++ src/IO.c (revision 34)
@@ -248,6 +248,150 @@
248248 free(line);
249249 }
250250
251+void write_model_ef_(char *output_file, int *is_bin,
252+ int *NS, int *NN, int *MM, int *fmt, double *y, double *a,
253+ double *b, double *probA, double *probB, double *acc,
254+ double *eps, double *Cost, double *gamma,
255+ double *x1, int *pt1, int *nd1,
256+ double *x2, int *pt2, int *nd2,
257+ double *x3, int *pt3, int *nd3)
258+{
259+ int i,j,k,n;
260+ char *p;
261+
262+ p=strtok(output_file," ");
263+ if (p == NULL) p=output_file;
264+ fp=fopen(p,"w");
265+
266+ n=0;
267+ for (i=0;i<(*NN);i++) {
268+ if (a[i] >= *eps) n++;
269+ }
270+
271+ fprintf(fp,"%d %d %.4f\n",*NS,n,*acc);
272+ for (i=0;i<(*NS);i++) {
273+ fprintf(fp,"%d %d\n",MM[i],fmt[i]);
274+ }
275+ fprintf(fp,"%.8E %.8E\n",*Cost,*gamma);
276+ fprintf(fp,"%.15E %.15E\n",*probA,*probB);
277+ fprintf(fp,"%.15E\n",*b);
278+
279+ if (*is_bin == 1) {
280+ for (i=0;i<(*NN);i++) {
281+ if (a[i] >= *eps) {
282+ fwrite(&y[i],sizeof(double),1,fp);
283+ }
284+ }
285+ for (i=0;i<(*NN);i++) {
286+ if (a[i] >= *eps) {
287+ fwrite(&a[i],sizeof(double),1,fp);
288+ }
289+ }
290+
291+ if (*NS >= 1) {
292+ if (fmt[0] == 0) {
293+ for (i=0;i<(*NN);i++) {
294+ if (a[i] >= *eps) {
295+ for (j=0;j<MM[0];j++) {
296+ fwrite(&x1[j+MM[0]*i],sizeof(double),1,fp);
297+ }
298+ }
299+ }
300+ }
301+ else if (fmt[0] == 1) {
302+ for (i=0;i<(*NN);i++) {
303+ if (a[i] >= *eps) {
304+ for (j=0;j<MM[0];j++) {
305+ fwrite(&x1[j+MM[0]*i],sizeof(double),1,fp);
306+ }
307+ }
308+ }
309+ for (i=0;i<(*NN);i++) {
310+ if (a[i] >= *eps) {
311+ for (j=0;j<MM[0];j++) {
312+ fwrite(&pt1[j+MM[0]*i],sizeof(int),1,fp);
313+ }
314+ }
315+ }
316+ for (i=0;i<(*NN);i++) {
317+ if (a[i] >= *eps) {
318+ fwrite(&nd1[i],sizeof(int),1,fp);
319+ }
320+ }
321+ }
322+ }
323+
324+ if (*NS >= 2) {
325+ if (fmt[1] == 0) {
326+ for (i=0;i<(*NN);i++) {
327+ if (a[i] >= *eps) {
328+ for (j=0;j<MM[1];j++) {
329+ fwrite(&x2[j+MM[1]*i],sizeof(double),1,fp);
330+ }
331+ }
332+ }
333+ }
334+ else if (fmt[1] == 1) {
335+ for (i=0;i<(*NN);i++) {
336+ if (a[i] >= *eps) {
337+ for (j=0;j<MM[1];j++) {
338+ fwrite(&x2[j+MM[1]*i],sizeof(double),1,fp);
339+ }
340+ }
341+ }
342+ for (i=0;i<(*NN);i++) {
343+ if (a[i] >= *eps) {
344+ for (j=0;j<MM[1];j++) {
345+ fwrite(&pt2[j+MM[1]*i],sizeof(int),1,fp);
346+ }
347+ }
348+ }
349+ for (i=0;i<(*NN);i++) {
350+ if (a[i] >= *eps) {
351+ fwrite(&nd2[i],sizeof(int),1,fp);
352+ }
353+ }
354+ }
355+ }
356+
357+ if (*NS >= 3) {
358+ if (fmt[2] == 0) {
359+ for (i=0;i<(*NN);i++) {
360+ if (a[i] >= *eps) {
361+ for (j=0;j<MM[2];j++) {
362+ fwrite(&x3[j+MM[2]*i],sizeof(double),1,fp);
363+ }
364+ }
365+ }
366+ }
367+ else if (fmt[2] == 1) {
368+ for (i=0;i<(*NN);i++) {
369+ if (a[i] >= *eps) {
370+ for (j=0;j<MM[2];j++) {
371+ fwrite(&x3[j+MM[2]*i],sizeof(double),1,fp);
372+ }
373+ }
374+ }
375+ for (i=0;i<(*NN);i++) {
376+ if (a[i] >= *eps) {
377+ for (j=0;j<MM[2];j++) {
378+ fwrite(&pt3[j+MM[2]*i],sizeof(int),1,fp);
379+ }
380+ }
381+ }
382+ for (i=0;i<(*NN);i++) {
383+ if (a[i] >= *eps) {
384+ fwrite(&nd3[i],sizeof(int),1,fp);
385+ }
386+ }
387+ }
388+ }
389+
390+ }
391+
392+ fclose(fp);
393+}
394+
251395 void read_df_(char *input_file, double *y, double *x)
252396 {
253397 char *p;
Show on old repository browser