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

📄 tools.cc

📁 一种聚类算法,名字是cocluster
💻 CC
📖 第 1 页 / 共 5 页
字号:
          if (*(argv+1) == NULL){            cout << "  !!! Invalid col permutation number: (col permutation number should be specified.) !!!" << endl << endl;            validCLA = false;          }          if (validCLA && !isdigit((*(argv+1))[0])){            cout << "  !!! Invalid col permutation number: " << *(argv+1) << " !!!" << endl << endl;            validCLA = false;          }	  tempNum = atoi(*(argv+1));	  if (tempNum <= 0){	    cout << "  !!! Invalid col permutation number: (col permutation number should be a positive integer.): " << tempNum << " !!!" << endl;	    validCLA = false;	  }          if (validCLA){	    myCLA.numColPermutation = atoi(*(++argv));	    myCLA.colInitializationMethod = PERMUTATION_INIT;	  }	  break;        case ROW_LABEL:          if (*(argv+1) == NULL){            cout << "  !!! Invalid row permutation number: (row permutation number should be specified.) !!!" << endl << endl;            validCLA = false;          }          if (validCLA && !isdigit((*(argv+1))[0])){            cout << "  !!! Invalid row permutation number: " << *(argv+1) << " !!!" << endl << endl;            validCLA = false;          }          tempNum = atoi(*(argv+1));	  if (tempNum <= 0){	    cout << "  !!! Invalid row permutation number: (row permutation number should be a positive integer.): " << tempNum << " !!!" << endl;	    validCLA = false;	  }          if (validCLA){	    myCLA.numRowPermutation = atoi(*(++argv));	    myCLA.rowInitializationMethod = PERMUTATION_INIT;	  }	  break;        default:	  cout << "  !!! Invalid permutation seeding label type: " << *argv << " !!!" << endl << endl;          validCLA = false;	  break;      }      break;    default:      cout << "  !!! Invalid seeding paramater(s): " << *argv << " !!!" << endl << endl;      validCLA = false;      break;  }  if (!validCLA){    printSeedingType();    myCLA.numInvalidCLA++;  }  return argv;}// get threshold value for batch update or local search from command-line... char **getThresholdInformation(int argc, char **argv, commandLineArgument &myCLA){  bool validCLA = true;  char tempThresholdInfo = toupper((*(++argv))[0]);  switch (tempThresholdInfo){    case BATCH_UPDATE_STEP:    case LOCAL_SEARCH_STEP:      break;    default:      cout << "  !!! Invalid threshold type: " << *argv << " !!!" << endl << endl;      validCLA = false;  }  if (validCLA){     if (*(argv+1) == NULL){      cout << "  !!! Invalid row threshold: (row local search threshold should be specified.) !!!" << endl << endl;      validCLA = false;    }    if (validCLA && (!isdigit((*(argv+1))[0]) && ((*(argv+1))[0] != '.'))){      cout << "  !!! Invalid row threshold: " << *(argv+1) << " !!!" << endl << endl;      validCLA = false;    }    if (validCLA && (*(argv+2) == NULL)){      cout << "  !!! Invalid col threshold: (col threshold should be specified.) !!!" << endl << endl;      validCLA = false;    }    if (validCLA && (!isdigit((*(argv+2))[0]) && ((*(argv+2))[0] != '.'))){      cout << "  !!! Invalid col threshold: " << *(argv+2) << " !!!" << endl << endl;      validCLA = false;    }    if (validCLA){      switch (tempThresholdInfo){        case BATCH_UPDATE_STEP:          myCLA.rowBatchUpdateThreshold = atof(*(++argv));	  myCLA.colBatchUpdateThreshold = atof(*(++argv));        break;        case LOCAL_SEARCH_STEP:          myCLA.rowLocalSearchThreshold = atof(*(++argv));          myCLA.colLocalSearchThreshold = atof(*(++argv));          break;        default:          cout << "  !!! Invalid threshold type: " << *argv << " !!!" << endl << endl;          validCLA = false;          break;      }    }  }  if (!validCLA){    printThresholdType();    myCLA.numInvalidCLA++;  }  return argv;}// get type of batch update and local search from command-line...char **getUpdateInformation(int argc, char **argv, commandLineArgument &myCLA){  bool validCLA = true;  switch (toupper((*(++argv))[0])){    case BATCH_UPDATE_STEP:      if (*(argv+1) == NULL){        cout << "  !!! Invalid batch update type: (batch update type should be specified.) !!!" << endl << endl;        validCLA = false;      }      if (validCLA && (!isdigit((*(argv+1))[0]))){        cout << "  !!! Invalid batch update type: " << *(argv+1) << " !!!" << endl << endl;        validCLA = false;      }      if (validCLA){        switch ((*(++argv))[0]){          case SINGLE_UPDATE:	    myCLA.batchUpdateType = SINGLE_RESPECTIVELY;	    break;	  case SINGLE_SINGLE_UPDATE:	    myCLA.batchUpdateType = SINGLE_IN_BATCH;	    break;          case MULTIPLE_UPDATE:	    myCLA.batchUpdateType = MULTIPLE_RESPECTIVELY;	    break;          case SINGLE_FLIP:	    myCLA.batchUpdateType = SINGLE_BY_FLIP;	    break;	  case MULTIPLE_FLIP:	    myCLA.batchUpdateType = MULTIPLE_BY_FLIP;	    break;          default:            cout << "  !!! Invalid batch update type: " << *argv << " !!!" << endl << endl;            validCLA = false;	    break;        }      }      break;    case LOCAL_SEARCH_STEP:/*      switch (toupper((*(++argv))[0])){	case 'B':          myCLA.localSearchType = BOTH_ROW_AND_COL;	  break;	case 'C':          myCLA.localSearchType = COL_ONLY;	  break;	case 'R':          myCLA.localSearchType = ROW_ONLY;	  break;        default:          cout << "  Invalid local search update type: " << *argv << endl << endl;          validCLA = false; 	  break;      }*/      if (*(argv+1) == NULL){        cout << "  !!! Invalid row local search length: (row local search length should be specified.) !!!" << endl << endl;        validCLA = false;      }      if (validCLA && (!isdigit((*(argv+1))[0]) && (*(argv+1))[0] != '-')){        cout << "  !!! Invalid row local search length: " << *(argv+1) << " !!!" << endl << endl;        validCLA = false;      }      if (validCLA && (*(argv+2) == NULL)){        cout << "  !!! Invalid col local search length: (col local search length should be specified.) !!!" << endl << endl;        validCLA = false;      }      if (validCLA && (!isdigit((*(argv+2))[0]) && (*(argv+2))[0] != '-')){        cout << "  !!! Invalid col local search length: " << *(argv+2) << " !!!" << endl << endl;        validCLA = false;      }      if (validCLA){        myCLA.rowLocalSearchLength = atoi(*(++argv));        myCLA.colLocalSearchLength = atoi(*(++argv));      }      break;    default:        cout << "  !!! Invalid update type: " << *argv << " !!!" << endl << endl;      validCLA = false;      break;  }  if (!validCLA){    printUpdateType();    myCLA.numInvalidCLA++;  }  return argv;}// get information of taking reverse of rows from command-line...char **getTakingReverse(int argc, char **argv, commandLineArgument &myCLA){  bool validCLA = true;  if (*(argv+1) == NULL){    cout << "  !!! Invalid parameter: (0 or 1 should be specified.) !!!" << endl << endl;    validCLA = false;  }  if (validCLA && !isdigit((*(argv+1))[0])){    cout << "  !!! Invalid parameter: " << *(argv+1) << " !!!" << endl << endl;    validCLA = false;  }  if (validCLA){    switch (atoi(*(++argv))){      case ON:        myCLA.takingReverse = true;	break;      case OFF:        myCLA.takingReverse = false;	break;      default:        cout << " !!! Invalid parameter: (0 or 1 should be specified.): " << myCLA.numRun << " !!!" << endl << endl;        validCLA = false;	break;    }  }  if (!validCLA){    printTakingReverse();    myCLA.numInvalidCLA++;  }  return argv;}// get co-clustering parameter values from command-line...void getCommandLine(int argc, char **argv, commandLineArgument &myCLA){  bool validCLA = true;  for (argv++; *argv != NULL; argv++){            if ((*argv)[0] == '-'){      switch (toupper((*argv)[1])){        case MY_ALGORITHM:		// -A  algorithmType          argv = getAlgorithmType(argc, argv, myCLA);	  break;        case MY_NUM_COL_CLUSTER:	// -C  numColCluster          argv = getColClusterNum(argc, argv, myCLA);          break;        case MY_DUMP_LEVEL:		// -D  dumpLevel          argv = getDumpLevel(argc, argv, myCLA);          break;        case MY_SHOWING_EACH_CLUSTER:	// -E  dumpLevel          argv = getShowingEachCluster(argc, argv, myCLA);          break;        case MY_HELP:	  printHelp();	  break;	case MY_INPUT_FILE:		// -I  inputMatrixType  inputFormatType  inputFilename          argv = getInputFileInformation(argc, argv, myCLA);          break;        case MY_CLASS_FILE:		// -K  classLabelSelection  classOffsetType  classLabelFilename	  argv = getClassFileInformation(argc, argv, myCLA);	  break;        case MY_SMOOTHING:		// -M smoothingType          argv = getSmoothingType(argc, argv, myCLA);          break;        case MY_NUM_RUN:		// -N  runNum          argv = getRunNum(argc, argv, myCLA);          break;        case MY_OUTPUT_FILE:		// -O  outputLabelType  outputAccessMode  labelOffsetType  outputFilename          argv = getOutputFileInformation(argc, argv, myCLA);          break;        case MY_NUM_ROW_CLUSTER:	// -R  numRowCluster          argv = getRowClusterNum(argc, argv, myCLA);          break;        case MY_SEEDING:		// -S  seedingType  seedingLabelSelection [labelOffsetType seedingFilename]          argv = getSeedingInformation(argc, argv, myCLA);          break;        case MY_THRESHOLD:		// -T thresholdType thresholdValue          argv = getThresholdInformation(argc, argv, myCLA);          break;        case MY_UPDATE:			// -U  updateType  updateOrderSelection          argv = getUpdateInformation(argc, argv, myCLA);          break;        case MY_COMPUTING_ONE_WAY:	// -W          argv = getComputingOneWayObjective(argc, argv, myCLA);           break;        case MY_TAKING_REVERSE:		// -X          argv = getTakingReverse(argc, argv, myCLA);          break;        default://          printHelp();	  cout << "  !!! Invalid argument setting: " << *argv << " !!!" << endl << endl;          validCLA = false;          break;      }    } else {      sprintf(myCLA.inputFilename, "%s",*argv);      if (strcmp(myCLA.coclusterFilename, "") == 0)        extractFilename(*argv, myCLA.coclusterFilename);      strcpy(myCLA.dumpFilename, myCLA.coclusterFilename);      strcpy(myCLA.objectiveFilename, myCLA.coclusterFilename);      myCLA.havingArgument = true;    }  }  if (!validCLA){//    printHelp();    myCLA.numInvalidCLA++;  }}void extractFilename(char *path, char *name){  int length = strlen(path);  for(int i = length-1; i >= 0; i--)    if ((path[i] == '/') || (path[i] == '\\')){      i++;      for (int j = i; j < length; j++)        name[j-i] = path[j];      break;    } else if (i == 0){      for (int j = i; j < length; j++)        name[j-i]=path[j];      break;    }}void makeFilename(char *filename, char *suffix, commandLineArgument &myCLA){  char buffer[DEFAULT_STRING_LENGTH];  char rowInit = ' ';  char colInit = ' ';  switch (myCLA.rowInitializationMethod){    case RANDOM_INIT:  		rowInit = 'r';	break;    case RANDOM_PERTURB_INIT:	rowInit = 'p';	break;    case FARTHEST_INIT:		rowInit = 'f';	break;    case PERTURBATION_INIT:	rowInit = 'p';	break;    case SEEDING_INIT:		rowInit = 's';  break;    default:      cout << "  !!! Invalid row initialization: " << myCLA.rowInitializationMethod << " !!!" << endl << endl;      exit(EXIT_FAILURE);      break;  }  switch (myCLA.colInitializationMethod){    case RANDOM_INIT:  		colInit = 'r';	break;    case RANDOM_PERTURB_INIT:	colInit = 'p';	break;    case FARTHEST_INIT:		colInit = 'f';	break;    case PERTURBATION_INIT:	colInit = 'p';	break;    case SEEDING_INIT:		colInit = 's';  break;    default:        cout << "  !!! Invalid column initialization: " << myCLA.colInitializationMethod << " !!!" << endl << endl;      exit(EXIT_FAILURE);      break;  }  sprintf(buffer, "%s_%c%c_%d_%d", suffix, rowInit, colInit, myCLA.numRowCluster, myCLA.numColCluster);  strcat(filename, buffer); }int *readMatrix(char *filename, denseStruct *mat, int &numEmptyCol, int formatType, int matrixType)  //read in a dense matrix; but since either rows are to be clustered or columns are to be clustered,  //we use 'matrixType' to identify that.  //for dense matrix we assume there is NO empty vector.{  std::ifstream dimFile;  std::ifstream inputFile;  char tempFilename[FILENAME_LENGTH];  char whole_line[DEFAULT_STRING_LENGTH];  int *emptyColId;    switch (formatType){

⌨️ 快捷键说明

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