int main() { char matx1[4][4] = {{'-','-','-','-'}, {'-','o','-','-'}, {'o','o','o','-'}, {'-','-','-','-'}}; char matx2[4][4] = {{'-','-','-','-'}, {'-','o','o','-'}, {'o','o','-','-'}, {'-','-','-','-'}}; char matx3[4][4] = {{'-','-','-','-'}, {'-','o','-','-'}, {'-','o','-','-'}, {'-','o','o','-'}}; char matx4[4][4] = {{'-','-','o','-'}, {'-','-','o','-'}, {'-','-','o','-'}, {'-','-','o','-'}}; printout(matx1, matx2, matx3, matx4); rotation(matx1); rotation(matx2); rotation(matx3); rotation(matx4); printout(matx1, matx2, matx3, matx4); rotation(matx1); rotation(matx2); rotation(matx3); rotation(matx4); printout(matx1, matx2, matx3, matx4); rotation(matx1); rotation(matx2); rotation(matx3); rotation(matx4); printout(matx1, matx2, matx3, matx4); rotation(matx1); rotation(matx2); rotation(matx3); rotation(matx4); printout(); return 0; }
void print_model (model *mod) { int i, j; printout("Dependent variable: %s\n", mod->dvname); printlog(VERBOSE, "\tAt position: %d\n", mod->dv); printout("Number of independent variables: %d\n", mod->numiv); printlog(VERBOSE, "Space allocated for independent variable array: %d\n", mod->maxiv); for (i = 0; i < mod->numiv; i++) { printout("Effect %d: %s", 1+i, mod->ivnames[i]); if (mod->direct[i] == 1) printout(" (DIRECT)\n"); else printout("\n"); printlog(VERBOSE, "\tAt position: %d\n", mod->iv[i]); } printout("Number of interactions: %d\n", mod->numints); printlog(VERBOSE, "Space allocated for interactions: %d\n", mod->maxints); for (i = 0; i < mod->numints; i++) { printout("Interaction %d: %s, %d terms [", 1+i, mod->intnames[i], mod->inttc[i]); for (j = 0; j < mod->inttc[i]; j++) { printout("%d", mod->ints[i][j]); if (j < mod->inttc[i] - 1) printout(", "); else printout("]\n"); } } }
void printout(box * tree) { if((tree) != NULL) { printout(tree -> l); printf("%d",tree -> d); printout(tree -> r); } }
template <typename TYPE> TYPE* _create_object(Geant4Kernel& kernel, const TypeName& typ) { Geant4Context* ctxt = kernel.workerContext(); Geant4Action* object = PluginService::Create<Geant4Action*>(typ.first, ctxt, typ.second); if (!object && typ.first == typ.second) { string _t = typeName(typeid(TYPE)); printout(DEBUG, "Geant4Handle", "Object factory for %s not found. Try out %s", typ.second.c_str(), _t.c_str()); object = PluginService::Create<Geant4Action*>(_t, ctxt, typ.second); if (!object) { size_t idx = _t.rfind(':'); if (idx != string::npos) _t = string(_t.substr(idx + 1)); printout(DEBUG, "Geant4Handle", "Try out object factory for %s",_t.c_str()); object = PluginService::Create<Geant4Action*>(_t, ctxt, typ.second); } } if (object) { TYPE* ptr = dynamic_cast<TYPE*>(object); if (ptr) { return ptr; } except("Geant4Handle", "Failed to convert object of type %s to handle of type %s!", typ.first.c_str(),typ.second.c_str()); } except("Geant4Handle", "Failed to create object of type %s!", typ.first.c_str()); return 0; }
void printout(node *Tree) { printf("Root = %d\n",Tree->val); if(Tree->right){ printf("Right: "); printout(Tree->right); } if(Tree->left){ printf("Left: "); printout(Tree->left); } }
void apply_create_continuations(VectorP packages, VectorC& continuations, uint64_t num, double ot){ typedef hpx::actions::base_lco_continuation<Result> rc_type; uint64_t i = 0; double mean; string message = "Measuring time required to create continuations:"; vector<double> time; vector<hpx::naming::id_type> cgids; rc_type* temp; for(; i < num; i++) cgids.push_back(packages[i]->get_gid()); high_resolution_timer t; for(i = 0; i < num; i++) temp = new rc_type(cgids[i]); mean = t.elapsed()/num; cgids.clear(); time.reserve(num); continuations.reserve(num); for(i = 0; i < num; ++i){ const hpx::naming::id_type cgid = packages[i]->get_gid(); high_resolution_timer t1; continuations.push_back(new rc_type(cgid)); time.push_back(t1.elapsed()); } printout(time, ot, mean, message); }
void tracenumber( tsd_t *TSD, const num_descr *num, char type ) { char tmpch; streng *message,*tmpstr; tra_tsd_t *tt; num_descr nd; int indent; tmpch = TSD->currlevel->tracestat; if ( ( tmpch != 'I' ) && ( tmpch != 'R' ) ) return; tt = (tra_tsd_t *)TSD->tra_tsd; if ( tt->traceflag || tt->quiet ) return; memset( &nd, 0, sizeof( num_descr ) ); descr_copy( TSD, num, &nd ); tmpstr = str_norm( TSD, &nd, NULL ); indent = TSD->systeminfo->cstackcnt + TSD->systeminfo->ctrlcounter; message = Str_makeTSD( 30 + indent + tmpstr->len ); sprintf( tt->tracestr, " >%%c> %%%ds \"%%.%ds\"", indent, tmpstr->len ); message->len = sprintf( message->value, tt->tracestr, type, "", tmpstr->value ); printout( TSD, message ); if ( nd.num != NULL ) FreeTSD( nd.num ); Free_stringTSD( message ); Free_stringTSD( tmpstr ); }
void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) { SCH_EDIT_FRAME* parent = GetParent(); GetPrintOptions(); wxPrintDialogData printDialogData( parent->GetPageSetupData().GetPrintData() ); printDialogData.SetMaxPage( g_RootSheet->CountSheets() ); if( g_RootSheet->CountSheets() > 1 ) printDialogData.EnablePageNumbers( true ); wxPrinter printer( &printDialogData ); SCH_PRINTOUT printout( parent, _( "Print Schematic" ) ); if( !printer.Print( this, &printout, true ) ) { if( wxPrinter::GetLastError() == wxPRINTER_ERROR ) wxMessageBox( _( "An error occurred attempting to print the schematic." ), _( "Printing" ), wxOK ); } else { parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData(); } }
void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) { SetPrintParameters( ); // If no layer selected, we have no plot. prompt user if it happens // because he could think there is a bug in Pcbnew: if( s_Parameters.m_PrintMaskLayer == 0 ) { DisplayError( this, _( "No layer selected" ) ); return; } wxPrintDialogData printDialogData( *s_PrintData ); wxPrinter printer( &printDialogData ); wxString title = _( "Print" ); BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_parent, title ); if( !printer.Print( this, &printout, true ) ) { if( wxPrinter::GetLastError() == wxPRINTER_ERROR ) DisplayError( this, _( "There was a problem printing" ) ); return; } else { *s_PrintData = printer.GetPrintDialogData().GetPrintData(); } }
void tracevalue( tsd_t *TSD, const streng *str, char type ) { char tmpch; streng *message; tra_tsd_t *tt; int indent; /* * ANSI 8.3.17 requires placeholders in PARSE to be traced with TRACE R */ tmpch = TSD->currlevel->tracestat; if ( ( tmpch != 'I' ) && ( tmpch != 'R' ) ) return; tt = (tra_tsd_t *)TSD->tra_tsd; if ( tt->traceflag || tt->quiet ) return; indent = TSD->systeminfo->cstackcnt + TSD->systeminfo->ctrlcounter; message = Str_makeTSD( str->len + 30 + indent ); sprintf( tt->tracestr, " >%%c> %%%ds \"%%.%ds\"", indent, str->len ); message->len = sprintf( message->value, tt->tracestr, type, "", str->value ); printout( TSD, message ); Free_stringTSD( message ); }
void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) { if( !PreparePrintPrms() ) return; wxPrintDialogData printDialogData( *s_printData ); wxPrinter printer( &printDialogData ); wxString title = _( "Print" ); BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_Parent, title ); // Disable 'Print' button to prevent issuing another print // command before the previous one is finished (causes problems on Windows) ENABLER printBtnDisable( *m_buttonPrint, false ); if( !printer.Print( this, &printout, true ) ) { if( wxPrinter::GetLastError() == wxPRINTER_ERROR ) DisplayError( this, _( "There was a problem printing" ) ); } else { *s_printData = printer.GetPrintDialogData().GetPrintData(); } }
bool DIALOG_PRINT_USING_PRINTER::TransferDataFromWindow() { SCH_EDIT_FRAME* parent = GetParent(); GetPrintOptions(); wxPrintDialogData printDialogData( parent->GetPageSetupData().GetPrintData() ); printDialogData.SetMaxPage( g_RootSheet->CountSheets() ); if( g_RootSheet->CountSheets() > 1 ) printDialogData.EnablePageNumbers( true ); wxPrinter printer( &printDialogData ); SCH_PRINTOUT printout( parent, _( "Print Schematic" ) ); // Disable 'Print' button to prevent issuing another print // command before the previous one is finished (causes problems on Windows) m_sdbSizer1OK->Enable( false ); if( !printer.Print( this, &printout, true ) ) { if( wxPrinter::GetLastError() == wxPRINTER_ERROR ) wxMessageBox( _( "An error occurred attempting to print the schematic." ), _( "Printing" ), wxOK ); } else { parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData(); } return true; }
int main (void) { FILE *fin, *fout, *fdict; char str[MAXCHAR + 1]; Name cow[MAXN]; int count, index; long long serial; fin = fopen("namenum.in", "r"); fout = fopen("namenum.out", "w"); fdict = fopen("dict.txt", "r"); count = 0; while (fscanf(fdict, "%s", str) != EOF) { if (screen(str)) continue; copy(&cow[count++], str); sort(cow, count); } fscanf(fin, "%lld", &serial); if ((index = find(serial, cow, count)) > -1) printout(fout, index, cow, count); else fprintf(fout, "NONE\n"); return 0; }
void DIALOG_PRINT_FOR_MODEDIT::OnPrintButtonClick( wxCommandEvent& event ) { PCB_PLOT_PARAMS plot_opts = m_parent->GetPlotSettings(); s_Parameters.m_Print_Black_and_White = m_ModeColorOption->GetSelection(); s_Parameters.m_PrintScale = s_scaleList[m_ScaleOption->GetSelection()]; plot_opts.SetFineScaleAdjustX( s_Parameters.m_XScaleAdjust ); plot_opts.SetFineScaleAdjustY( s_Parameters.m_YScaleAdjust ); plot_opts.SetScale( s_Parameters.m_PrintScale ); m_parent->SetPlotSettings( plot_opts ); wxPrintDialogData printDialogData( *s_PrintData ); wxPrinter printer( &printDialogData ); BOARD_PRINTOUT_CONTROLLER printout( s_Parameters, m_parent, _( "Print Footprint" ) ); if( !printer.Print( this, &printout, true ) ) { if( wxPrinter::GetLastError() == wxPRINTER_ERROR ) DisplayError( this, _( "There was a problem printing." ) ); return; } else { *s_PrintData = printer.GetPrintDialogData().GetPrintData(); } }
void run_tests(bool empty, uint64_t num, T a1){ uint64_t i = 0; double ot = timer_overhead(num); string message; vector<double> time; Vector packages; hpx::naming::id_type lid = hpx::find_here(); create_packages<Vector, Package>(packages, num); //next test applies actions directly, skipping get_gid stage high_resolution_timer tt; for(i = 0; i < num; ++i) hpx::apply<Action>(lid, a1); double mean = tt.elapsed()/num; time.reserve(num); message = "Measuring time required to apply actions directly:"; for(i = 0; i < num; i++){ high_resolution_timer t1; hpx::apply<Action>(lid, a1); time.push_back(t1.elapsed()); } printout(time, ot, mean, message); }
void run_tests(bool empty, uint64_t num){ uint64_t i = 0; double ot = timer_overhead(num); string message; vector<double> time; Vector packages; //first create packages create_packages<Vector, Package>(packages, num); //find the local id to give as the apply destination (we don't want to //perform a remote action in this test) hpx::naming::id_type lid = hpx::find_here(); //obtain the mean time of applying the action high_resolution_timer tt; for(i = 0; i < num; ++i) hpx::apply<Action>(lid); double mean = tt.elapsed()/num; time.reserve(num); message = "Measuring time required to apply actions directly:"; //obtain a statistical sampling of the apply time for(i = 0; i < num; i++){ high_resolution_timer t1; hpx::apply<Action>(lid); time.push_back(t1.elapsed()); } printout(time, ot, mean, message); }
void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event)) { wxPostScriptPrinter printer(g_printData); MyPrintout printout(_T("My printout")); printer.Print(this, &printout, true/*prompt*/); (*g_printData) = printer.GetPrintData(); }
void Network::train(vector<float> x,int ident,float beta) { vector<vector<float> > y; vector<vector<float> > dy; vector<float> answer=x; vector<vector<float> > delta(layers.size(),vector<float>()); deque<Layer>::iterator i; for (i = layers.begin(); i != layers.end(); ++i) { dy.push_back((*i).get_dy(answer)); answer=(*i).classify(answer); y.push_back(answer); } vector<float> d(x.size(),-1.0f); d[ident] = 1.0f; //output layer for (int j = 0; j < y.back().size(); ++j) delta.back().push_back((d[j]-y.back()[j])*dy.back()[j]); //hidden layers for (int k=layers.size()-1;k>=0;--k) for (int j=0;j<y[k].size();++j) { float sum=0.0; for (int l=0;l<layers[k+1].size();++l) { sum+=delta[k+1][l]*layers[k+1].get_weight(l,j); } delta[k].push_back(sum*dy[k][j]); } cout<<"DELTA"<<endl; for (vector<vector<float> >::iterator i=delta.begin();i!=delta.end();++i) { for (vector<float>::iterator j=(*i).begin();j!=(*i).end();++j) cout<<(*j)<<" "; cout<<endl; } //correction for (int k=1;k<layers.size();++k) for (int n=0;n<layers[k].size();++n) { vector<float> mod; for (int l=0;l<layers[k-1].size();++l) mod.push_back(beta*delta[k][n]*y[k-1][l]); mod.push_back(beta*delta[k][n]); layers[k].modify(n,mod); } printout(); }
Network::Network(vector<int> arch) { for (unsigned int i=1; i < arch.size(); ++i) { layers.push_back(Layer(arch[i],arch[i-1])); } printout(); }
int main(void) { printout(); bool dobreak = false; char response; double r = 0; for (;!dobreak;) { response = 'a'; int dimensions = promptdimensions(); switch (dimensions) { case 2: // Get parameters while( r <= 0.0 ) { printf("Please give a length: "); scanf("%lf", &r); } circle(r); square(r); break; case 3: // Get parameters while( r <= 0.0 ) { printf("Please give a length: "); scanf("%lf", &r); } sphere(r); cube(r); break; default: break; } for(;;) { printf("Do you want to do this again? (y/n)\n"); scanf(" %c", &response); if (response == 'y' || response == 'Y') { printf("Restarting\n"); break; } else if (response == 'N' || response == 'n') { printf("Quitting\n"); dobreak = true; break; } else { printf("That is not an acceptable response\n"); } } } return 0; }
uint32_t Register_GPIO_BRR::operator = (uint32_t arg) { printout("=", 0); uint32_t value = odr_.value_; value &= ~(arg & 0xffff); odr_.assign(value); return 0; // See STM32F0xx Refence Manual RM0091 Doc ID 018940 Rev 5 page 165. }
void eErrorOutput::thread_finished() { threadrunning=false; printout_timer->stop(); printout(); while(waitPrintout) usleep(10000); // wait 10 milliseconds }
int main (void) { static const char * teststrings [] = { "autoksiko", " autoksiko", "autoksiko ", " autoksiko ", "autoksiko teen", " autoksiko teen", "autoksiko teen ", " autoksiko teen ", " miljoona miljoona ruusua ", 0 }; int i; for (i = 0; teststrings [i] != 0; i++) { char * ts; char * orig_ts; orig_ts = ts = strdup (teststrings [i]); if (ts == 0) { fail(); } printf ("Plain: "); printout (ts); printf ("Left-trimmed: "); printout (left_trimmed (ts)); printf ("Right-trimmed: "); trim_right (ts); printout (ts); printf ("Completely trimmed: "); printout (left_trimmed (ts)); puts (""); free (orig_ts); } return 0; }
int main(void) { /* movl $foo,%eax puts the address of variable foo into register %eax, but movl foo,%eax puts the contents of variable foo into register %eax. There are two %’s prefixed to the register name. This helps GCC to distinguish between the operands and registers. operands have a single % as prefix. The clobbered register %eax after the third colon tells GCC that the value of %eax is to be modified inside "asm", so GCC won’t use this register to store any other value. +---+--------------------+ | r | Register(s) | +---+--------------------+ | a | %eax, %ax, %al | | b | %ebx, %bx, %bl | | c | %ecx, %cx, %cl | | d | %edx, %dx, %dl | | S | %esi, %si | | D | %edi, %di | +---+--------------------+ */ resetvals(); input_a=2, input_b=3; __asm__( "movl %0, %2;" // move input_1 to output_1 "movl %1, %3;" // move input_2 to output_2 :"=r" (output_a) , "=i" (output_b) /* output */ :"r" (input_a) , "0" (input_b) /* input */ :"%eax" ); printout(); resetvals(); input_a=5, input_b=4; __asm__( "leal (%0,%0,1), %2;" :"=r" (output_a) /* output */ :"r" (input_a) , "r" (input_b) /* input */ :"%eax" /* clobbered register */ ); printout(); return 0; }
int main(void){ float total_mtests = 0; #pragma omp parallel { unsigned int seed; double last_print = omp_get_wtime(); unsigned testcount = 0; unsigned lasttestcount = testcount; seed = time(NULL); float *floatpart = malloc(0); int *intpart = malloc(0); float my_mtests = 0; unsigned j; for(j=0; j<1024*1024*1024; j++){ int n = (rand_r(&seed) % 64) + 1; int len = (rand_r(&seed) % n) + 1; if(len/4 > 0 && n / (len/4) > 0) len = len / 4; int chunk = (rand_r(&seed) % (n / len)) + 1; floatpart = realloc(floatpart, sizeof(float)*len); intpart = realloc(intpart, sizeof(int)*len); int i; for(i=0; i<len; i++){ floatpart[i] = 1e-9 + ((double)rand_r(&seed) / (double)RAND_MAX) * len; } int ret; ret = intpart_from_floatpart_chunked_normalized(n, intpart, floatpart, chunk, 0, len); if(ret != 0) printf("len=%d, n=%d, chunk=%d, returned %d.\n", len, n, chunk, ret); testcount++; double now = omp_get_wtime(); if(now - last_print > 4.0){ #pragma omp critical { total_mtests -= my_mtests; my_mtests = (double)(testcount-lasttestcount)/(double)(now - last_print)*1e-6; total_mtests += my_mtests; printf("Thread %d: %1.3f Mtests/s. Total: %1.3f Mtests/s.\n", omp_get_thread_num(), my_mtests, total_mtests); lasttestcount = testcount; last_print = now; printf("len=%d, chunk=%d, n=%d\n", len, chunk, n); printout(intpart, floatpart, len); printf("\n"); } } } } }
void input(int array[max]) //Function to take input the elements of the array { int i , size; printf("Enter the size of the elements in the array\n"); scanf("%d",&size); printf("Enter the elements in the array \n"); for(i=0;i<size;i++) //Taking input for a array { scanf("%d",&array[i]); } printout(array,size); }
static void tracemsg( tsd_t *TSD ) { streng *message; const streng *msg; msg = errortext( TSD, 0, 3, 0, 0 ); message = Str_makeTSD( 12 + Str_len( msg ) ); Str_catstrTSD( message, " +++ " ); Str_catTSD( message, msg ); printout( TSD, message ); Free_stringTSD( message ); }
void reduce_do(char* buf, const size_t total, const std::string &out_folder){ yucha::tool::recursive_mkdir(out_folder.c_str()); size_t prev = 0; size_t split = 0; std::pair<size_t , size_t> p; MyHash h(buf); MyHashEq e(buf); MYMAP uni(3 , h , e); { size_t spaces[3]; for(size_t i = 0 ; i < total; ++i){ prev = i; unsigned short int count = 0; bool error = false; for(; buf[i] != '\n'; ++i){ //get freq if(buf[i] == '\t'){ if (count==2){ error = true; } else{ spaces[count] = i; ++count; }; }; }; if (count!=2 or error) continue; buf[spaces[0]] = ' '; const size_t end_1 = spaces[0]; const size_t end_2 = spaces[1]; const size_t tail = i; std::pair<size_t , size_t> word1(prev, end_1); std::pair<size_t , size_t> word2(end_1+1 , end_2); buf[tail] = '\0'; const unsigned long freq = atoi(&buf[end_2]); add(uni, word1, freq); add(uni, word2, freq); }; } printout(1, uni, out_folder, buf, 0); };
int main(int argc, char* argv[]) { int c = 0, amount = 100, show_date = 0, oldest = 0; char* dirname = "."; while((c = getopt(argc, argv, "c:doC:")) != -1) { switch(c) { case 'c': amount = atoi(optarg); break; case 'd': show_date = 1; break; case 'o': oldest = 1; break; case 'C': dirname = optarg; break; case ':': switch(optopt) { case '?': printf("%s", usage); return 1; default: break; } break; default: printf("%s", usage); return 1; } } if (chdir(dirname) < 0) { perror(dirname); exit(1); } DIR* dir = opendir("."); if (!dir) { perror(dirname); exit(1); } heap* heap_storage = init_heap(oldest, amount); traverse(dir, "./", traverseHandler, heap_storage); printout(heap_storage, show_date); closedir(dir); }
void get_results2(Vector1 packages, Vector2 futures, uint64_t num, double ot, double mean){ uint64_t i = 0; string message = "Measuring time required to get results from futures:"; vector<double> time; time.reserve(num); for(i = 0; i < num; ++i){ high_resolution_timer t1; futures[i].get(); time.push_back(t1.elapsed()); } printout(time, ot, mean, message); }