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

📄 mpdiag

📁 it is the Data Mining Algorithm source code.
💻
字号:
#!/bin/bashin=${3:-data.txt}out=${4:-diag.mp}gawk -v figno=$1 -v params="$2" 'BEGIN {  n   = -1;                     # split the parameters  cnt = split(params, vec, "|") -2;  for (i in vec) {              # traverse the lines    m = split(vec[i], args, ":");    for (k in args) {           # split line into fields      while (sub("\n",  "", args[k]));      sub("^ *", "", args[k]);  # remove leading  blanks      sub(" *$", "", args[k]);  # remove trailing blanks    }    if      (i == 1) {          # if control line      title       = args[1];    # get diagram title and legend position      legpos      = (m < 2) ? "toprgt" : args[2]; }    else if (i == 2) {          # if scaling line      scale       = args[1];    # note the scaling parameters      xmin_low    = args[2];      xmin_high   = args[3];      xmax_low    = args[4];      xmax_high   = args[5];      ymin_low    = args[6];      ymin_high   = args[7];      ymax_low    = args[8];      ymax_high   = args[9]; }    else {                      # if graph line      k = i-2;                  # compute the curve index      rownames[k] = args[1];    # note the curve parameters      colnames[k] = args[2];      colors  [k] = args[3];      styles  [k] = args[4];      descs   [k] = (m < 5) ? args[1] : args[5];      legline [k] = (m < 6) ? -2      : args[6];    }  }}($1 == ">") {  for (c = 2; ++c <= NF; )    for (i in colnames)      if (colnames[i] == $c) colids[i] = c-1;  curr = $2; k = -1;}($1 != ">") {  for (i in rownames) {    if ($1 != rownames[i]) continue;    if (k < 0) x[k = ++n] = curr;    value = $colids[i];    if      (value == "*")   y[i,k] = "*";    else if (scale != "log") y[i,k] = value *scale;    else if (value <= 0)     y[i,k] = "*";    else                     y[i,k] = log(value)/log(10);  }}END {                           # after file has been processed  n++;                          # compute the number of data points  printf("beginfig(%d);\n", figno);  xmin = 1e12; xmax = -1e12;  ymin = 1e12; ymax = -1e12;  for (k = 0; k < n; k++) {     # traverse all data pairs    if (x[k] < xmin) xmin = x[k];    if (x[k] > xmax) xmax = x[k];    for (i = 1; i <= cnt; i++) {      if (y[i,k] == "*") continue;      if (y[i,k] < ymin) ymin = y[i,k];      if (y[i,k] > ymax) ymax = y[i,k];    }                           # find ranges of values  }  d = (xmax -xmin) *0.03;       # compute x value range  xmin -= d; xmax += d;         # and x scaling factor  if ((xmin_low  != "*") && (xmin < xmin_low )) xmin = xmin_low;  if ((xmin_high != "*") && (xmin > xmin_high)) xmin = xmin_high;  if ((xmax_low  != "*") && (xmax < xmax_low )) xmax = xmax_low;  if ((xmax_high != "*") && (xmax > xmax_high)) xmax = xmax_high;  xscl = (xmax > xmin) ? 100/(xmax-xmin) : 1;  d = (ymax -ymin) *0.03;       # compute y value range  ymin -= d; ymax += d;         # and y scaling factor  if ((ymin_low  != "*") && (ymin < ymin_low )) ymin = ymin_low;  if ((ymin_high != "*") && (ymin > ymin_high)) ymin = ymin_high;  if ((ymax_low  != "*") && (ymax < ymax_low )) ymax = ymax_low;  if ((ymax_high != "*") && (ymax > ymax_high)) ymax = ymax_high;  yscl = (ymax > ymin) ? 100/(ymax-ymin) : 1;  printf("  scale(%g, %g, %g, %g);\n", xmin, ymin, xscl, yscl);  range = xmax -xmin;  if      (range <= 0.8) inc = 0.1;  else if (range <= 1.6) inc = 0.2;  else if (range <= 4.0) inc = 0.5;  else if (range <= 8.0) inc =   1;  else if (range <= 20)  inc =   2;  else if (range <= 40)  inc =   5;  else if (range <= 80)  inc =  10;  else if (range <= 160) inc =  20;  else if (range <= 400) inc =  50;  else                   inc = 100;  beg = inc*int(xmin/inc);  end = inc*int(xmax/inc);  printf("  xtics(");  for (i = beg; i < end; i += inc)    if ((i >= xmin) && (i < xmax))      printf("%.1f,", i);       # print tics  printf("%.1f);\n", end);      # on x-axis  range = ymax -ymin;  if (scale == "log")    inc =   1;  else if (range <= 0.6) inc = 0.1;  else if (range <= 1.2) inc = 0.2;  else if (range <= 3.0) inc = 0.5;  else if (range <= 6.0) inc =   1;  else if (range <= 12)  inc =   2;  else if (range <= 30)  inc =   5;  else if (range <= 60)  inc =  10;  else if (range <= 120) inc =  20;  else if (range <= 300) inc =  50;  else                   inc = 100;  beg = inc*int(ymin/inc);  end = inc*int(ymax/inc);  printf("  ytics(");  printf((scale == "log") ? "log, " : "linear, ");  for (i = beg; i < end; i += inc)    if ((i >= ymin) && (i <= ymax))      printf("%.1f,", i);       # print tics  printf("%.1f);\n", end);      # on y-axis  printf("  diag;\n");          # draw background diagram  for (i = 1; i <= cnt; i++) {  # traverse the curves    for (k = p = 0; k < n; k++){# print the data points      if ( x[k]   < xmin) continue;      if ((x[k]   > xmax) || (y[i,k] == "*") \      ||  (y[i,k] > ymax) || (y[i,k] < ymin))        break;      printf("  x%d := %5.2f;",  p, x[k]);      printf(" y%d := %6.3f;\n", p, y[i,k]); p++;    }    if (p <= 0) continue;    printf("  curve(\"%s\", %d, %d, %s, %s);\n",                    descs[i], p, legline[i], colors[i], styles[i]);    printf("%% %s %s\n", rownames[i], colnames[i]);  }  printf("  legend(\"%s\", %s);\n", title, legpos);  printf("endfig;\n\n");        # draw the legend  printf("%-----------------------------------");  printf("------------------------------------\n\n");}' "$in" >> "$out"

⌨️ 快捷键说明

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