⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cle.c

📁 it is the Data Mining Algorithm source code.
💻 C
📖 第 1 页 / 共 2 页
字号:
/*----------------------------------------------------------------------  File    : cle.c  Contents: probabilistic and fuzzy cluster evaluation  Author  : Christian Borgelt  History : 2003.05.17 file created            2003.05.18 setting of noise parameter (option -y) added            2003.06.09 coverage of data added            2003.08.16 slight changes in error message output            2004.02.25 source files mcle.c and cle.c combined            2006.01.28 conditional compilation simplified            2007.02.14 adapted to changed module tabscan            2007.03.16 table and matrix version combined----------------------------------------------------------------------*/#include <stdio.h>#include <stdlib.h>#include <stdarg.h>#include <string.h>#include <math.h>#include <time.h>#include <assert.h>#ifndef AS_RDWR#define AS_RDWR#endif#ifndef AS_PARSE#define AS_PARSE#endif#include "io.h"#ifndef MAT_READ#define MAT_READ#endif#ifndef CLS_PARSE#define CLS_PARSE#endif#ifndef CLS_EXTFN#define CLS_EXTFN#endif#include "cluster.h"/*----------------------------------------------------------------------  Preprocessor Definitions----------------------------------------------------------------------*/#define PRGNAME     "cle"#define DESCRIPTION "probabilistic and fuzzy cluster evaluation"#define VERSION     "version 2.0 (2008.04.11)         " \                    "(c) 2003-2008   Christian Borgelt"/* --- error codes --- */#define OK            0         /* no error */#define E_NONE        0         /* no error */#define E_NOMEM     (-1)        /* not enough memory */#define E_FOPEN     (-2)        /* file open failed */#define E_FREAD     (-3)        /* file read failed */#define E_FWRITE    (-4)        /* file write failed */#define E_OPTION    (-5)        /* unknown option */#define E_OPTARG    (-6)        /* missing option argument */#define E_ARGCNT    (-7)        /* wrong number of arguments */#define E_STDIN     (-8)        /* double assignment of stdin */#define E_PARSE     (-9)        /* parse errors on input file */#define E_PATCNT   (-10)        /* no pattern found */#define E_PATSIZE  (-11)        /* invalid pattern size */#define E_UNKNOWN  (-18)        /* unknown error *//*----------------------------------------------------------------------  Constants----------------------------------------------------------------------*/static const char *errmsgs[] = {   /* error messages */  /* E_NONE      0 */  "no error\n",  /* E_NOMEM    -1 */  "not enough memory\n",  /* E_FOPEN    -2 */  "cannot open file %s\n",  /* E_FREAD    -3 */  "read error on file %s\n",  /* E_FWRITE   -4 */  "write error on file %s\n",  /* E_OPTION   -5 */  "unknown option -%c\n",  /* E_OPTARG   -6 */  "missing option argument\n",  /* E_ARGCNT   -7 */  "wrong number of arguments\n",  /* E_STDIN    -8 */  "double assignment of standard input\n",  /* E_PARSE    -9 */  "parse error(s) on file %s\n",  /* E_PATCNT  -10 */  "no pattern in file %s\n",  /* E_PATSIZE -11 */  "invalid pattern size %d\n",  /*    -12 to -15 */  NULL, NULL, NULL, NULL,  /* E_VALUE   -16 */  "file %s, record %d: "                         "invalid value %s in field %d\n",  /* E_FLDCNT  -17 */  "file %s, record %d: "                         "%s%d field(s) instead of %d\n",  /* E_UNKNOWN -18 */  "unknown error\n",};/*----------------------------------------------------------------------  Global Variables----------------------------------------------------------------------*/const  char    *prgname = NULL; /* program name for error messages */static FILE    *in      = NULL; /* input  file */static ATTSET  *attset  = NULL; /* attribute set */static ATTMAP  *attmap  = NULL; /* attribute map */static TABSCAN *tscan   = NULL; /* table scanner */static SCAN    *scan    = NULL; /* scanner for cluster set desc. */static CLSET   *clset   = NULL; /* cluster set *//*----------------------------------------------------------------------  Main Functions----------------------------------------------------------------------*/static void error (int code, ...){                               /* --- print error message */  va_list    args;              /* list of variable arguments */  const char *msg;              /* error message */  assert(prgname);              /* check the program name */  if (code < E_UNKNOWN) code = E_UNKNOWN;  if (code < 0) {               /* if to report an error, */    msg = errmsgs[-code];       /* get the error message */    if (!msg) msg = errmsgs[-E_UNKNOWN];    fprintf(stderr, "\n%s: ", prgname);    va_start(args, code);       /* get variable arguments */    vfprintf(stderr, msg, args);/* print the error message */    va_end(args);               /* end argument evaluation */  }  #ifndef NDEBUG                      /* clean up memory */  if (clset)  cls_deletex(clset, 0);  /* and close files */  if (tscan)  ts_delete(tscan);  if (attmap) am_delete(attmap);  if (attset) as_delete(attset);  if (scan)   sc_delete(scan);  if (in && (in != stdin)) fclose(in);  #endif  exit(code);                   /* abort the program */}  /* error() *//*--------------------------------------------------------------------*/int main (int argc, char *argv[]){                               /* --- main function */  int    i, k = 0;              /* loop variables, counters */  char   *s;                    /* to traverse options */  char   **optarg = NULL;       /* option argument */  char   *fn_cls  = NULL;       /* name of cluster set file */  char   *fn_hdr  = NULL;       /* name of table header file */  char   *fn_in   = NULL;       /* name of table file */  char   *blanks  = NULL;       /* blank   characters */  char   *fldseps = NULL;       /* field   separators */  char   *recseps = NULL;       /* record  separators */  char   *comment = NULL;       /* comment characters */  int    matinp   = 0;          /* flag for numerical matrix input */  double radius   = 1;          /* radius for (avg.) part. density */  int    patcnt   = 0;          /* number of test patterns */  int    flags    = 0, f;       /* table file read flags */  int    tplcnt   = 0;          /* number of tuples */  double tplwgt   = 0.0, w;     /* weight of tuples */  double *pat;                  /* to traverse the patterns */  int    attcnt;                /* number of values in a pattern */  int    clscnt;                /* number of clusters */  TSINFO *tse;                  /* error information */  prgname = argv[0];            /* get program name for error msgs. */  /* --- print startup/usage message --- */  if (argc > 1) {               /* if arguments are given */    fprintf(stderr, "%s - %s\n", argv[0], DESCRIPTION);    fprintf(stderr, VERSION); } /* print a startup message */  else {                        /* if no argument is given */    printf("usage: %s [options] clsfile [-d|-h hdrfile] "                     "tabfile\n", argv[0]);    printf("%s\n", DESCRIPTION);    printf("%s\n", VERSION);    printf("-p#      radius for (average) partition density "                    "(default: %g)\n", radius);    printf("-b/f/r#  blank characters, field and record separators\n"           "         (default: \" \\t\\r\", \" ,\\t\", \"\\n\")\n");    printf("-C#      comment characters (default: \"#\")\n");    printf("clsfile  file to read cluster set description from\n");    printf("-d       use default header "                    "(field names = field numbers)\n");    printf("-h       read table header (field names) from hdrfile\n");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -