Ejemplo n.º 1
0
int main(void)
{
   int a[SIZE]; // create array a

   // create data
   for (size_t i = 0; i < SIZE; ++i)
   {
      a[i] = 2 * i;
   }

   printf("%s", "Enter a number between 0 and 28: ");
   int key; // value to locate in array a
   scanf_s("%d", &key);

   printHeader();

   // Search for key in array a
   const size_t result = binarySearch(a, key, 0, SIZE - 1);

   // display results
   if (result != (size_t)-1)
   {
      printf("\n%d found at index %d\n", key, result);
   }
   else
   {
      printf("\n%d not found\n", key);
   }

   return 0;
}
void TextTestResult::print (std::ostream &stream)
{
	printHeader (stream);
	printErrors (stream);
	printFailures (stream);

}
Ejemplo n.º 3
0
void myLog::openLog(const string& fileName, int mode)
{
   if (logLevel < QUIET_MODE)
   {
      open(fileName.c_str(),mode);
      
      // fail() returns a null zero when operation fails   
      // rc = (*this).fail();
    
      if ( fail() == 0 )
      {
         logName = fileName;
         printHeader(0);         // insert start time into top of log file
      }
      else
      {
         cout << "ERROR: Log file " << fileName.c_str() 
              << " could not be opened for write access." << endl;
         logLevel = QUIET_MODE;
      }
   }
   else
   {
      cout << "Logging disabled (QUIET_MODE set)" << endl;
   }
}
Ejemplo n.º 4
0
void StatTool::printTabular(StatManager * sm)
{
    if (ST_WithHeader) {
        printHeader();
    }
    std::cout<< sm->getGid()<<ST_Separator;
    std::cout<< sm->getConcensus()<<ST_Separator;
    std::cout<< sm->getRpeatCount()<< ST_Separator;
    std::cout<< sm->meanRepeatL()<<ST_Separator;
    std::cout<< sm->getSpacerCount()<<ST_Separator;
    if (!sm->getSpLenVec().empty()) {
        std::cout<< sm->meanSpacerL()<<ST_Separator;
    } else {
        std::cout<<0<<ST_Separator;
    }
    if (sm->getSpCovVec().empty()) {
        std::cout<<0<<ST_Separator;
    } else {
        std::cout<< sm->meanSpacerC()<<ST_Separator;
    }
    std::cout<< sm->getFlankerCount()<<ST_Separator;
    if (sm->getFlLenVec().empty()) {
        std::cout<<0<<ST_Separator;
    } else {
        std::cout<< sm->meanFlankerL()<<ST_Separator;
    }
    std::cout<<sm->getReadCount()<<std::endl;
}
Ejemplo n.º 5
0
void GerberGenerator::generate() {
  mOutput.clear();
  printHeader();
  printApertureList();
  printContent();
  printFooter();
}
Ejemplo n.º 6
0
int menu0()
{
    char input[32];       // A simple buffer to store whatever the user types in the menu
    int optionSelected = -1;

     // Display the menu to select the region
    while(optionSelected != EXIT) // This condition makes the menu repeat itself until a valid input is entered
    {
        system("cls"); // clears the screen
        printHeader();
        printf("Start patch to RU version\n");

        // Converts the read string to int
        optionSelected = 1;
        // This variable also tells the program later which one of the "moddedBytes" the program should use when replacing the bytes

        if (optionSelected == EXIT)
        {
            break;
        }

         // If the user entered an invalid option, displays a error message
        if(optionSelected < 1 || optionSelected > 2)
        {
            printf("\nInvalid option!\n\n");
            system("PAUSE");
        }
        else
        {
            break;
        }
    }

    return optionSelected;
}
Ejemplo n.º 7
0
void Spice::saveFile(string filename, Circuit& netList){
	ofstream file;
	file.open(filename.c_str()); // Write
	if (!file)
        throw AstranError("Could not save file: " + filename);

	printHeader (file, "* ", "");
	
	map<string, CellNetlst>::iterator cells_it;
	for ( cells_it = netList.getCellNetlsts()->begin(); cells_it != netList.getCellNetlsts()->end(); cells_it++ ){
		file << ".SUBCKT " <<  cells_it->first;
		for ( vector<int>::iterator inouts_it=cells_it->second.getInouts().begin(); inouts_it != cells_it->second.getInouts().end(); inouts_it++ )
			file << " " << cells_it->second.getNetName(*inouts_it);
		file << endl;
		for(map<string,Inst>::iterator tmp=cells_it->second.getInstances().begin(); tmp!=cells_it->second.getInstances().end(); ++tmp){
			file << tmp->first << " ";
			for(vector<int>::iterator tmp2=tmp->second.ports.begin(); tmp2!=tmp->second.ports.end(); ++tmp2)
				file << cells_it->second.getNetName(*tmp2) << " ";
			file << tmp->second.subCircuit << endl;
		}		
		for(int x=0; x<cells_it->second.size(); x++){
			file << cells_it->second.getTrans(x).name << " " << 
			cells_it->second.getNetName(cells_it->second.getTrans(x).drain) << " " << 
			cells_it->second.getNetName(cells_it->second.getTrans(x).gate) << " " << 
			cells_it->second.getNetName(cells_it->second.getTrans(x).source) << " ";
			if(cells_it->second.getTrans(x).type==PMOS) 
				file << netList.getVddNet() << " PMOS";
			else
				file << netList.getGndNet() << " NMOS";
			file << " L=" << cells_it->second.getTrans(x).length << "U W=" << cells_it->second.getTrans(x).width << "U"<< endl;			
		}
		file << ".ENDS " << cells_it->first << endl << endl;
	}
}
Ejemplo n.º 8
0
/** Constructor */
IcpdFrm::IcpdFrm( wxWindow* parent ):ICPD_frm( parent ){
	wxLog::SetActiveTarget( new wxLogTextCtrl(wx_log));

    new Redirector( wx_log, cout, false);
    new Redirector( wx_log, cerr, true);

	printHeader(cout, "", "");

	string astran_cfg;
    astran_cfg = "astran.cfg";

    wxString astran_path;
    ::wxGetEnv(wxT("ASTRAN_PATH"), &astran_path);

	if (wxDirExists(astran_path)) {
		astran_cfg = string(wxString(astran_path).mb_str()) + "/astran.cfg";

        ifstream afile(astran_cfg.c_str());
        if(afile) {
			executeCommand(string("read \"" + astran_cfg + "\""));
        }
	}

    wxabout = new WxAbout(this);
    wxrules = new WxRules(this);
    wxautocell = new WxAutoCell(this);
    wxcircuit = new WxCircuit(this);
    wxfp = new WxFP(this);
    wxpreferences = new WxPreferences(this);
    refresh();
}
Ejemplo n.º 9
0
// main function
int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
    // warnings
    if (argc != 4)
    {
        usage(argv);
		return 0;
    }

    // create modified RNA index
	int qualThreshold, coverageThreshold;
	qualThreshold = atoi(argv[2]);
	coverageThreshold = atoi(argv[3]);
    // read lines
    printHeader();
    if (strcmp(argv[1],"-") == 0)
    {
		cerr << "Reading from stdin" << endl;
        readStream(qualThreshold, coverageThreshold);
    }
    else
    {
        const char* filename = argv[1];
		cerr << "Reading from: " << filename << endl;
        readFile(filename, qualThreshold, coverageThreshold);
    }
    return 0;
}
Ejemplo n.º 10
0
int ApiGen::genContextImpl(const std::string &filename, SideType side)
{
    FILE *fp = fopen(filename.c_str(), "wt");
    if (fp == NULL) {
        perror(filename.c_str());
        return -1;
    }
    printHeader(fp);

    std::string classname = m_basename + "_" + sideString(side) + "_context_t";
    size_t n = size();
    fprintf(fp, "\n\n#include <string.h>\n");
    fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(side));
    fprintf(fp, "#include <stdio.h>\n\n");

    // init function;
    fprintf(fp, "int %s::initDispatchByName(void *(*getProc)(const char *, void *userData), void *userData)\n{\n", classname.c_str());
    for (size_t i = 0; i < n; i++) {
        EntryPoint *e = &at(i);
        fprintf(fp, "\t%s = (%s_%s_proc_t) getProc(\"%s\", userData);\n",
                e->name().c_str(),
                e->name().c_str(),
                sideString(side),
                e->name().c_str());
    }
    fprintf(fp, "\treturn 0;\n");
    fprintf(fp, "}\n\n");
    fclose(fp);
    return 0;
}
Ejemplo n.º 11
0
int ApiGen::genDecoderHeader(const std::string &filename)
{
    FILE *fp = fopen(filename.c_str(), "wt");
    if (fp == NULL) {
        perror(filename.c_str());
        return -1;
    }

    printHeader(fp);
    std::string classname = m_basename + "_decoder_context_t";

    fprintf(fp, "\n#ifndef GUARD_%s\n", classname.c_str());
    fprintf(fp, "#define GUARD_%s\n\n", classname.c_str());

    fprintf(fp, "#include \"IOStream.h\" \n");
    fprintf(fp, "#include \"%s_%s_context.h\"\n\n\n", m_basename.c_str(), sideString(SERVER_SIDE));

    for (size_t i = 0; i < m_decoderHeaders.size(); i++) {
        fprintf(fp, "#include %s\n", m_decoderHeaders[i].c_str());
    }
    fprintf(fp, "\n");

    fprintf(fp, "struct %s : public %s_%s_context_t {\n\n",
            classname.c_str(), m_basename.c_str(), sideString(SERVER_SIDE));
    fprintf(fp, "\tsize_t decode(void *buf, size_t bufsize, IOStream *stream);\n");
    fprintf(fp, "\n};\n\n");
    fprintf(fp, "#endif  // GUARD_%s\n", classname.c_str());

    fclose(fp);
    return 0;
}
Ejemplo n.º 12
0
void MemoryDebugger::doLookForValue(const s2e::plugins::ExecutionTraceItemHeader &hdr,
                                    const s2e::plugins::ExecutionTraceMemory &item)
{
  /*  if (!(item.flags & EXECTRACE_MEM_WRITE)) {
    if ((m_valueToFind && (item.value != m_valueToFind))) {
        return;
    }
}*/

    printHeader(hdr);
    m_os << " pc=0x" << std::hex << item.pc <<
            " addr=0x" << item.address <<
            " val=0x" << item.value <<
            " size=" << std::dec << (unsigned)item.size <<
            " iswrite=" << (item.flags & EXECTRACE_MEM_WRITE);

    ModuleCacheState *mcs = static_cast<ModuleCacheState*>(m_events->getState(m_cache, &ModuleCacheState::factory));
    const ModuleInstance *mi = mcs->getInstance(hdr.pid, item.pc);
    std::string dbg;
    if (m_library->print(mi, item.pc, dbg, true, true, true)) {
        m_os << " - " << dbg;
    }

     m_os << std::endl;

}
Ejemplo n.º 13
0
void IndexFrontEnd::doSearch(){
  
  int docIdsFound;
  set<EvidenceInfo *, EvidenceMostImportant > foundEvidenceSet;
  map<std::string, int> foundWords;
  if (mSearchType == WORDS){

    getIndexSearcher().findMatchingTerms(mIndexSearcher.getQuery(), foundWords);
    printFoundWords(foundWords);
    
  } else {

    
    docIdsFound = getIndexSearcher().searchDocuments();
    printHeader(docIdsFound);
    
    int foundEvidences = getIndexSearcher().retrieveEvidences(foundEvidenceSet, mFrom, mAmount);
    
    set<EvidenceInfo *>::iterator iter;
    for (iter = foundEvidenceSet.begin(); iter != foundEvidenceSet.end(); iter++){
      
      printEvidenceInfo(**iter);
    }
    printNavigation(foundEvidences); 
    for (iter = foundEvidenceSet.begin(); iter != foundEvidenceSet.end(); iter++){

      delete *iter;
      //   *iter = 0;
    }
  }

}
Ejemplo n.º 14
0
int main(void) {
	int arr[SIZE];
	int element;
	int searchKey;
	int count;

	for (count = 0; count < SIZE; count++) {
		arr[count] = 2 * count;
	}

	printf("Enter a number between 0 and 28: \n");
	scanf("%d", &searchKey);

	printHeader();

	element = binearSearch(arr, searchKey, 0, SIZE - 1);

	if (element != -1) {
		printf("\n%dvalue found in array%d\n", searchKey, element);
	}
	else {
		printf("\n%dSearched value not found in array\n", searchKey);
	}

	system("pause");
	return 0;
}
Ejemplo n.º 15
0
gboolean PrintDialog::printLine(int indent, const char *line)
{
    QRect out_rect;
    QString out_line;

    if (!line || !cur_printer_ || !cur_painter_) return FALSE;

    /* Prepare the tabs for printing, depending on tree level */
    out_line.fill(' ', indent * 4);
    out_line += line;

    out_rect = cur_painter_->boundingRect(cur_printer_->pageRect(), Qt::TextWordWrap, out_line);

    if (cur_printer_->pageRect().height() < page_pos_ + out_rect.height()) {
        if (in_preview_) {
            // When generating a preview, only generate the first page;
            // if we're past the first page, stop the printing process.
            return FALSE;
        }
        if (*line == '\0') { // Separator
            return TRUE;
        }
        printHeader();
    }

    out_rect.translate(0, page_pos_);
    cur_painter_->drawText(out_rect, Qt::TextWordWrap, out_line);
    page_pos_ += out_rect.height();
    return TRUE;
}
Ejemplo n.º 16
0
/*
 * The temperature page, takes a linked list of structs as input
 * Should be generated from the JSON
 */
void tempPage(struct tempList *temps){    //take temp list as parameter
    //Set up the html file for the table
    printHeader();
    printNavbar();
    printAccountNav();
    startBody();
    divClass("centered");
    divClass("content");
    
    //start table
    printf("<table><caption>");
    printf("Recorded temperature measurements for the past 24 hours.");
    printf("</caption>\n");
    
    //Insert the header row of the table
    printf("<tr>\n");
    printf("<th scope=\"col\">Time Recorded</th>\n");
    printf("<th scope=\"col\">Temperature Recorded</th>\n");
    printf("</tr>\n");
    
    //Fill the rows of the table with the temperature val
    while (temps!=NULL){
        tableRow(temps->tempTime, temps->tempVal);
        temps = temps -> next;
    }
    
    //close the table and the rest of the page
    printf("</table>\n");
    endDiv();
    endDiv();
    endBody();
    printFooter();
}
void *sal_malloc(u_int32_t n)
{
	byte *allocated;

	//iterate through to get to the first free space
	free_header_t *first = (free_header_t *) memory+free_list_ptr;
	free_header_t *curr = first;
	int circle = TRUE;
	
	printHeader(curr);
	
	while (circle)) {
		//found a chunk that is bigger than we need
		if (n <= HEADER_SIZE+curr->size) {
			//check if we can break down chunks
			if (n <= HEADER_SIZE+(curr->size)/2) {
				//break chunk, then salloc again (and hence find that chunk)
				//TODO this is a bad way i think...
				splitChunk(curr);
				allocated = sal_malloc(u_int32_t n/2)
			//if cannot splt, then five them this bit of memory
			} else {
				allocated = (byte *)curr + HEADER_SIZE;
			}
			break;
		//else if we get back around the full circle, nothing is big enough so error
		} else if (curr == first) {
Ejemplo n.º 18
0
// main function
int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);
	cout.sync_with_stdio(false);
    // warnings
    if (argc != 4)
    {
        usage(argv);
		return 0;
    }
	int qualThreshold = atoi(argv[2]);
	int covThreshold = atoi(argv[3]);

    printHeader();

    // read lines
    if (strcmp(argv[1],"-") == 0)
    {
        readStream(qualThreshold, covThreshold);
    }
    else
    {
        const char* filename = argv[1];
        readFile(filename,qualThreshold, covThreshold);
    }
    return 0;
}
Ejemplo n.º 19
0
int ApiGen::genFuncTable(const std::string &filename, SideType side)
{
    FILE *fp = fopen(filename.c_str(), "wt");
    if (fp == NULL) {
        perror(filename.c_str());
        return -1;
    }
    printHeader(fp);

    fprintf(fp, "#ifndef __%s_%s_ftable_t_h\n", m_basename.c_str(), sideString(side));
    fprintf(fp, "#define __%s_%s_ftable_t_h\n", m_basename.c_str(), sideString(side));
    fprintf(fp, "\n\n");
    fprintf(fp, "static const struct _%s_funcs_by_name {\n", m_basename.c_str());
    fprintf(fp,
            "\tconst char *name;\n" \
            "\tvoid *proc;\n" \
            "} %s_funcs_by_name[] = {\n", m_basename.c_str());


    for (size_t i = 0; i < size(); i++) {
        EntryPoint *e = &at(i);
        if (e->notApi()) continue;
        fprintf(fp, "\t{\"%s\", (void*)%s},\n", e->name().c_str(), e->name().c_str());
    }
    fprintf(fp, "};\n");
    fprintf(fp, "static const int %s_num_funcs = sizeof(%s_funcs_by_name) / sizeof(struct _%s_funcs_by_name);\n",
            m_basename.c_str(), m_basename.c_str(), m_basename.c_str());
    fprintf(fp, "\n\n#endif\n");
    return 0;
}
Ejemplo n.º 20
0
/*
 * The login page. 
 * If error evaluates to true, show the user that the login failed
 */
void loginPage(int error){
    //Start of the page
    printHeader();
    printNavbar();
    startBody();
    divClass("centered");
    printBanner();
    
    //begin sign in display
    printf("<h1>Please sign in below to view the temperature recordings.</h1>\n");
    divClass("frame"); divClass("inFrame");
    
    if (error) //If Login Failed
        printf("<font color=\"#990000\">There was an error, try again.</font>");
    
    printf("<form action=\"\" method=\"get\" onSubmit=\"window.location.reload()\">\n" );
    input("text", "user", "Username");
    br();
    input("password" ,"pass", "Password");
    br();br();

    printf ("<input type=\"submit\" value=\"Sign In!\" class=\"btn\">\n");
    button("./temp-cgi/login.cgi", "float-right", "Sign Up!");
    printf("</form>\n");
    
    //End login form and fill out the rest of the page
    endDiv(); endDiv();
    endDiv();
    endBody();
    printFooter();
}
static void msBedPrintTable(struct bed *bedList, struct hash *erHash,
    char *itemName, char *expName, float minScore, float maxScore,
    float stepSize, int base,
    void(*printHeader)(struct bed *bedList, struct hash *erHash, char *item),
			    void(*printRow)(struct bed *bedList,struct hash *erHash, int expIndex, char *expName, float maxScore, enum expColorType colorScheme),
    void(*printKey)(float minVal, float maxVal, float size, int base, struct rgbColor(*getColor)(float val, float max, enum expColorType colorScheme), enum expColorType colorScheme),
    struct rgbColor(*getColor)(float val, float max, enum expColorType colorScheme),
	enum expColorType colorScheme)
/* prints out a table from the data present in the bedList */
{
int i,featureCount=0;
if(bedList == NULL)
    errAbort("hgc::msBedPrintTable() - bedList is NULL");
featureCount = slCount(bedList);
/* time to write out some html, first the table and header */
if(printKey != NULL)
    printKey(minScore, maxScore, stepSize, base, getColor, colorScheme);
printf("<p>\n");
printf("<basefont size=-1>\n");
printf("<table  bgcolor=\"#000000\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\"><tr><td>");
printf("<table  bgcolor=\"#fffee8\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">");
printHeader(bedList, erHash, itemName);
for(i=0; i<bedList->expCount; i++)
    {
    printRow(bedList, erHash, i, expName, maxScore, colorScheme);
    }
printf("</table>");
printf("</td></tr></table>");
printf("</basefont>");
}
Ejemplo n.º 22
0
int main(){
    int i;

    // Read in the input glass
    char filename[100] = "glass.std";
    printf("Reading: %s\n", filename);
    tipsy* tipsyIn = readTipsyStd(filename);
    // Set attributes not set by readTipsy
    tipsyIn->attr->xmin = -0.5; tipsyIn->attr->xmax = 0.5;
    tipsyIn->attr->ymin = -0.5; tipsyIn->attr->ymax = 0.5;
    tipsyIn->attr->zmin = -0.5; tipsyIn->attr->zmax = 0.5;
    printf("Input ");
    printHeader(tipsyIn->head);
    printAttr(tipsyIn->attr);
    printf("=================================================\n");

    // Create 1/8x compressed glass
    printf("\nCreating 1/8x compressed glass:\n");
    tipsy* glass8f = tipsyClone(tipsyIn);
    tipsyScaleExpand(glass8f, 2, 2, 2);
    tipsyCenter(glass8f);
    printHeader(glass8f->head);
    printAttr(glass8f->attr);
    printf("=================================================\n");
    writeTipsyStd("glass8f.std", glass8f);

    // Tile the 1/8x compressed glass to 28x2x2
    printf("\nTiling Shocktube:\n");
    tipsy* rcrShock = tipsyClone(glass8f);
    tipsyTesselate(rcrShock, 14, 1, 1);           // creates 28x2x2
    printf("\nCentering:\n");
    tipsyCenter(rcrShock);
    printf("\nEditing Velocities:\n");
    for (i=0; i<rcrShock->head->nsph; i++){
        if (rcrShock->gas[i].pos[AXIS_X] < 0.0)
            rcrShock->gas[i].vel[AXIS_X] = -1;
        else if (rcrShock->gas[i].pos[AXIS_X] > 0.0)
            rcrShock->gas[i].vel[AXIS_X] = 1;
    }
    printHeader(rcrShock->head);
    printAttr(rcrShock->attr);

    writeTipsyStd("RCRShock1.std", rcrShock);

    // Cleanup
    tipsyDestroy(tipsyIn); tipsyDestroy(glass8f); tipsyDestroy(rcrShock);
}
Ejemplo n.º 23
0
Archivo: MAIN.C Proyecto: ahelwer/UofC
/**
 * run
 * Run is the main control body of the program. It first prints the header which
 * contains directions on how to use the program then enters the paused state
 * in which the user may edit the population using a cursor controlled by the 
 * arrow keys. If the user presses Enter, the simulation is started and will
 * continue until the user again presses Enter to pause or Esc to exit.
 **/
void run(int model[][ROWS]) {
    printHeader(); //prints directions
	drawBorder(GRIDCOLOR); //draws a border
	swapBuff();
    int i = COLUMNS/2; //initializes position of cursor to middle of screen
    int j = ROWS/2;
    raw_key = 0x1C; //sets raw_key = ENTER
    while (raw_key != 0x01) { //loops until user hits Esc
	if (raw_key==0x1C) { //checks for enter pressed
            raw_key=0;
	    waitVRetrace();
	    drawGrid(GRIDCOLOR); //draws grid on screen for edit mode
	    drawSquare(i,j,SELCOLOR); //draws cursor at position on screen
	    while (raw_key!=0x1C && raw_key!=0x01) { //loops until Esc or Enter
		waitVRetrace();
		if (raw_key==0x48) { //up arrow has been pressed
		    raw_key = 0;
		    updateSquare(model,i,j); //erases cursor
		    if (j>0) {j--;} //updates cursor position
		    drawSquare(i,j,SELCOLOR); //draws cursor at new position
		}
		if (raw_key==0x50) { //down arrow has been pressed
		    raw_key = 0;
		    updateSquare(model,i,j);
		    if (j<ROWS-1) {j++;}
		    drawSquare(i,j,SELCOLOR);
		}
		if (raw_key==0x4B) { //left arrow has been pressed
		    raw_key = 0;
		    updateSquare(model,i,j);
		    if (i>0) {i--;}
		    drawSquare(i,j,SELCOLOR);
		}
		if (raw_key==0x4D) { //right arrow has been pressed
		    raw_key = 0;
		    updateSquare(model,i,j);
		    if (i<COLUMNS-1) {i++;}
		    drawSquare(i,j,SELCOLOR);
		}
		if (raw_key==0x39) { //spacebar has been pressed
		    raw_key = 0;
		    //flips the life state of current square
		    if (model[i][j]==1) {model[i][j]=0;}
		    else {model[i][j]=1;}
		}
		swapBuff();
	    }
			//clears raw key if enter was pressed
            if (raw_key==0x1C) {raw_key=0;} 
	    updateSquare(model,i,j); //erases cursor
	    drawGrid(BGCOLOR); //erases grid for simulation mode
	    while(raw_key!=0x01 && raw_key!=0x1C) { //loops until Esc or Enter
		updateModel(model); //simulates game of life and redraws squares
		waitVRetrace();
		swapBuff();
	    }
	}
    }
}
Ejemplo n.º 24
0
int main(int argc, char **argv)
{
	int inputs;					/* Number of inputs into the neural network */

	getCommandLine(&inputs, argc, argv);
	printHeader(inputs);
	printSet(inputs);
}
Ejemplo n.º 25
0
 void start() { 
   #ifdef WIN32
     assert(QueryPerformanceFrequency(&g_llFrequency) != 0);
   #endif
   startTime = osQueryPerfomance();
   prevTime = startTime;
   printHeader();
 }
Ejemplo n.º 26
0
void
TextOutputter::write()
{
  printHeader();
  m_stream << endl;
  printFailures();
  m_stream << endl;
}
Ejemplo n.º 27
0
void recoverOldExtention(const char *fileName, secureHeader * sHeader){
    char * newFilePath = get_only_path_copy(fileName);
    newFilePath = (char*) myRealloc(newFilePath, strlen(newFilePath) + strlen(sHeader->fileName) + 1);
     strcat(newFilePath, sHeader->fileName);
    printHeader(sHeader);
    fprintf(stderr, "newFile is %s", newFilePath);
    rename(fileName, newFilePath);
    myFree(newFilePath);
}
void uniqSize(char *ooDir, char *agpFile, char *glFile, char *altFile)
/* Figure out unique parts of genome from all the
 * gold.22 files in ooDir */
{
struct fileInfo *chromDirs, *chromEl;
struct fileInfo *contigDirs, *contigEl;
char subDir[512];
struct chromInfo *ciList = NULL, *ci, *ciTotal;

chromDirs = listDirX(ooDir, "*", FALSE);
for (chromEl = chromDirs; chromEl != NULL; chromEl = chromEl->next)
    {
    char *chromName = chromEl->name;
    int dirNameLen = strlen(chromName);
    if (dirNameLen > 0 && dirNameLen <= 2 && chromEl->isDir)
	{
	struct chromInfo *ctgList = NULL, *ctg;
	sprintf(subDir, "%s/%s", ooDir, chromName);
	contigDirs = listDirX(subDir, "NT*", FALSE);
	for (contigEl = contigDirs; contigEl != NULL; contigEl = contigEl->next)
	    {
	    if (contigEl->isDir)
		{
		int nSize, uSize;
		char *contigName = contigEl->name;
		char fileName[512];
		sprintf(fileName, "%s/%s/%s", subDir, contigName, agpFile);
		if (!fileExists(fileName) && altFile != NULL)
		    sprintf(fileName, "%s/%s/%s", subDir, contigName, altFile);
		if (fileExists(fileName))
		    {
		    ctg = oneContigInfo(fileName);
		    slAddHead(&ctgList, ctg);
		    getSizes(fileName, &uSize, &nSize);
		    sprintf(fileName, "%s/%s/%s", subDir, contigName, glFile);
		    if (fileExists(fileName))
			addStretchInfo(fileName, ctg);
		    }
		else
		    {
		    warn("No %s in %s/%s", agpFile, subDir, contigName);
		    }
		}
	    }
	slFreeList(&contigDirs);
	ci = combineChromInfo(ctgList, chromName);
	slAddHead(&ciList, ci);
	}
    }
slReverse(&ciList);

printHeader(stdout);
for (ci = ciList; ci != NULL; ci = ci->next)
    printChromInfo(ci, stdout);
ciTotal = combineChromInfo(ciList, "total");
printChromInfo(ciTotal, stdout);
}
/**
 * \brief    Main function
 * \details  --
 * \param    int argc
 * \param    char const** argv
 * \return   \e int
 */
int main( int argc, char const** argv )
{
  /*------------------------------------------------*/
  /* 1) read command line arguments                 */
  /*------------------------------------------------*/
  size_t backup_start = 0;
  size_t backup_end   = 0;
  size_t backup_step  = 0;
  readArgs(argc, argv, backup_start, backup_end, backup_step);
  
  /*------------------------------------------------*/
  /* 2) print header                                */
  /*------------------------------------------------*/
  printHeader();
  
  /*------------------------------------------------*/
  /* 3) recover the simulation state at each backup */
  /*------------------------------------------------*/
  std::ofstream file("./statistics/SL_diversity.txt", std::ios::out | std::ios::trunc);
  file << "backup SpA SpB\n";
  size_t current_step = backup_start;
  while (current_step <= backup_end)
  {
    std::cout << "> Working with backup " << current_step << " ...\n";
    
    /*----------------------------------------*/
    /* 3.1) Open the backups                  */
    /*----------------------------------------*/
    Parameters* parameters = new Parameters(current_step);
    Simulation* simulation = new Simulation(parameters, current_step, false);
    simulation->initialize(FROM_BACKUP);
    
    /*----------------------------------------*/
    /* 3.2) Compute SL diversity and write it */
    /*----------------------------------------*/
    double Sp_A  = 0.0;
    double Sp_B  = 0.0;
    double depth = (double)current_step-simulation->get_phylogenetic_tree()->get_common_ancestor_age();
    simulation->get_phylogenetic_tree()->compute_common_ancestor_SL_repartition(Sp_A, Sp_B);
    if (Sp_A != -1.0 && Sp_B != -1.0)
    {
      file << current_step << " " << Sp_A << " " << Sp_B << " " << depth << "\n";
    }
    
    /*----------------------------------------*/
    /* 3.3) Free memory                       */
    /*----------------------------------------*/
    delete simulation;
    simulation = NULL;
    delete parameters;
    parameters = NULL;
    current_step += backup_step;
  }
  file.close();
  return EXIT_SUCCESS;
}
Ejemplo n.º 30
0
int main()
{
    printHeader();

    insert_increasing< S1 >();
    insert_increasing< S2 >();
    insert_increasing< S3 >();

    insert_decreasing< S1 >();
    insert_decreasing< S2 >();
    insert_decreasing< S3 >();

    insert_random< S1 >();
    insert_random< S2 >();
    insert_random< S3 >();

    index_operator_increasing< S1 >();
    index_operator_increasing< S2 >();
    index_operator_increasing< S3 >();

    index_operator_decreasing< S1 >();
    index_operator_decreasing< S2 >();
    index_operator_decreasing< S3 >();

    index_operator_random< S1 >();
    index_operator_random< S2 >();
    index_operator_random< S3 >();

    find< S1 >();
    find< S2 >();
    find< S3 >();

    erase_increasing< S1 >();
    erase_increasing< S2 >();
    erase_increasing< S3 >();

    erase_decreasing< S1 >();
    erase_decreasing< S2 >();
    erase_decreasing< S3 >();

    erase_random< S1 >();
    erase_random< S2 >();
    erase_random< S3 >();

    random_operations< S1 >();
    random_operations< S2 >();
    random_operations< S3 >();

    std::cout << "OK" << std::endl;

#if defined _MSC_VER
    system( "pause" );
#endif

    return 0;
}