📄 gener_data.c
字号:
/*----------------------------------------------------------------------*//* Version : 1.0 *//* Creation : 02/09/00 *//* Derniere modif.: 08/05/01 *//* Sujet : Mise en oeuvre d'une SVM multi-classe *//* Intitule : Donnees du pb. jouet [Elisseeff 00] p. 59 *//* Auteur : Yann Guermeur *//*----------------------------------------------------------------------*/#include <stdio.h>#include <string.h>#include <math.h>#include <ctype.h>#define Q 3#define taille 81#define true 1#define false 0FILE *fc[Q+1];long i, k, nb_data=0, dim_input=2, classe;char *fichier_cible[Q+1], chaine[taille];double x, y, drand48();/* Procedures appelees dans ce programme */main(int argc, char *argv[]){strcpy(chaine, argv[1]);nb_data=atol(chaine);srand48(getpid());for(k=0; k<=Q; k++) { fichier_cible[k] = (char *) calloc(taille, sizeof(char)); sprintf(fichier_cible[k], "../Data/toy.%d", k); }for(k=0; k<=Q; k++) if((fc[k]=fopen(fichier_cible[k], "w"))==NULL) { printf("\nTarget file: %s cannot be open...\n", fichier_cible[k]); exit(0); }fprintf(fc[0],"%d\n", nb_data);fprintf(fc[0],"%d\n", dim_input);for(i=0; i<nb_data; i++) { x = drand48(); y = drand48(); if(y < x) { if(y > 1.0 - x) classe=1; else classe=3; } else classe=2; fprintf(fc[0],"%lf %lf %2d\n", x, y, classe); fprintf(fc[classe],"%lf %lf\n", x, y); }for(k=0; k<=Q; k++) fclose(fc[k]);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -