コード例 #1
0
void AbscissaTransformDialog::on_buttonBox_accepted()
{
    double out_factor = ParseInput(ui->outFactorLineEdit->text());
    double in_factor = ParseInput(ui->inFactorLineEdit->text());
    QString out_units = ui->outUnitsComboBox->currentText();
    QString in_units = ui->inUnitsComboBox->currentText();
    QString description = ui->descriptionLineEdit->text();
    if (in_factor * out_factor){
        dataset_->TransformAbscissa(in_units, in_factor, out_units, out_factor, description);
    }
}
コード例 #2
0
ファイル: networkbuilder.cpp プロジェクト: bhanu475/tesseract
// Parses the given string and returns a network according to the network
// description language in networkbuilder.h
Network* NetworkBuilder::BuildFromString(const StaticShape& input_shape,
                                         char** str) {
  SkipWhitespace(str);
  char code_ch = **str;
  if (code_ch == '[') {
    return ParseSeries(input_shape, nullptr, str);
  }
  if (input_shape.depth() == 0) {
    // There must be an input at this point.
    return ParseInput(str);
  }
  switch (code_ch) {
    case '(':
      return ParseParallel(input_shape, str);
    case 'R':
      return ParseR(input_shape, str);
    case 'S':
      return ParseS(input_shape, str);
    case 'C':
      return ParseC(input_shape, str);
    case 'M':
      return ParseM(input_shape, str);
    case 'L':
      return ParseLSTM(input_shape, str);
    case 'F':
      return ParseFullyConnected(input_shape, str);
    case 'O':
      return ParseOutput(input_shape, str);
    default:
      tprintf("Invalid network spec:%s\n", *str);
      return nullptr;
  }
  return nullptr;
}
コード例 #3
0
ファイル: myui1.c プロジェクト: jkarson/mystoreProj
int main(){
  printf("Read the standard output using fread() and write it to the terminal using fwrite()...\n");
  ReadStdin();
  printf("\nParse the data and print it in reverse order...\n");
  ParseInput();
  return 1;
}
コード例 #4
0
ファイル: Game.cpp プロジェクト: MihailTrajkovski/xiq
bool Game::Update(GameTime)
{
	time.StartFrame();

	SDL_LockAudio();
	{
		ParseInput();
		if (Transitioning())
		{
			Transist();
		}
		else if (phase)
		{
			phase->Update(time);
		}
	}
	SDL_UnlockAudio();

	GetFactory()->Purge();

	if (finished)
	{
		SDL_CloseAudio();
	}

	return !finished;
}
コード例 #5
0
RImplInfoArray* CAiwResolver::ListAllL(TUid aInterfaceUid, 
    const TEComResolverParams& aAdditionalParameters) const
    {
    // Use the member var to create the array so that we get proper cleanup behaviour
    delete iImplementationInfoArray;
    iImplementationInfoArray = NULL;
    iImplementationInfoArray = new (ELeave) RImplInfoArray;
    RImplInfoArray* retList = iImplementationInfoArray;

    RImplInfoArray& fullList = iRegistry.ListImplementationsL(aInterfaceUid);

    const TBool useWildcards = aAdditionalParameters.IsWildcardMatch();
    TBuf8<KMaxDataItemSize> content;
    TBuf8<KMaxDataItemSize> opaque;

    ParseInput(aAdditionalParameters.DataType(), content, opaque);
    const TInt numImps = fullList.Count();

    for (TInt index = 0; index < numImps; ++index)
        {
        if (Match(fullList[index]->DataType(), content, useWildcards) &&
            MatchServiceCmd(fullList[index]->OpaqueData(), opaque))
            {
            User::LeaveIfError(retList->Append(fullList[index]));
            }
        }

    // Reset the member variable because we are passing ownership back
    iImplementationInfoArray = NULL;

    return retList;
    }
コード例 #6
0
ファイル: myui2.c プロジェクト: jkarson/mystoreProj
void display(){
  xt_par0(XT_CLEAR_SCREEN);
  xt_par2(XT_SET_ROW_COL_POS, 1, 1);
  xt_par0(XT_CH_BOLD);
  printf("Welcome to MyStore.\n");
  xt_par0(XT_CH_NORMAL);
  printf("Scroll through records using left and right arrow keys.\n\n");
  printf("Press F2 to add a new record\n");
  printf("Press F3 to delete current record\n");
  printf("Press F4 to return to welcome screen\n");
  printf("Press F5 to delete all records\n");
  printf("Press F6 to edit\n");
  printf("Press F7 to SEARCH for a key word\n");
  printf("Press F9 to jump to first record\n");
  if (numRecords == 0){
    xt_par0(XT_CH_BOLD);
    printf("\n\n\nNO RECORDS AS OF YET");
    xt_par0(XT_CH_NORMAL);
    viewRecordHelper();
  }
  else{
    char strRecordNum[10];
    sprintf(strRecordNum, "%d", recordNum);
    ReadMystoreFromChild("display", strRecordNum, NULL, NULL);
    setNumStructsNeeded();
    ParseInput();



    char *date = (char *)malloc(100 * sizeof(char));
    date = pairs[2].value;
    char *subject = (char *)malloc(30 * sizeof(char));

    subject = pairs[3].value;
    char *body = (char *)malloc(141 * sizeof(char));
    body = pairs[4].value;
    xt_par2(XT_SET_ROW_COL_POS, 15, 1);
    xt_par0(XT_CH_BOLD);
    printf("ITEM #: ");
    xt_par0(XT_CH_NORMAL);
    printf("%d\n", recordNum);
    xt_par2(XT_SET_ROW_COL_POS, 16, 1);
    xt_par0(XT_CH_BOLD);
    printf("SUBJECT: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", subject);
    xt_par2(XT_SET_ROW_COL_POS, 17,1);
    xt_par0(XT_CH_BOLD);
    printf("BODY: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", body);
    xt_par2(XT_SET_ROW_COL_POS, 19, 1);
    xt_par0(XT_CH_BOLD);
    printf("TIME ADDED: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", date);
    viewRecordHelper();
  }
}
コード例 #7
0
ファイル: ProofTests.C プロジェクト: dawehner/root
//_____________________________________________________________________________
void ProofTests::Begin(TTree * /*tree*/)
{
   // The Begin() function is called at the start of the query.
   // When running with PROOF Begin() is only called on the client.
   // The tree argument is deprecated (on PROOF 0 is passed).

   // Fill relevant members
   ParseInput();
}
コード例 #8
0
ファイル: myui2.c プロジェクト: jkarson/mystoreProj
void calculateNumRecords(){
  ReadMystoreFromChild("stat",NULL,NULL,NULL);
  setNumStructsNeeded();
  ParseInput();
  numRecords = atoi(pairs[3].value);
  if (numRecords > 0)
    recordNum = 1;
  //  printf("calculate num records: %d\n", numRecords);
}
コード例 #9
0
int main(int argumentCount, char** arguments)
{
	auto games = ParseInput(argumentCount, arguments);
	
	EvaluateGames(games);

	ReportResults(games);

	return 0;
}
コード例 #10
0
ファイル: RTSPclient.cpp プロジェクト: yyd01245/bbcvision
int CRTSPclient::ServConnect (const char * serverURL) {
	int res = 0;
	unsigned int addr;
	int socket_type = SOCK_STREAM;
	struct sockaddr_in server;
	struct hostent *hp;

	if (state != IDLE) {
		Disconnect ();
		state = IDLE;
	}
	strcpy (session, ""); 
	strcpy (sessName, ""); 
	strcpy (accept, "");	
	numMedia = 0;	

	if ((res = ParseInput (serverURL)) != 0) 
		MessageBox(NULL, "Invalid server URL!", "Network Error", MB_OK);
	else {
		// Good URL, stored in the host, port and file globals
		if (isalpha(host[0])) {   /* server address is a name */
			hp = gethostbyname(host);
		}
		else  { /* Convert nnn.nnn address to a usable one */
			addr = inet_addr(host);
	//		hp = gethostbyaddr((char *)&addr,4,AF_INET);
		}
//		if (hp == NULL ) {
//			MessageBox(NULL, "Host not found!", "Network Error", MB_OK);
//			return 10;
//		}

		memset(&server,0,sizeof(server));
		//memcpy(&(server.sin_addr),hp->h_addr,hp->h_length);
		server.sin_family = AF_INET;
		server.sin_port = htons(port);
		server.sin_addr.s_addr = inet_addr(host);

		serv_socket = socket(AF_INET,socket_type,0); /* Open the socket */
		if (serv_socket <0 ) {
			MessageBox(NULL, "Could not open the socket!", "Network Error", MB_OK);
			return 11;
		}
 
		if (connect(serv_socket, (struct sockaddr*)&server, sizeof(server)) == SOCKET_ERROR) {
			MessageBox(NULL, "Could not connect to the server!", "Network Error", MB_OK);
			return 12;
		}
	}

	return res;
}
コード例 #11
0
ファイル: mobile-bench.c プロジェクト: autisyu/mobilebench
int main(int argc, char **argv)
{
    if (argc != 7) {
        Usage();
    }
    if (worker > 10) {
        fprintf(stderr, "too much worker you choose, we reset it to 10\n");
        worker = 10;
    }
    ParseInput(argc, argv);
    Process(worker);
    return 0;
}
コード例 #12
0
void LoadInputs()
{
  Sint64 size;
  char *buffer;
  char buf[512];
  char input[16];
  int s;
  PHYSFS_File *PSfile;
  FILE *file;
  PSfile = PHYSFS_openRead("system/controls.cfg");
  if(PSfile == NULL)
  {
    fprintf(stderr,"Unable to open control configuration file!\n");
    return;
  }
  size = PHYSFS_fileLength(PSfile);
  buffer = (char *)malloc(size);
  if(buffer == NULL)
  {
    fprintf(stderr,"Unable to allocate space for control configuration file\n");
    PHYSFS_close(PSfile);
    return;
  }
  NumInputs = 0;
  PHYSFS_read(PSfile, buffer, size, 1);
  file = fmemopen (buffer, size, "r");
  while(fscanf(file, "%s", buf) != EOF)
  {
    if(strcmp(buf,"#") ==0)
    {
      fgets(buf, sizeof(buf), file);
      continue;/*ignore the rest of the line.*/
    }
    if(strcmp(buf,"<input>") ==0)
    {
      fscanf(file, "%s %s %s",InputList[NumInputs].name,InputList[NumInputs].type,input);
      s = ParseInput(InputList[NumInputs].type,input);
      if(s != -1)
      {
        InputList[NumInputs].id = s;
        NumInputs++;
      }
      continue;
    }
    
  }
  fclose(file);
  PHYSFS_close(PSfile);
  free(buffer);
}
コード例 #13
0
int main(int argc, char** argv) {
    WORD KeyVal;
    char ResString[10];
    
    void Ludacris_Speed_GO(void);
    Ludacris_Speed_GO();
    InitGlobals();
    InitLCD();
    
    Timer1_Setup();

    UART1_Config();
    Pin_Setup();
    printf("\nUART Configured\n\n");

    while(1)
    {
        __delay_ms(250);
        PutsXLCD("No Workie!  ");
        if(!Calculate)
        {
          if(TriggerGetKeys)
            {
                KeyVal = GetKeyPressed();
                FindKey(KeyVal);
                if(Key != NULL)
                {
                    ParseInput(Key);
                }
            TriggerGetKeys = 0;
            }
        }
        else
        {
            DoCalculate();
            printf("%f\n", Terms.Result);
            sprintf(ResString, "%f", Terms.Result);
            PutsXLCD(ResString);
            TriggerGetKeys = 0;
            Calculate = 0;
            GotOperand1 = 0;
            GotOperand2 = 0;
            Operation = NO_OP;
        }
    }

    return (EXIT_SUCCESS);
}
コード例 #14
0
int main (){

  int nQueens;
  int size;
  int verbose;
  
  Solution* Sol;
  char** PrintMat;
  int hasSol;
  
  int start = 0;
  int limit;

  ParseInput(&nQueens, &size, &verbose);
  
  if(nQueens - size > 1){
    start = 1;
  }
  if(size > 15){
    start = size;
  } 

  for(int i=start; i<size; i++){
    for(int j=0; j<size; j++){
      Sol = NewSolution(size);
      hasSol = SolveQueens(Sol, 0, nQueens);

      start = (nQueens - size > 0);
    }
  }

  if(hasSol)
    printf("%d\n", Sol->nKnights);
  else
    printf("-1\n");

  if(verbose && hasSol){
    PrintMat = AsMatSolution(Sol);
    PrintCharMat(PrintMat, size, size);
    DestroyCharMat(PrintMat, size);
  }

  DestroySolution(Sol);

  return 0;
}
コード例 #15
0
ファイル: Dvi.c プロジェクト: ajinkya93/netbsd-src
static void
FindPage (DviWidget dw)
{
	int	i;
	long	file_position;

	if (dw->dvi.requested_page < 1)
		dw->dvi.requested_page = 1;

	if (dw->dvi.last_page != 0 && dw->dvi.requested_page > dw->dvi.last_page)
		dw->dvi.requested_page = dw->dvi.last_page;

	file_position = SearchPagePosition (dw, dw->dvi.requested_page);
	if (file_position != -1) {
		FileSeek(dw, file_position);
		dw->dvi.current_page = dw->dvi.requested_page;
	} else {
		for (i=dw->dvi.requested_page; i > 0; i--) {
			file_position = SearchPagePosition (dw, i);
			if (file_position != -1)
				break;
		}
		if (file_position == -1)
			file_position = 0;
		FileSeek (dw, file_position);

		dw->dvi.current_page = i;
		
		dw->dvi.display_enable = 0;
		while (dw->dvi.current_page != dw->dvi.requested_page) {
			dw->dvi.current_page = ParseInput (dw);
			/*
			 * at EOF, seek back to the beginning of this page.
			 */
			if (!dw->dvi.readingTmp && feof (dw->dvi.file)) {
				file_position = SearchPagePosition (dw,
						dw->dvi.current_page);
				if (file_position != -1)
					FileSeek (dw, file_position);
				dw->dvi.requested_page = dw->dvi.current_page;
				break;
			}
		}
	}
}
コード例 #16
0
ファイル: construct.c プロジェクト: agottem/trigger_script
int TSDef_ConstructUnitFromString (
                                   char*                        program_string,
                                   char*                        name,
                                   struct tsdef_unit*           unit,
                                   struct tsdef_def_error_list* errors
                                  )
{
    struct yy_buffer_state* lex_buffer;
    int                     error;

    lex_buffer = yy_scan_string(program_string);
    if(lex_buffer == NULL)
        return TSDEF_ERROR_MEMORY;

    error = ParseInput(name, unit, errors);

    yy_delete_buffer(lex_buffer);

    return error;
}
コード例 #17
0
ファイル: Dvi.c プロジェクト: ajinkya93/netbsd-src
static void
ShowDvi (DviWidget dw)
{
	if (!dw->dvi.file) {
		static char Error[] = "No file selected";

		XSetFont (XtDisplay(dw), dw->dvi.normal_GC,
			  dw->dvi.default_font->fid);
		XDrawString (XtDisplay (dw), XtWindow (dw), dw->dvi.normal_GC,
			     20, 20, Error, strlen (Error));
		return;
	}

	FindPage (dw);
	
	dw->dvi.display_enable = 1;
	ParseInput (dw);
	if (dw->dvi.last_page && dw->dvi.requested_page > dw->dvi.last_page)
		dw->dvi.requested_page = dw->dvi.last_page;
}
コード例 #18
0
ファイル: construct.c プロジェクト: agottem/trigger_script
int TSDef_ConstructUnitFromFile (
                                 char*                        file,
                                 char*                        name,
                                 struct tsdef_unit*           unit,
                                 struct tsdef_def_error_list* errors
                                )
{
    int error;

    yyin = fopen(file, "rt");
    if(yyin == NULL)
        return TSDEF_ERROR_FILE_OPEN;

    yyrestart(yyin);

    error = ParseInput(name, unit, errors);

    fclose(yyin);

    return error;
}
コード例 #19
0
ファイル: myui2.c プロジェクト: jkarson/mystoreProj
void editRecord(){
  saveOption = 1;
  subjInput = (char*)malloc(31 * sizeof(char));
  bodyInput = (char*)malloc(141 * sizeof(char));
  subjPos = bodyPos = 0;
  char strRecordNum[10];
  sprintf(strRecordNum, "%d", recordNum);
  ReadMystoreFromChild("display", strRecordNum, NULL, NULL);
  ParseInput();
  strcpy(subjInput,pairs[3].value);
  strcpy(bodyInput,pairs[4].value);
  xt_par0(XT_CLEAR_SCREEN);
  xt_par2(XT_SET_ROW_COL_POS, 1, 1);
  xt_par0(XT_CH_BOLD);
  printf("Welcome to MyStore.\n");
  xt_par0(XT_CH_NORMAL);
  printf("This is the EDIT Page.\n");
  printf("Added/edited text shows up in RED.\n");
  setUpAddEditScreen();
  addEditKeyboardControl();
}
コード例 #20
0
void EventHandle::PollInput() // Grabs input from 'GetAsyncKeyState()'
{
	int i = 0;
	FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE));

	if (GetAsyncKeyState(VK_LEFT) & 0x8000) { m_vKeys.push_back(VK_LEFT); ++i; }
	if (GetAsyncKeyState(VK_RIGHT) & 0x8000) { m_vKeys.push_back(VK_RIGHT); ++i; }
	if (GetAsyncKeyState(VK_UP) & 0x8000) { m_vKeys.push_back(VK_UP); ++i; }
	if (GetAsyncKeyState(VK_DOWN) & 0x8000) { m_vKeys.push_back(VK_DOWN);  ++i; }

	if (GetAsyncKeyState('W') & 0x8000)	{ m_vKeys.push_back(0x57);  ++i; } // W Key
	if (GetAsyncKeyState('A') & 0x8000) { m_vKeys.push_back(0x41);  ++i; } // A Key
	if (GetAsyncKeyState('S') & 0x8000) { m_vKeys.push_back(0x53);  ++i; } // S Key
	if (GetAsyncKeyState('D') & 0x8000) { m_vKeys.push_back(0x44);  ++i; } // D Key

	if (GetAsyncKeyState('P') & 0x8000) { m_vKeys.push_back(0x50);  ++i; } // P Key
	if (GetAsyncKeyState('G') & 0x8000) { m_vKeys.push_back(0x47);  ++i; } // G Key
	if (GetAsyncKeyState('X') & 0x8000) { m_vKeys.push_back(0x58);  ++i; } // X Key

	if (GetAsyncKeyState('F') & 0x8000) { m_vKeys.push_back(0x46);  ++i; } // F Key

	if (GetAsyncKeyState(VK_RETURN) & 0x8000) { m_vKeys.push_back(VK_RETURN);  ++i; }

	if (GetAsyncKeyState(VK_PRIOR) & 0x8000) { m_vKeys.push_back(VK_PRIOR); ++i; }
	if (GetAsyncKeyState(VK_NEXT) & 0x8000) { m_vKeys.push_back(VK_NEXT); ++i; }

	if (GetAsyncKeyState(VK_ESCAPE) & 0x8000) { m_vKeys.push_back(VK_ESCAPE); ++i; }

	OrderInput();
	ParseInput();
	if (!i)
	{
		m_vPrevKeys.clear();
		m_vUntilPressed.clear();
		m_vUntilRepeat.clear();
	}
}
コード例 #21
0
ファイル: main.cpp プロジェクト: dciliske/projekts
void InputTask( void * pd )
{
    fd_set read_fds, error_fds;
    int index = 0, openCount = 0;
    bool inString = false, strEscape = false;
    while (1) {
        if (ws_fd > 0) {
            FD_SET( ws_fd, &read_fds );
            FD_SET( ws_fd, &error_fds );
            if (select(1, &read_fds, NULL, &error_fds, 0)) {
                if (FD_ISSET(ws_fd, &error_fds)) {
                    close(ws_fd);
                    ws_fd = -1;
                }
                if (FD_ISSET(ws_fd, &read_fds)) {
                    while (dataavail(ws_fd) && (index < INCOMING_BUF_SIZE)) {
                        read(ws_fd, IncomingBuffer + index, 1);
                        openCount += ConsumeSocket( IncomingBuffer[index], inString, strEscape );
                        index++;
                        if (openCount == 0) {
                            break;
                        }
                    }
                }
                if ((index == 0) && (openCount == 0)) {
                    IncomingBuffer[index] = '\0';
                    OSTimeDly(4);
                    ParseInput(IncomingBuffer);
                    index = 0;
                }
            }
        }
        else {
            OSSemPend( &SockReadySem, 0 );
        }
    }
}
コード例 #22
0
ファイル: state_machine.c プロジェクト: thgreiner/amy
/**
 * Implements the state machine.
 */
void StateMachine(void)
{
    char *gameend;

    State = STATE_WAITING;

    CurrentPosition = InitialPosition();
    ComputerSide = Black;

    while(State != STATE_END) {

	if(AutoSave) {
	    SaveGame(CurrentPosition, AutoSaveFileName);
	}

        switch(State) {
            case STATE_WAITING:
                if(!XBoardMode) {
                    Print(0, "%s(%d): ", 
                        CurrentPosition->turn == White ? "White":"Black", 
                        (CurrentPosition->ply/2)+1);
                }

                if(!ReadLine(InputBuffer, 1023)) {
                    State = STATE_END;
                } else {
                    struct Command *command = ParseInput(InputBuffer);
                    if(command) {
                        ExecuteCommand(command);
                        if(command->move != M_NONE) {
                            if(!ForceMode) State = STATE_CALCULATING;
                        }
                    }
                }
                break;
            case STATE_CALCULATING:
                ComputerSide = CurrentPosition->turn;
                SearchRoot(CurrentPosition);
                if(EasyMode || ForceMode) {
                    State = STATE_WAITING;
                }
                else {
                    State = STATE_PONDERING;
                }
                break;
            case STATE_PONDERING:
                switch(PermanentBrain(CurrentPosition)) {
                    case PB_NO_PB_MOVE:
                        State = STATE_WAITING;
                        break;
                    case PB_NO_PB_HIT:
                        State = ForceMode ? STATE_WAITING : STATE_CALCULATING;
                        break;
                    case PB_HIT:
                        if(EasyMode) {
                            State = STATE_WAITING;
                        }
                        break;
                }
                break;
            case STATE_ANALYZING:
		AnalysisMode(CurrentPosition);
                break;
        }

        /*
         * Check for game termination
         */

        gameend = GameEnd(CurrentPosition);
        if(gameend != NULL) {
            Print(0, "%s\n", gameend);
            if(State == STATE_ANALYZING) {
                State = STATE_WAITING;
            }
        }
    }

    FreePosition(CurrentPosition);
}
コード例 #23
0
ファイル: myui2.c プロジェクト: jkarson/mystoreProj
//type is 0 or 1,
//if 0, then its find in subject
//if 1, then its find in body
void findRecords(char* key, int type){

  calculateNumRecords();
	//can return a maximum of 100 records
	//can only return records with ids < 10000
  fi = 0; // found records index


  
  char *test;
  
  
  int ri = 1; //record index
  char ris[5]; //record index as a string
  

  while(ri <= numRecords){	
    
    
    sprintf(ris,"%d",ri);
    ris[4] = '\0';
    
    
    ReadMystoreFromChild("display", ris, NULL, NULL);
    setNumStructsNeeded();
    ParseInput();
    
    

    if(type == 0){
      test = (char *)malloc(30 * sizeof(char));
      test = pairs[3].value;
    }
    
    else if(type == 1){	
      test = (char *)malloc(140 * sizeof(char));
      test = pairs[4].value;
    }
    
    int klen = strlen(key);
    
    int tlen = strlen(test);
    
    int ti = 0; //text index
    char exerpt[klen+1];
    
    char *testSpot;
    int loop = 1;
    
    while(ti < tlen){
      
      if(test[ti] == key[0]){
	testSpot = &test[ti];
	strncpy(exerpt, testSpot, klen);
	exerpt[klen] = '\0';
	if(strcmp(exerpt, key) == 0){
	  foundRecords[fi++] = ri;
	}
      }
      ti++;
    }
    
    
    ++ri;
  }
  
  numFoundRecords = fi;
  fi = 0;
  
}
コード例 #24
0
ファイル: myui2.c プロジェクト: jkarson/mystoreProj
void displayFoundRecords(){
  xt_par2(XT_SET_ROW_COL_POS, 15, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 16, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 17, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 18, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 19, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 20, 1);
  xt_par0(XT_ERASE_LINE);
  xt_par2(XT_SET_ROW_COL_POS, 1, 1);
  printf("Records with \n");
  printf("Scroll through found records using left and right arrow keys.\n\n");
  printf("Press F3 to delete current record\n");
  printf("Press F4 to return to all records\n");
  printf("Press F5 to input a new SEARCH\n");
  printf("Press F6 to edit current record\n");

  recordNum = foundRecords[fi];

  if (numFoundRecords == 0){
    printf("\n\n\nNO MATCHING RECORDS FOUND");
    viewFoundRecordsHelper();
  }
  else{
    char strRecordNum[10];
    sprintf(strRecordNum, "%d", recordNum);
    ReadMystoreFromChild("display", strRecordNum, NULL, NULL);
    setNumStructsNeeded();
    ParseInput();
    char *date = (char*)malloc(100 * sizeof(char));
    date = pairs[2].value;
    char *subject = (char *)malloc(31 * sizeof(char));
    subject = pairs[3].value;
    char *body = (char *)malloc(141 * sizeof(char));
    body = pairs[4].value;
    xt_par2(XT_SET_ROW_COL_POS, 10, 1);
    xt_par2(XT_SET_ROW_COL_POS, 15, 1);
    xt_par0(XT_CH_BOLD);
    printf("ITEM #: ");
    xt_par0(XT_CH_NORMAL);
    printf("%d\n", recordNum);
    xt_par2(XT_SET_ROW_COL_POS, 16, 1);
    xt_par0(XT_CH_BOLD);
    printf("SUBJECT: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", subject);
    xt_par2(XT_SET_ROW_COL_POS, 17,1);
    xt_par0(XT_CH_BOLD);
    printf("BODY: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", body);
    xt_par2(XT_SET_ROW_COL_POS, 19, 1);
    xt_par0(XT_CH_BOLD);
    printf("TIME ADDED: ");
    xt_par0(XT_CH_NORMAL);
    printf("%s", date);
    viewFoundRecordsHelper();
  }
}
コード例 #25
0
ファイル: ProofTests.C プロジェクト: dawehner/root
//_____________________________________________________________________________
void ProofTests::SlaveBegin(TTree * /*tree*/)
{
   // The SlaveBegin() function is called after the Begin() function.
   // When running with PROOF SlaveBegin() is called on each slave server.
   // The tree argument is deprecated (on PROOF 0 is passed).

   TString option = GetOption();

   // Fill relevant members
   ParseInput();

   // Output histo
   fStat = new TH1I("TestStat", "Test results", 20, .5, 20.5);
   fOutput->Add(fStat);

   // We were started
   fStat->Fill(1.);

   // Depends on the test
   if (fTestType == 0) {
      // Retrieve objects from the input list and copy them to the output
      // H1
      TList *h1list = dynamic_cast<TList*>(fInput->FindObject("h1list"));
      if (h1list) {
         // Retrieve objects from the input list and copy them to the output
         TH1F *h1 = dynamic_cast<TH1F*>(h1list->FindObject("h1data"));
         if (h1) {
            TParameter<Double_t> *h1avg = dynamic_cast<TParameter<Double_t>*>(h1list->FindObject("h1avg"));
            TParameter<Double_t> *h1rms = dynamic_cast<TParameter<Double_t>*>(h1list->FindObject("h1rms"));
            if (h1avg && h1rms) {
               if (TMath::Abs(h1avg->GetVal() - h1->GetMean()) < 0.0001) {
                  if (TMath::Abs(h1rms->GetVal() - h1->GetRMS()) < 0.0001) {
                     fStat->Fill(2.);
                  }
               }
            } else {
               Info("SlaveBegin", "%d: info 'h1avg' or 'h1rms' not found!", fTestType);
            }
         } else {
            Info("SlaveBegin", "%d: input histo 'h1data' not found!", fTestType);
         }
      } else {
         Info("SlaveBegin", "%d: input list 'h1list' not found!", fTestType);
      }
      // H2
      TList *h2list = dynamic_cast<TList*>(fInput->FindObject("h2list"));
      if (h2list) {
         // Retrieve objects from the input list and copy them to the output
         TH1F *h2 = dynamic_cast<TH1F*>(h2list->FindObject("h2data"));
         if (h2) {
            TParameter<Double_t> *h2avg = dynamic_cast<TParameter<Double_t>*>(h2list->FindObject("h2avg"));
            TParameter<Double_t> *h2rms = dynamic_cast<TParameter<Double_t>*>(h2list->FindObject("h2rms"));
            if (h2avg && h2rms) {
               if (TMath::Abs(h2avg->GetVal() - h2->GetMean()) < 0.0001) {
                  if (TMath::Abs(h2rms->GetVal() - h2->GetRMS()) < 0.0001) {
                     fStat->Fill(3.);
                  }
               }
            } else {
               Info("SlaveBegin", "%d: info 'h2avg' or 'h2rms' not found!", fTestType);
            }
         } else {
            Info("SlaveBegin", "%d: input histo 'h2data' not found!", fTestType);
         }
      } else {
         Info("SlaveBegin", "%d: input list 'h2list' not found!", fTestType);
      }

      TNamed *iob = dynamic_cast<TNamed*>(fInput->FindObject("InputObject"));
      if (iob) {
         fStat->Fill(4.);
      } else {
         Info("SlaveBegin", "%d: input histo 'InputObject' not found!", fTestType);
      }
   } else if (fTestType == 1) {
      // We should find in the input list the name of a test variable which should exist
      // at this point in the gEnv table
      TNamed *nm = dynamic_cast<TNamed*>(fInput->FindObject("testenv"));
      if (nm) {
         if (gEnv->Lookup(nm->GetTitle())) fStat->Fill(2.);
      } else {
         Info("SlaveBegin", "%d: TNamed with the test env info not found!", fTestType);
      }
   } else if (fTestType == 2) {
      // We should find in the input list the list of names of test variables which should exist
      // at this point in the gEnv table
      TNamed *nm = dynamic_cast<TNamed*>(fInput->FindObject("testenv"));
      if (nm) {
         TString nms(nm->GetTitle()), nam;
         Int_t from = 0;
         while (nms.Tokenize(nam, from, ",")) {
            if (gEnv->Lookup(nam)) {
               Double_t xx = gEnv->GetValue(nam, -1.);
               if (xx > 1.) fStat->Fill(xx);
            }
         }
      } else {
         Info("SlaveBegin", "%d: TNamed with the test env info not found!", fTestType);
      }
   }
}
コード例 #26
0
ファイル: mcmain.c プロジェクト: rfinkelnburg/MetPhoMod
int main(int argc, char *argv[])
{
  Entity et;
  int error, startupflags, i;
  char *restartname, name[128];
#ifdef PARALLEL
  const ParCommand end = EXIT;
#endif
  InitVarTable();
#ifdef PARALLEL
  IsMaster();
  if (master) {
    printf("MetPhoMod   Rel. 2.2\n" SYSTEM " parallel Version - " DATE "\n\n");
#else
  printf("MetPhoMod   Rel. 2.2\n" SYSTEM " sequential Version - " DATE "\n\n");
#endif
    if (argc > 1 && (!strcmp(argv[1], "-help") || !strcmp(argv[1], "-h")))  {
      McInterface::modmanager.Init1();
      PrintHelp(argc - 2, argv + 2);
      exit (0);
    }
    if (argc > 1 && !strcmp(argv[1], "-genchem"))  {
      if (argc != 3)  goto instant_help;
      GenerateSpecialChem(argv[2]);
      exit (0);
    }
    startupflags = AnalizeOptions(&argc, argv, &restartname);
    if (argc != 2)  {
instant_help :
      printf("Usage : meteochem [-RESTART restart-file [-REOPEN]] [-noexcpt] [-syntax] \\\n"
             "                  [-nooutput] [-debug] [-sequential] inpfile\n"
             "or    : meteochem (-h | -help) [keyword]\n"
             "or    : meteochem -genchem chemfile\n");
      return (1);
    }
    McInterface::modmanager.Init1();
    if (startupflags & SYNTAX_ONLY)  {
      if (ParseInput(argv[1]))  {
        printf("Errors in Input-File\n");
        return (1);
      }
      else  {
        printf("the input-file seems to be OK!\n");
        return (0);
      }
    }
#ifdef PARALLEL
    if (startupflags & SEQUENTIAL)  {
      parallel = FALSE; master = TRUE;
      leftest = rightest = TRUE;
    }
  }
  if (master)  {
#endif
    if (ParseInput(argv[1]))  {
      fprintf(stderr, "Errors parsing Input-File. I don't start the calculation.\n");
      return (1);
    }
    plausible = TRUE;
    if (!(startupflags & NOEXCPT))  InstallFpeHandler();
    tinc = chemtinc = tincmax;
    actime = chemtime = tstart;
#ifdef PARALLEL
    if (!parallel)  printf("\n\n!!! Using sequential mode !!!\n\n");
    else
      McInterface::modmanager.CheckIfReadyForParallel();
  }
  InitializeWorkers(argv[0], startupflags & DEBUG_WORKERS);
  if (parallel && !master)  {
    if (!(startupflags & NOEXCPT))  InstallFpeHandler();
    McInterface::modmanager.Init1();
    ReadDataFromMaster();
    InitializeData();
    plausible = TRUE;
    tinc = chemtinc = tincmax;
    actime = chemtime = tstart;
  }
  if (parallel && master)  {
    printf("Sending Data to workers...\n");
    SendDataToWorkers();
    InitializeData();
  }
  if (!parallel)
#endif
    InitializeData();
  for (et = maxentity; et--; )
    if (g[et])
      CalculateLayerAverage(g[et], pstat, avg+et*nz);
    else
      memset(avg+et*nz, 0, nz*sizeof(double));
  CalcMeanHydrostaticPressure();
#ifdef PARALLEL
  if (!parallel || !master)  {
#endif
    SetAvgMountains();
    SetBoundary(maxentity);
/*    CalcAllKm();  */
#ifdef PARALLEL
  }
  if (parallel && !master)  {
    if (GetRestartName(name))  {
      if (!(ReadFullDump(name, (startupflags & REOPEN)) && actime <= tend))  {
	printf("Error : Restart-file not found\n");
	plausible = FALSE;
      }
    }
  }
  else  {
    if (parallel)
      SendRestartName((startupflags & RESTART) ? restartname : NULL);
#endif
    if (startupflags & RESTART)  {
      if (!ReadFullDump(restartname, (startupflags & REOPEN)))  {
        printf("Error : Restart-file not found\n");
        return (1);
      }
    }
    else if (startupflags & REOPEN)  {
      printf("Error: -REOPEN can only be used together with -RESTART\n");
      return (1);
    }
#ifdef PARALLEL
  }
  if (master)  {
#endif
    if (!(startupflags & NO_OUTPUT))  {
      printf("Opening output-Files...");
      if (OpenOutputFiles(argv[1], (startupflags & RESTART) && (startupflags & REOPEN)))  {
        printf("\nExecution abortet\n");
        exit (1);
      }
      CreateDomainFiles((startupflags & RESTART) && (startupflags & REOPEN));
    }
    InstallSignalHandler();
    printf("\n");
#ifdef PARALLEL
    if (parallel)  printf("Starting calculation...\n");
  }
#else  
  printf("Starting calculation...\n");
#endif
#if PARALLEL
  if (!parallel || master)  
#endif
    if (!(startupflags & NO_OUTPUT))  {
      WriteOutData(tstart, FALSE);
      WriteToDomainFiles(tstart);
    }
/*  TestChemicals("Start");  */
#if PARALLEL
  if (parallel)
    if (master)  MastersLoop(startupflags);
    else	 WorkersLoop(startupflags);
  else
#endif
    SequentialLoop(startupflags);
  printf("Closing output-Files...\n");
  if (plausible)  printf("Calculation terminated successfully\n\n");
  else  {
    if (!(startupflags & NO_OUTPUT))
      WriteOutData(actime, TRUE);
    printf("Calculation stopped because of inplausibilities!\n\n");
  }
  if (!(startupflags & NO_OUTPUT))  {
    CloseOutputFiles();
    CloseDomainFiles();
  }
#ifdef PARALLEL
  if (parallel)  {
    pvm_initsend(PvmDataRaw);
    pvm_pkint((int *)&end, 1, 1);
    SendCommand();
    pvm_exit();
  }
#endif
  return (0);
}
コード例 #27
0
ファイル: SearchBWT.c プロジェクト: Questionman/SOAP3-dp-1
int main(int argc, char** argv) {

    char c;
    unsigned int i, j, k;
    MMPool *mmPool;
    dictionary *programInput, *ini;
    char argumentText[11] = "argument:0";
    double startTime;
    double elapsedTime = 0, totalElapsedTime = 0;

    BWT *bwt;
    HSP *hsp;

    unsigned char charMap[256];

    unsigned char *convertedKey;
    unsigned int *packedKey;

    unsigned int found;
    unsigned int numberOfPattern, numberOfPatternFound;
    unsigned int saIndexLeft, saIndexRight;
    SaIndexGroupNew *saIndexGroup;
    SaIndexList *tempSaIndex1, *tempSaIndex2;
    unsigned int numberOfSaIndexGroup;
    HitList *hitList;
    unsigned int textPositionMatched, textPositionRetrieved;
    unsigned long long totalTextPositionMatched, totalTextPositionRetrieved;
    BWTSaRetrievalStatistics BWTSaRetrievalStatistics;

    FILE *logFile;
    

    init(textPositionRetrieved);    // to avoid compiler warning only
    init(textPositionMatched);        // to avoid compiler warning only

    programInput = ParseInput(argc, argv);
    ini = ParseIniFile();

    ProcessIni();
    ValidateIni();

    PrintIni();

    if (Confirmation == TRUE) {
        printf("BWT Search. Press Y to go or N to cancel. ");
        c = (char)getchar();
        while (c != 'y' && c != 'Y' && c != 'n' && c!= 'N') {
            c = (char)getchar();
        }
        if (c == 'n' || c == 'N') {
            exit(0);
        }
    }

    startTime = setStartTime();

    MMMasterInitialize(1, 0, FALSE, NULL);
    mmPool = MMPoolCreate(PoolSize);

    // Load Database
    printf("Loading Database..");
    fflush(stdout);

    bwt = BWTLoad(mmPool, BWTCodeFileName, BWTOccValueFileName, SaValueFileName, NULL, SaIndexFileName, NULL);
    HSPFillCharMap(charMap);
    hsp = HSPLoad(mmPool, PackedDNAFileName, AnnotationFileName, AmbiguityFileName, MAX_SEARCH_PATTERN_LENGTH / CHAR_PER_WORD);
    if (bwt->textLength != hsp->dnaLength) {
        fprintf(stderr, "BWT-BLAST: Database length inconsistent!\n");
        exit(1);
    }


    if (LogFileName[0] != '\0') {
        logFile = fopen64(LogFileName, "w");
        if (logFile == NULL) {
            fprintf(stderr, "Cannot open log file!\n");
            exit(1);
        }
    } else {
        logFile = NULL;
    }

    packedKey = MMPoolDispatch(mmPool, WordPackedLengthFromText(MAX_SEARCH_PATTERN_LENGTH, BIT_PER_CHAR));
    convertedKey = MMPoolDispatch(mmPool, MAX_SEARCH_PATTERN_LENGTH);

    saIndexGroup = MMUnitAllocate(MaxNumberOfHitGroups * sizeof(SaIndexGroup));
    hitList = MMUnitAllocate(MaxNumberOfTextPosition * sizeof(HitList));
    tempSaIndex1 = MMUnitAllocate(MaxNumberOfTextPosition * sizeof(SaIndexList));
    tempSaIndex2 = MMUnitAllocate(MaxNumberOfTextPosition * sizeof(SaIndexList));

    elapsedTime = getElapsedTime(startTime) - totalElapsedTime;
    printf("Elapsed time = ");
    printElapsedTime(stdout, FALSE, FALSE, TRUE, 4, elapsedTime);
    totalElapsedTime += elapsedTime;
    printf("\n");

    // Process search pattern files
    for (i=1; i<=NumberOfSearchPatternFile; i++) {

        argumentText[9] = '0' + (char)(i + 2);
        iniparser_copystring(programInput, argumentText, PatternFileName, PatternFileName, MAX_FILENAME_LEN);

        printf("Loading search pattern : %s\n", PatternFileName);
        numberOfPattern = ProcessSearchPattern();
        printf("Finished loading search pattern.\n");
        elapsedTime = getElapsedTime(startTime) - totalElapsedTime;
        printf("Elapsed time = ");
        printElapsedTime(stdout, FALSE, FALSE, TRUE, 4, elapsedTime);
        totalElapsedTime += elapsedTime;
        printf("\n");

        if (LogFileName[0] != '\0') {
            fprintf(logFile, "Searching for pattern : %s\n", PatternFileName);
        }

        if (SABinarySearch == TRUE) {

            printf("Start forward search with SA index.\n");
            if (LogFileName[0] != '\0') {
                fprintf(logFile, "Forward search with SA index.\n");
            }

            numberOfPatternFound = 0;
            totalTextPositionMatched = 0;
            totalTextPositionRetrieved = 0;
            BWTInitializeSaRetrievalStatistics(&BWTSaRetrievalStatistics);

            for (j=0; j<numberOfPattern; j++) {
                //ConvertTextToWordPacked(searchPattern + searchPatternPosition[j], packedKey, charMap, ALPHABET_SIZE, 
                //                    searchPatternPosition[j+1] - searchPatternPosition[j]);
                //found = BWTForwardSearchSaIndex(packedKey, searchPatternPosition[j+1] - searchPatternPosition[j],
                //                         bwt, hsp->packedDNA, &saIndexLeft, &saIndexRight);

                ConvertTextToCode(searchPattern + searchPatternPosition[j], convertedKey, charMap, 
                                    searchPatternPosition[j+1] - searchPatternPosition[j]);
                found = BWTSaBinarySearch(convertedKey, searchPatternPosition[j+1] - searchPatternPosition[j],
                                         bwt, hsp->packedDNA, &saIndexLeft, &saIndexRight, packedKey);

                if (found) {
                    numberOfPatternFound++;
                    textPositionMatched = saIndexRight - saIndexLeft + 1;
                    totalTextPositionMatched += textPositionMatched;

                    if (FindTextPosition) {
                        saIndexGroup->startSaIndex = saIndexLeft;
                        if (textPositionMatched <= MaxNumberOfTextPosition) {
                            saIndexGroup->numOfMatch = textPositionMatched;
                        } else {
                            saIndexGroup->numOfMatch = MaxNumberOfTextPosition;
                            printf("Max no of text positions reached! Only %u out of %u text positions retrieved.\n", MaxNumberOfTextPosition, textPositionMatched);
                        }
                        saIndexGroup->posQuery = 0;
                        saIndexGroup->info = 0;
                        textPositionRetrieved = BWTTextPosition(bwt, saIndexGroup, 1, hitList, tempSaIndex1, tempSaIndex2, &BWTSaRetrievalStatistics, FALSE);
                        totalTextPositionRetrieved += textPositionRetrieved;
                    }
                }

                if (LogFileName[0] != '\0') {
                    if (found) {
                        fprintf(logFile, "Pattern number %u found. SA Index from %u to %u.  ", 
                                j + 1, saIndexLeft, saIndexRight);
                        if (FindTextPosition) {
                            fprintf(logFile, "%u matches of %u located. ", textPositionRetrieved, textPositionMatched);
                            for (k=0; k<textPositionRetrieved; k++) {
                                fprintf(logFile, "%u ", hitList[k].posText);
                            }
                        }
                    } else {
                        fprintf(logFile, "Pattern number %u not found.", j + 1); 
                    }
                    fprintf(logFile, "\n");
                }
            }

            printf("Finished forward search with SA index.\n");
            printf("%u patterns out of %u found. %llu of %llu matches located.\n", numberOfPatternFound, numberOfPattern, totalTextPositionRetrieved, totalTextPositionMatched);
            if (FindTextPosition) {
                printf("Hits: BWT/Cached/Diag/Dup      : %u/%u/%u/%u\n", 
                              BWTSaRetrievalStatistics.bwtSaRetrieved, BWTSaRetrievalStatistics.cachedSaRetrieved, 
                              BWTSaRetrievalStatistics.saDiagonalLinked, BWTSaRetrievalStatistics.saDuplicated);
            }
            elapsedTime = getElapsedTime(startTime) - totalElapsedTime;
            printf("Elapsed time = ");
            printElapsedTime(stdout, FALSE, FALSE, TRUE, 4, elapsedTime);
            totalElapsedTime += elapsedTime;
            printf("\n");
            if (LogFileName[0] != '\0') {
                fprintf(logFile, "Finished forward search with SA index.\n");
                fprintf(logFile, "%u patterns out of %u found. %llu of %llu matches located.\n", numberOfPatternFound, numberOfPattern, totalTextPositionRetrieved, totalTextPositionMatched);
                if (FindTextPosition) {
                    fprintf(logFile, "Hits: BWT/Cached/Diag/Dup      : %u/%u/%u/%u\n", 
                                  BWTSaRetrievalStatistics.bwtSaRetrieved, BWTSaRetrievalStatistics.cachedSaRetrieved, 
                                  BWTSaRetrievalStatistics.saDiagonalLinked, BWTSaRetrievalStatistics.saDuplicated);
                }
                fprintf(logFile, "Elapsed time = ");
                printElapsedTime(logFile, FALSE, FALSE, TRUE, 4, elapsedTime);
                fprintf(logFile, "\n");
            }

        }

        if (BackwardSearch == TRUE) {

            printf("Start backward search.\n");
            if (LogFileName[0] != '\0') {
                fprintf(logFile, "Backward search.\n");
            }

            numberOfPatternFound = 0;
            totalTextPositionMatched = 0;
            totalTextPositionRetrieved = 0;
            BWTInitializeSaRetrievalStatistics(&BWTSaRetrievalStatistics);

            for (j=0; j<numberOfPattern; j++) {
                ConvertTextToCode(searchPattern + searchPatternPosition[j], convertedKey, charMap, 
                                    searchPatternPosition[j+1] - searchPatternPosition[j]);
                found = BWTBackwardSearch(convertedKey, searchPatternPosition[j+1] - searchPatternPosition[j],
                                         bwt, &saIndexLeft, &saIndexRight);
                if (found) {
                    numberOfPatternFound++;
                    textPositionMatched = saIndexRight - saIndexLeft + 1;
                    totalTextPositionMatched += textPositionMatched;

                    if (FindTextPosition) {
                        saIndexGroup->startSaIndex = saIndexLeft;
                        if (textPositionMatched <= MaxNumberOfTextPosition) {
                            saIndexGroup->numOfMatch = textPositionMatched;
                        } else {
                            saIndexGroup->numOfMatch = MaxNumberOfTextPosition;
                            printf("Max no of text positions reached! Only %u out of %u text positions retrieved.\n", MaxNumberOfTextPosition, textPositionMatched);
                        }
                        saIndexGroup->posQuery = 0;
                        saIndexGroup->info = 0;
                        textPositionRetrieved = BWTTextPosition(bwt, saIndexGroup, 1, hitList, tempSaIndex1, tempSaIndex2, &BWTSaRetrievalStatistics, FALSE);
                        totalTextPositionRetrieved += textPositionRetrieved;
                    }
                }

                if (LogFileName[0] != '\0') {
                    if (found) {
                        fprintf(logFile, "Pattern number %u found. SA Index from %u to %u. Total %u occurrences ", j + 1, saIndexLeft, saIndexRight, saIndexRight - saIndexLeft + 1);
                        if (FindTextPosition) {
                            fprintf(logFile, "%u matches of %u located. ", textPositionRetrieved, textPositionMatched);
                            for (k=0; k<textPositionRetrieved; k++) {
                                fprintf(logFile, "%u ", hitList[k].posText);
                            }
                        }
                    } else {
                        fprintf(logFile, "Pattern number %u not found.", j + 1); 
                    }
                    fprintf(logFile, "\n");
                }
            }

            printf("Finished backward search.\n");
            printf("%u patterns out of %u found. %llu of %llu matches located.\n", numberOfPatternFound, numberOfPattern, totalTextPositionRetrieved, totalTextPositionMatched);
            if (FindTextPosition) {
                printf("Hits: BWT/Cached/Diag/Dup      : %u/%u/%u/%u\n", 
                              BWTSaRetrievalStatistics.bwtSaRetrieved, BWTSaRetrievalStatistics.cachedSaRetrieved, 
                              BWTSaRetrievalStatistics.saDiagonalLinked, BWTSaRetrievalStatistics.saDuplicated);
            }
            elapsedTime = getElapsedTime(startTime) - totalElapsedTime;
            printf("Elapsed time = ");
            printElapsedTime(stdout, FALSE, FALSE, TRUE, 4, elapsedTime);
            totalElapsedTime += elapsedTime;
            printf("\n");
            if (LogFileName[0] != '\0') {
                fprintf(logFile, "Finished backward search.\n");
                fprintf(logFile, "%u patterns out of %u found. %llu of %llu matches located.\n", numberOfPatternFound, numberOfPattern, totalTextPositionRetrieved, totalTextPositionMatched);
                if (FindTextPosition) {
                    fprintf(logFile, "Hits: BWT/Cached/Diag/Dup      : %u/%u/%u/%u\n", 
                                  BWTSaRetrievalStatistics.bwtSaRetrieved, BWTSaRetrievalStatistics.cachedSaRetrieved, 
                                  BWTSaRetrievalStatistics.saDiagonalLinked, BWTSaRetrievalStatistics.saDuplicated);
                }
                fprintf(logFile, "Elapsed time = ");
                printElapsedTime(logFile, FALSE, FALSE, TRUE, 4, elapsedTime);
                fprintf(logFile, "\n");
            }

        }

        if (BackwardSearchCheck == TRUE) {

            printf("Start backward search with text.\n");
            if (LogFileName[0] != '\0') {
                fprintf(logFile, "Backward search with text.\n");
            }

            numberOfPatternFound = 0;
            totalTextPositionMatched = 0;
            totalTextPositionRetrieved = 0;
            BWTInitializeSaRetrievalStatistics(&BWTSaRetrievalStatistics);

            for (j=0; j<numberOfPattern; j++) {
                ConvertTextToCode(searchPattern + searchPatternPosition[j], convertedKey, charMap, 
                                    searchPatternPosition[j+1] - searchPatternPosition[j]);
                ConvertTextToWordPacked(searchPattern + searchPatternPosition[j], packedKey, charMap, ALPHABET_SIZE, 
                                    searchPatternPosition[j+1] - searchPatternPosition[j]);
                found = BWTBackwardSearchCheckWithText(convertedKey, packedKey, searchPatternPosition[j+1] - searchPatternPosition[j],
                                                  bwt, hsp->packedDNA, TextCheckCostFactor, MaxNumberOfTextPosition, 
                                                  hitList, &saIndexLeft, &saIndexRight);
                if (found) {
                    numberOfPatternFound++;
                    textPositionMatched = saIndexRight - saIndexLeft + 1;
                    totalTextPositionMatched += textPositionMatched;

                    // Find text position if text check not used
                    if (FindTextPosition && saIndexLeft != 0) {
                        saIndexGroup->startSaIndex = saIndexLeft;
                        if (textPositionMatched <= MaxNumberOfTextPosition) {
                            saIndexGroup->numOfMatch = textPositionMatched;
                        } else {
                            saIndexGroup->numOfMatch = MaxNumberOfTextPosition;
                            printf("Max no of text positions reached! Only %u out of %u text positions retrieved.\n", MaxNumberOfTextPosition, textPositionMatched);
                        }
                        saIndexGroup->posQuery = 0;
                        saIndexGroup->info = 0;
                        textPositionRetrieved = BWTTextPosition(bwt, saIndexGroup, 1, hitList, tempSaIndex1, tempSaIndex2, &BWTSaRetrievalStatistics, FALSE);
                        totalTextPositionRetrieved += textPositionRetrieved;
                    } else {
                        textPositionRetrieved = textPositionMatched;
                        totalTextPositionRetrieved += textPositionRetrieved;
                    }
                }

                if (LogFileName[0] != '\0') {
                    if (found) {
                        fprintf(logFile, "Pattern number %u found. ", j + 1);
                        if (FindTextPosition) {
                            fprintf(logFile, "%u matches of %u located. ", textPositionRetrieved, textPositionMatched);
                            for (k=0; k<textPositionRetrieved; k++) {
                                fprintf(logFile, "%u ", hitList[k].posText);
                            }
                        }
                    } else {
                        fprintf(logFile, "Pattern number %u not found.", j + 1); 
                    }
                    fprintf(logFile, "\n");
                }
            }

            printf("Finished backward search with text.\n");
            printf("%u patterns out of %u found. %llu of %llu matches located.\n", numberOfPatternFound, numberOfPattern, totalTextPositionRetrieved, totalTextPositionMatched);
            if (FindTextPosition) {
                printf("Hits: BWT/Cached/Diag/Dup      : %u/%u/%u/%u\n", 
                              BWTSaRetrievalStatistics.bwtSaRetrieved, BWTSaRetrievalStatistics.cachedSaRetrieved, 
                              BWTSaRetrievalStatistics.saDiagonalLinked, BWTSaRetrievalStatistics.saDuplicated);
            }
            elapsedTime = getElapsedTime(startTime) - totalElapsedTime;
            printf("Elapsed time = ");
            printElapsedTime(stdout, FALSE, FALSE, TRUE, 4, elapsedTime);
            totalElapsedTime += elapsedTime;
            printf("\n");
            if (LogFileName[0] != '\0') {
                fprintf(logFile, "Finished backward search with text.\n");
                fprintf(logFile, "%u patterns out of %u found. %llu of %llu matches located.\n", numberOfPatternFound, numberOfPattern, totalTextPositionRetrieved, totalTextPositionMatched);
                if (FindTextPosition) {
                    fprintf(logFile, "Hits: BWT/Cached/Diag/Dup      : %u/%u/%u/%u\n", 
                                  BWTSaRetrievalStatistics.bwtSaRetrieved, BWTSaRetrievalStatistics.cachedSaRetrieved, 
                                  BWTSaRetrievalStatistics.saDiagonalLinked, BWTSaRetrievalStatistics.saDuplicated);
                }
                fprintf(logFile, "Elapsed time = ");
                printElapsedTime(logFile, FALSE, FALSE, TRUE, 4, elapsedTime);
                fprintf(logFile, "\n");
            }

        }

        if (HammingDistSearch == TRUE) {

            printf("Start hamming distance %u approximate match.\n", MaxErrorAllowed);
            if (LogFileName[0] != '\0') {
                fprintf(logFile, "Hamming distance %u approximate match.\n", MaxErrorAllowed);
            }

            numberOfPatternFound = 0;
            totalTextPositionMatched = 0;
            totalTextPositionRetrieved = 0;
            BWTInitializeSaRetrievalStatistics(&BWTSaRetrievalStatistics);

            for (j=0; j<numberOfPattern; j++) {
                ConvertTextToCode(searchPattern + searchPatternPosition[j], convertedKey, charMap, 
                                    searchPatternPosition[j+1] - searchPatternPosition[j]);
                numberOfSaIndexGroup = BWTHammingDistMatchOld(convertedKey, searchPatternPosition[j+1] - searchPatternPosition[j],
                                                           bwt, MaxErrorAllowed, saIndexGroup, MaxNumberOfHitGroups, 0, 0);
                if (numberOfSaIndexGroup) {
                    numberOfPatternFound++;
                    textPositionMatched = 0;
                    for (k=0; k<numberOfSaIndexGroup; k++) {
                        textPositionMatched += saIndexGroup[k].numOfMatch;
                    }
                    if (textPositionMatched > MaxNumberOfTextPosition) {
                        textPositionMatched = 0;
                        for (k=0; k<numberOfSaIndexGroup && textPositionMatched < MaxNumberOfTextPosition; k++) {
                            textPositionMatched += saIndexGroup[k].numOfMatch;
                        }
                        numberOfSaIndexGroup = k - 1;
                        saIndexGroup[numberOfSaIndexGroup].numOfMatch -= textPositionMatched - MaxNumberOfTextPosition;
                        for (; k<numberOfSaIndexGroup; k++) {
                            textPositionMatched += saIndexGroup[k].numOfMatch;
                        }
                        printf("Max no of text positions reached! Only %u out of %u text positions retrieved.\n", MaxNumberOfTextPosition, textPositionMatched);
                    }
                    totalTextPositionMatched += textPositionMatched;

                    if (FindTextPosition) {
                        textPositionRetrieved = BWTTextPosition(bwt, saIndexGroup, numberOfSaIndexGroup, hitList, tempSaIndex1, tempSaIndex2, &BWTSaRetrievalStatistics, FALSE);
                        totalTextPositionRetrieved += textPositionRetrieved;
                    }
                }

                if (LogFileName[0] != '\0') {
                    if (numberOfSaIndexGroup) {
                        fprintf(logFile, "Pattern number %u found. %u matches", j + 1, textPositionMatched);
                        if (FindTextPosition) {
                            fprintf(logFile, "%u matches of %u located. ", textPositionRetrieved, textPositionMatched);
                            for (k=0; k<textPositionRetrieved; k++) {
                                fprintf(logFile, "%u ", hitList[k].posText);
                            }
                        }
                    } else {
                        fprintf(logFile, "Pattern number %u not found.", j + 1); 
                    }
                    fprintf(logFile, "\n");
                }
            }

            printf("Finished hamming distance search.\n");
            printf("%u patterns out of %u found. %llu of %llu matches located.\n", numberOfPatternFound, numberOfPattern, totalTextPositionRetrieved, totalTextPositionMatched);
            if (FindTextPosition) {
                printf("Hits: BWT/Cached/Diag/Dup      : %u/%u/%u/%u\n", 
                              BWTSaRetrievalStatistics.bwtSaRetrieved, BWTSaRetrievalStatistics.cachedSaRetrieved, 
                              BWTSaRetrievalStatistics.saDiagonalLinked, BWTSaRetrievalStatistics.saDuplicated);
            }
            elapsedTime = getElapsedTime(startTime) - totalElapsedTime;
            printf("Elapsed time = ");
            printElapsedTime(stdout, FALSE, FALSE, TRUE, 4, elapsedTime);
            totalElapsedTime += elapsedTime;
            printf("\n");
            if (LogFileName[0] != '\0') {
                fprintf(logFile, "Finished hamming distance search.\n");
                fprintf(logFile, "%u patterns out of %u found. %llu of %llu matches located.\n", numberOfPatternFound, numberOfPattern, totalTextPositionRetrieved, totalTextPositionMatched);
                if (FindTextPosition) {
                    fprintf(logFile, "Hits: BWT/Cached/Diag/Dup      : %u/%u/%u/%u\n", 
                                  BWTSaRetrievalStatistics.bwtSaRetrieved, BWTSaRetrievalStatistics.cachedSaRetrieved, 
                                  BWTSaRetrievalStatistics.saDiagonalLinked, BWTSaRetrievalStatistics.saDuplicated);
                }
                fprintf(logFile, "Elapsed time = ");
                printElapsedTime(logFile, FALSE, FALSE, TRUE, 4, elapsedTime);
                fprintf(logFile, "\n");
            }

        }

        if (EditDistSearch == TRUE) {

            printf("Start edit distance %u approximate match.\n", MaxErrorAllowed);
            if (LogFileName[0] != '\0') {
                fprintf(logFile, "Edit distance %u approximate match.\n", MaxErrorAllowed);
            }

            numberOfPatternFound = 0;
            totalTextPositionMatched = 0;
            totalTextPositionRetrieved = 0;
            BWTInitializeSaRetrievalStatistics(&BWTSaRetrievalStatistics);

            for (j=0; j<numberOfPattern; j++) {
                ConvertTextToCode(searchPattern + searchPatternPosition[j], convertedKey, charMap, 
                                    searchPatternPosition[j+1] - searchPatternPosition[j]);
                numberOfSaIndexGroup = BWTEditDistMatchOld(convertedKey, searchPatternPosition[j+1] - searchPatternPosition[j],
                                                        bwt, MaxErrorAllowed, (SaIndexGroupWithLengthError*)saIndexGroup, MaxNumberOfHitGroups);
                if (numberOfSaIndexGroup > MaxNumberOfHitGroups) {
                    fprintf(stderr, "numberOfSaIndexGroup > MaxNumberOfHitGroups!\n");
                }
                if (numberOfSaIndexGroup) {
                    numberOfPatternFound++;
                    textPositionMatched = 0;
                    for (k=0; k<numberOfSaIndexGroup; k++) {
                        textPositionMatched += saIndexGroup[k].numOfMatch;
                    }
                    if (textPositionMatched > MaxNumberOfTextPosition) {
                        textPositionMatched = 0;
                        for (k=0; k<numberOfSaIndexGroup && textPositionMatched < MaxNumberOfTextPosition; k++) {
                            textPositionMatched += saIndexGroup[k].numOfMatch;
                        }
                        numberOfSaIndexGroup = k - 1;
                        saIndexGroup[numberOfSaIndexGroup].numOfMatch -= textPositionMatched - MaxNumberOfTextPosition;
                        for (; k<numberOfSaIndexGroup; k++) {
                            textPositionMatched += saIndexGroup[k].numOfMatch;
                        }
                        printf("Max no of text positions reached! Only %u out of %u text positions retrieved.\n", MaxNumberOfTextPosition, textPositionMatched);
                    }
                    totalTextPositionMatched += textPositionMatched;

                    if (FindTextPosition) {
                        textPositionRetrieved = BWTTextPosition(bwt, saIndexGroup, numberOfSaIndexGroup, hitList, tempSaIndex1, tempSaIndex2, &BWTSaRetrievalStatistics, FALSE);
                        totalTextPositionRetrieved += textPositionRetrieved;
                    }
                }

                if (LogFileName[0] != '\0') {
                    if (numberOfSaIndexGroup) {
                        fprintf(logFile, "Pattern number %u found. %u matches. ", j + 1, textPositionMatched);
                        if (FindTextPosition) {
                            fprintf(logFile, "%u matches of %u located. ", textPositionRetrieved, textPositionMatched);
                            for (k=0; k<textPositionRetrieved; k++) {
                                fprintf(logFile, "%u ", hitList[k].posText);
                            }
                        }
                    } else {
                        fprintf(logFile, "Pattern number %u not found.", j + 1); 
                    }
                    fprintf(logFile, "\n");
                }
            }

            printf("Finished edit distance search.\n");
            printf("%u patterns out of %u found. %llu of %llu matches located.\n", numberOfPatternFound, numberOfPattern, totalTextPositionRetrieved, totalTextPositionMatched);
            if (FindTextPosition) {
                printf("Hits: BWT/Cached/Diag/Dup      : %u/%u/%u/%u\n", 
                              BWTSaRetrievalStatistics.bwtSaRetrieved, BWTSaRetrievalStatistics.cachedSaRetrieved, 
                              BWTSaRetrievalStatistics.saDiagonalLinked, BWTSaRetrievalStatistics.saDuplicated);
            }
            elapsedTime = getElapsedTime(startTime) - totalElapsedTime;
            printf("Elapsed time = ");
            printElapsedTime(stdout, FALSE, FALSE, TRUE, 4, elapsedTime);
            totalElapsedTime += elapsedTime;
            printf("\n");
            if (LogFileName[0] != '\0') {
                fprintf(logFile, "Finished edit distance search.\n");
                fprintf(logFile, "%u patterns out of %u found. %llu of %llu matches located.\n", numberOfPatternFound, numberOfPattern, totalTextPositionRetrieved, totalTextPositionMatched);
                if (FindTextPosition) {
                    fprintf(logFile, "Hits: BWT/Cached/Diag/Dup      : %u/%u/%u/%u\n", 
                                  BWTSaRetrievalStatistics.bwtSaRetrieved, BWTSaRetrievalStatistics.cachedSaRetrieved, 
                                  BWTSaRetrievalStatistics.saDiagonalLinked, BWTSaRetrievalStatistics.saDuplicated);
                }
                fprintf(logFile, "Elapsed time = ");
                printElapsedTime(logFile, FALSE, FALSE, TRUE, 4, elapsedTime);
                fprintf(logFile, "\n");
            }

        }

    }

    MMPoolReturn(mmPool, packedKey, WordPackedLengthFromText(MAX_SEARCH_PATTERN_LENGTH, BIT_PER_CHAR));
    MMPoolReturn(mmPool, convertedKey, MAX_SEARCH_PATTERN_LENGTH);

    HSPFree(mmPool, hsp, MAX_SEARCH_PATTERN_LENGTH / CHAR_PER_WORD);
    BWTFree(mmPool, bwt);

    if (searchPattern != NULL) {
        MMUnitFree(searchPattern, searchPatternAllocated);
    }
    if (searchPatternPosition != NULL) {
        MMUnitFree(searchPatternPosition, searchPatternPositionAllocated);
    }
    MMUnitFree(saIndexGroup, MaxNumberOfHitGroups * sizeof(unsigned int));
    MMUnitFree(hitList, MaxNumberOfTextPosition * sizeof(unsigned int));

    MMPoolFree(mmPool);

    iniparser_freedict(programInput);
    iniparser_freedict(ini);

    return 0;

}
コード例 #28
0
ファイル: search.c プロジェクト: thgreiner/amy
/*
 * Check if search should be terminated
 *
 * Here we also handle the case that we are in Permanent Brain and have to
 * check for user input.
 *
 */
static int TerminateSearch(struct SearchData *sd) {
    if ((Nodes+QNodes) > ChkNodes) {
        unsigned int now = GetTime();

        ChkNodes = Nodes+QNodes+NodesPerCheck;
        if (AbortSearch) return TRUE;

        CurTime = now;
        if (CurTime > (StartTime+ONE_SECOND)) PrintOK = TRUE;

        if (InputReady()) {
            char buffer[64];
            struct Command *theCommand;

            ReadLine(buffer, 64);

            /*
             * the '.' command can only be handled here
             */

            if (buffer[0] == '.') {
                PrintNoLog(0,
                           "stat01: %d %ld %d %d %d\n",
                           (CurTime - StartTime),
                           Nodes + QNodes,
                           sd->depth,
                           sd->nrootmoves - sd->movenum -1,
                           sd->nrootmoves);
            }

            theCommand = ParseInput(buffer);

            if (theCommand) {
                if (SearchMode == Pondering && theCommand->move != M_NONE) {
                    if (theCommand->move == PBActMove) {
                        PBHit = TRUE;
                        SearchMode = Searching;
                        Print(1, "OK!\n");
                        WallTimeStart = now;

                        if (CurTime >= HardLimit) return TRUE;
                        if (DoneAtRoot) return TRUE;

                        return FALSE;
                    } else {
                        PBHit = FALSE;
                        PBAltMove = theCommand->move;
                        return TRUE;
                    }
                }

                if (SearchMode == Puzzling && theCommand->move != M_NONE) {
                    PBAltMove = theCommand->move;
                    return TRUE;
                }

                if (SearchMode == Analyzing && theCommand->move != M_NONE) {
                    ExecuteCommand(theCommand);
                    return TRUE;
                }

                if (theCommand->allowed_during_search) {
                    ExecuteCommand(theCommand);

                    if (theCommand->interrupts_search) {
                        SearchMode = Interrupted;
                        return TRUE;
                    }
                }
            }
        }

        if (SearchMode == Searching) {
            if (CurTime >= HardLimit) return TRUE;
        }
    }
    return FALSE;
}
コード例 #29
0
ファイル: console.cpp プロジェクト: svkaiser/TurokEX
bool kexConsole::ProcessInput(const event_t *ev) {
    if(ev->type == ev_mousedown || ev->type == ev_mouseup ||
        ev->type == ev_mouse) {
            return false;
    }

    if(ev->type == ev_mousewheel && state == CON_STATE_DOWN) {
        switch(ev->data1) {
            case KM_BUTTON_SCROLL_UP:
                LineScroll(1);
                break;
            case KM_BUTTON_SCROLL_DOWN:
                LineScroll(0);
                break;
        }

        return true;
    }

    CheckShift(ev);
    CheckStickyKeys(ev);

    int c = ev->data1;

    switch(state) {
        case CON_STATE_DOWN:
            if(ev->type == ev_keydown) {
                switch(c) {
                    case KKEY_BACKQUOTE:
                        state = CON_STATE_UP;
                        inputSystem->MouseCenter();
                        return true;
                    case KKEY_RETURN:
                        ParseInput();
                        return true;
                    case KKEY_UP:
                        GetHistory(false);
                        return true;
                    case KKEY_DOWN:
                        GetHistory(true);
                        return true;
                    case KKEY_TAB:
                        cvarManager.AutoComplete(typeStr);
                        command.AutoComplete(typeStr);
                        return true;
                    default:
                        ParseKey(c);
                        return true;
                }

                return false;
            }
            break;
        case CON_STATE_UP:
            if(ev->type == ev_keydown) {
                switch(c) {
                    case KKEY_BACKQUOTE:
                        state = CON_STATE_DOWN;
                        return true;
                    default:
                        break;
                }

                return false;
            }
            break;
        default:
            return false;
    }

    return false;
}
コード例 #30
0
ファイル: vspaero.C プロジェクト: hmxa91/Urban-UAV
int main(int argc, char **argv)
{

    // Grab the file name
    
    FileName = argv[argc-1];

    // Parse the input

    ParseInput(argc,argv);

    // Output a header

    printf("VSPAERO v.2.1 --- 3/10/2015 \n");
    printf("\n\n\n\n");
    
#ifdef VSPAERO_OPENMP
    printf("Initializing OPENMP for %d threads \n",NumberOfThreads_);
    
    omp_set_num_threads(NumberOfThreads_);
    
    NumberOfThreads_ = omp_get_max_threads();

    printf("NumberOfThreads_: %d \n",NumberOfThreads_);
#else
    NumberOfThreads_ = 1;
    printf("Single threaded build.\n");
#endif
                    
    // Load in the case file

    LoadCaseFile();
    
    // Load in the VSP degenerate geometry file
    
    VSP_VLM().ReadFile(FileName);
    
    // Command line arguments over-ride any inputs in the case file
    
    if ( SetFreeStream_ ) {
     
       Mach_ = Set_Mach_;
       AoA_  = Set_AoA_;
       Beta_ = Set_Beta_;
       
       VSP_VLM().Mach() = Mach_;
       VSP_VLM().AngleOfAttack() = AoA_ * TORAD;
       VSP_VLM().AngleOfBeta() = Beta_ * TORAD;       
       
    }
   
    // Solve
    
    VSP_VLM().Setup();
    
    // Symmetry options
    
    if ( DoSymmetry_ == SYM_X ) VSP_VLM().DoSymmetryPlaneSolve(SYM_X);
    if ( DoSymmetry_ == SYM_Y ) VSP_VLM().DoSymmetryPlaneSolve(SYM_Y);
    if ( DoSymmetry_ == SYM_Z ) VSP_VLM().DoSymmetryPlaneSolve(SYM_Z);
    
    // Force farfield distance for wake adaption
    
    if ( SetFarDist_ ) VSP_VLM().SetFarFieldDist(FarDist_);
    
    // Set number of farfield wake nodes
    
    if ( NumberOfWakeNodes_ > 0 ) VSP_VLM().SetNumberOfWakeTrailingNodes(NumberOfWakeNodes_);
     
    // Geometry dump, no solver
    
    if ( DumpGeom_ ) VSP_VLM().DumpGeom() = 1;
    
    // Force no wakes for some number of iterations
    
    if ( NoWakeIteration_ > 0 ) VSP_VLM().NoWakeIteration() = NoWakeIteration_;
    
    // Use force averaging
    
    if ( ForceAveragingIter_ > 0 ) {
       
       VSP_VLM().ForceType() = FORCE_AVERAGE;
       
       VSP_VLM().AveragingIteration() = ForceAveragingIter_;
       
    }
        
    if ( !StabControlRun_ ) {
 
       VSP_VLM().RotationalRate_p() = 0.;
       VSP_VLM().RotationalRate_q() = 0.;
       VSP_VLM().RotationalRate_r() = 0.;
       
       if ( SaveRestartFile_ ) VSP_VLM().SaveRestartFile() = 1;
   
       if ( DoRestartRun_    ) VSP_VLM().DoRestart() = 1;
               
       VSP_VLM().Solve();

       VSP_VLM().WriteOutAerothermalDatabaseFiles();
       
    }
    
    else {
     
       StabilityAndControlSolve();
       
    }

    printf("Done!\n");
}