示例#1
0
/*---------- function definitions ---------- */
int main(int argc,char *argv[]) 
{
  LALStatus status = blank_status;	/* initialize status */

  vrbflg = 1;		/* verbose error-messages */

  /* set LAL error-handler */
  lal_errhandler = LAL_ERR_EXIT;	/* exit with returned status-code on error */

  /* register all user-variables */
  LAL_CALL (InitUserVars(&status, &CommandLineArgs), &status);	  

  /* read cmdline & cfgfile  */	
  BOOLEAN should_exit = 0;
  XLAL_CHECK_MAIN (XLALUserVarReadAllInput(&should_exit, argc, argv, lalAppsVCSInfoList) == XLAL_SUCCESS, XLAL_EFUNC);
  if (should_exit)
    return EXIT_FAILURE;
  LAL_CALL ( CheckUserInput (&status, &CommandLineArgs), &status);

  LAL_CALL ( Initialize (&status, &CommandLineArgs), &status);

  /*---------- central function: compute F-statistic ---------- */
  LAL_CALL ( ComputeF(&status, CommandLineArgs), &status); 

  
  /* Free remaining memory */
  LAL_CALL ( LALSDestroyVector(&status, &(amc.a) ), &status);
  LAL_CALL ( LALSDestroyVector(&status, &(amc.b) ), &status);
  XLALDestroyUserVars();

  LALCheckMemoryLeaks();

  return 0;

} /* main() */
示例#2
0
/*
 *  DecryptDES: Decrypt a block using DES. Set verbose for debugging info.
 *  (This loop does both loops on the "DES Decryption" page of the flowchart.)
 */
void DecryptDES(bool key[56], bool outBlk[64], bool inBlk[64], int verbose) {
  int i,round;
  bool R[32], L[32], fout[32];
  bool roundKey[56];

  EnableDumpBin = verbose;                      /* set debugging on/off flag */
  DumpBin("input(left)", inBlk+32, 32);
  DumpBin("input(right)", inBlk, 32);
  DumpBin("raw key(left )", key+28, 28);
  DumpBin("raw key(right)", key, 28);

  /* Compute the first roundkey by performing PC1 */
  ComputeRoundKey(roundKey, key);

  DumpBin("roundKey(L)", roundKey+28, 28);
  DumpBin("roundKey(R)", roundKey, 28);

  /* Compute the initial permutation and divide the result into L and R */
  ComputeIP(L,R,inBlk);

  DumpBin("after IP(L)", L, 32);
  DumpBin("after IP(R)", R, 32);

  for (round = 0; round < 16; round++) {
    if (verbose)
      printf("-------------- BEGIN DECRYPT ROUND %d -------------\n", round);
    DumpBin("round start(L)", L, 32);
    DumpBin("round start(R)", R, 32);

    /* Compute f(R, roundKey) and exclusive-OR onto the value in L */
    ComputeF(fout, R, roundKey);
    DumpBin("f(R,key)", fout, 32);
    for (i = 0; i < 32; i++)
      L[i] ^= fout[i];
    DumpBin("L^f(R,key)", L, 32);

    Exchange_L_and_R(L,R);

    /* Rotate roundKey halves right once or twice (depending on round) */
    DumpBin("roundKey(L)", roundKey+28, 28);       /* show keys before shift */
    DumpBin("roundKey(R)", roundKey, 28);
    RotateRoundKeyRight(roundKey);
    if (round != 0 && round != 7 && round != 14 && round != 15)
      RotateRoundKeyRight(roundKey);

    DumpBin("round end(L)", L, 32);
    DumpBin("round end(R)", R, 32);
    if (verbose)
      printf("--------------- END ROUND %d --------------\n", round);
  }

  Exchange_L_and_R(L,R);

  /* Combine L and R then compute the final permutation */
  ComputeFP(outBlk,L,R);
  DumpBin("FP out( left)", outBlk+32, 32);
  DumpBin("FP out(right)", outBlk, 32);
}
示例#3
0
void AddOpen(PathFinder* pf, int x, int y, Node* parent)
{
    if (x < 0 || x >= pf->map->width)
        return;
    if (y < 0 || y >= pf->map->height)
        return;

    // Ignore if the node isn't walkable
    if (GetTile(pf->map, x, y) == Wall)
        return;

    // Ignore if the node has already been checked before.
    if (pf->nodeMap[x][y].open == OnClosedList)
        return;

    if (pf->nodeMap[x][y].open == NoList)
    {
        pf->nodeMap[x][y].parent = parent;

        pf->nodeMap[x][y].g = ComputeG(pf, x, y, parent);
        pf->nodeMap[x][y].h = ComputeH(pf, x, y);
        pf->nodeMap[x][y].f = ComputeF(pf, x, y);

        pf->nodeMap[x][y].open = OnOpenList;
        QueueAdd(pf->openList, &pf->nodeMap[x][y]);
    }
    else if (pf->nodeMap[x][y].open == OnOpenList)
    {
        int g = ComputeG(pf, x, y, parent);

        // If this path we're currently searching is better, use it instead
        if (pf->nodeMap[x][y].g > g)
        {
            pf->nodeMap[x][y].parent = parent;

            pf->nodeMap[x][y].g = ComputeG(pf, x, y, parent);
            pf->nodeMap[x][y].h = ComputeH(pf, x, y);
            pf->nodeMap[x][y].f = ComputeF(pf, x, y);

            int index = QueueSearch(pf->openList, &pf->nodeMap[x][y]);
            PercolateUp(pf->openList, index, &pf->nodeMap[x][y]);
        }
    }
}
示例#4
0
void Mainloop() {	
	long closedset_sz = 0;
	long openset_sz   = 0;
	
	//long start_time = clock();
	time_t time_start,time_end;
	time(&time_start);

	Tree tree= TREE_INITIALIZER(Node_compare);
	
	_Node p0 = {0};
	p0.uXYZ.lXYZ[0] = 0;
	p0.uXYZ.lXYZ[1] = 0;
	ComputeF(&p0);

	_Node* temp = Node_new(&p0);
	temp->uXYZ.lXYZ[0] = 0;
	temp->uXYZ.lXYZ[1] = 0;

	_Node* p = Node_new(temp);
	TREE_INSERT(&tree, _Node, linkage, p);
	HeapInsert(p);
	openset_sz++;

	while(true) {
		_Node* p = HeapRemove();
		p->expended = true;
		closedset_sz++;
		openset_sz--;

		if (p->h == 0) 	{
			printf("\nThe MLCS is:\n");
			int l = CommonSeq(p);
			printf("\n\n|MLCS|=%d\n", l);
			break;
		}

		for(int i=0; i<ABC_len; i++) { 
			 int j=0;

			 if (NUMBYTE == 1) {
				 while (j<MAXSTR) {
					 temp->uXYZ.cXYZ[j] = cur_T[j][p->uXYZ.cXYZ[j]+1][i];

					 if  (temp->uXYZ.cXYZ[j]==str_lngth[j]+1)
						 break;
					 j++; 
				 }
			 } else {
				 while (j<MAXSTR) {
					 temp->uXYZ.sXYZ[j] = cur_T[j][p->uXYZ.sXYZ[j]+1][i];

					 if  (temp->uXYZ.sXYZ[j]==str_lngth[j]+1)
						 break;
					 j++; 
				 }
			 }

			 if (j < MAXSTR)
				 continue;

			_Node *q = TREE_FIND(&tree, _Node, linkage, temp);

			if (q) { //node is already in tree
				if (!q->expended && (q->fg & 0xffff) < (p->fg & 0xffff)+1) {
					q->parent = p;
					q->fg = ((q->h+(p->fg & 0xffff)+1) << 16) | ((p->fg & 0xffff)+1);
				}
			} else {
				q = Node_new(temp);
				q->parent = p;
				q->fg = p->fg+1;
				ComputeF(q);

				TREE_INSERT(&tree, _Node, linkage, q);
				HeapInsert(q);
				openset_sz++;
			}
		}

	}

	printf("|closedset|=%d\n|openset|=%d\n\n", closedset_sz, openset_sz+1);

	time(&time_end);
	double elapsedTime = difftime(time_end,time_start);

	printf("The time is %6.2f seconds\n",elapsedTime);			
}