TextStream& SVGFEComposite::externalRepresentation(TextStream& ts) const { ts << "[type=COMPOSITE] "; SVGFilterEffect::externalRepresentation(ts); if (!in2().isEmpty()) ts << " [in2=\"" << in2() << "\"]"; ts << " [k1=" << k1() << " k2=" << k2() << " k3=" << k3() << " k4=" << k4() << "]"; return ts; }
TextStream& SVGFEDisplacementMap::externalRepresentation(TextStream& ts) const { ts << "[type=DISPLACEMENT-MAP] "; SVGFilterEffect::externalRepresentation(ts); if (!in2().isEmpty()) ts << " [in2=" << in2() << "]"; ts << " [scale=" << m_scale << "]" << " [x channel selector=" << m_xChannelSelector << "]" << " [y channel selector=" << m_yChannelSelector << "]"; return ts; }
int main(int argc, char* argv[]) { int n = argc>2 ? std::atoi(argv[2]) : 10; int s = argc>3 ? std::atoi(argv[3]) : 100; int l = argc>4 ? std::atoi(argv[4]) : 2; std::ostringstream out1; if(argc>5) { tgen t1(out1,s,std::atoi(argv[5])); t1.create_tetrahedra(n,n,1); } else { tgen t1(out1,s); t1.create_tetrahedra(n,n,1); } std::istringstream in1(out1.str()); Nef_polyhedron N1; in1 >> N1; CGAL_assertion(N1.is_valid()); Nef_polyhedron N2; std::ifstream in2(argv[1]); in2 >> N2; Nef_polyhedron N3=N2; transform_big(N2,n,s); N1=N2.join(N1); cgal_nef3_timer_on = true; CGAL::Random r; int x=r.get_int(0,n-l-1); int y=r.get_int(0,n-1-1); transform_small(N3,s,l,x,y); N1 = N1.difference(N3); };
//******************************************************************* // compare PUBLIC //******************************************************************* qint32 QBtFileComparator::compare( const QString& in_fname1, const QString& in_fname2 ) { qint32 retval = IO_ERROR; char buffer1[ BUFFER_SIZE ] = { 0 }; char buffer2[ BUFFER_SIZE ] = { 0 }; QFile in1( in_fname1 ); QFile in2( in_fname2 ); emit init_progress( in1.size() ); if( in1.size() != in2.size() ) { emit progress( in1.size() ); return NOT_EQUAL; } qint64 total = qint64(); if( in1.open( QIODevice::ReadOnly ) ) { if( in2.open( QIODevice::ReadOnly ) ) { while( loop_ && !in1.atEnd() && !in2.atEnd() ) { const quint32 n1 = in1.read( buffer1, BUFFER_SIZE ); const quint32 n2 = in2.read( buffer2, BUFFER_SIZE ); retval = ( n1 == n2 ) ? memcmp( buffer1, buffer2, n1 ) : NOT_EQUAL; if( EQUAL != retval ) break; total += n1; emit progress( total ); } in2.close(); } in1.close(); } return retval; }
Jugador::Jugador(list<Entidad*>* entidades,SDL_Renderer* renderer) { tipo = "Jugador"; this->renderer = renderer; this->textures["down"].push_back(IMG_LoadTexture(renderer, "Personaje/down1.png")); this->textures["down"].push_back(IMG_LoadTexture(renderer, "Personaje/down2.png")); this->textures["up"].push_back(IMG_LoadTexture(renderer, "Personaje/up1.png")); this->textures["up"].push_back(IMG_LoadTexture(renderer, "Personaje/up2.png")); this->textures["left"].push_back(IMG_LoadTexture(renderer, "Personaje/left1.png")); this->textures["left"].push_back(IMG_LoadTexture(renderer, "Personaje/left2.png")); this->textures["right"].push_back(IMG_LoadTexture(renderer, "Personaje/right1.png")); this->textures["right"].push_back(IMG_LoadTexture(renderer, "Personaje/right2.png")); SDL_QueryTexture(this->textures["down"][0], NULL, NULL, &rect.w, &rect.h); ifstream in("Posiciones"); ifstream in2("Estado"); vector<double> respuesta; vector<string> respuesta2; double str; string estado; // CHEQUIAR POSICION while(in>>str) { respuesta.push_back(str); } if(respuesta.size()==0) { x= 150; y= 150; } else { x = respuesta[0]; y = respuesta[1]; } //CHEQUIAR ESTADO while(in2>>estado) { respuesta2.push_back(estado); } if(respuesta2.size()==0) { state= "down"; } else { state= respuesta2[0]; } rect.x = x; rect.y = x; //---------------------------------------- velocity=1.5; animation_velocity=20; current_texture=0; //state="down"; this->entidades = entidades; }
int sc_main(int ac, char *av[]) { // Parameter Settings int result_size = 9; int in1_size = 6; int in2_size = 6; // Signal Instantiation signal_bool_vector6 in1 ("in1"); signal_bool_vector6 in2 ("in2"); signal_bool_vector9 result ("result"); sc_signal<bool> ready ("ready"); // Clock Instantiation sc_clock clk( "clock", 10, SC_NS, 0.5, 0, SC_NS); // Process Instantiation datawidth D1 ("D1", clk, in1, in2, ready, result, in1_size, in2_size, result_size); stimgen T1 ("T1", clk, result, in1, in2, ready); // Simulation Run Control sc_start(); return 0; }
void append(char one[], char two[], char out[]) { ifstream in1(one); ifstream in2(two); ofstream outfile(out); char val; cout << "Adding vals from : " << one << endl; in1.get(val); while(!in1.eof()) { outfile << val; in1.get(val); } cout << "Adding vals from : " << two << endl; in2.get(val); while(!in2.eof()) { outfile << val; in2.get(val); } cout << out << " is complete"; return; }
std::vector< std::vector<SgMove> > GoAutoBook::ParseWorkList(std::istream& in) { std::vector< std::vector<SgMove> > ret; while (in) { std::string line; std::getline(in, line); if (line == "") continue; std::vector<SgMove> var; std::istringstream in2(line); while (true) { std::string s; in2 >> s; if (! in2 || s == "|") break; std::istringstream in3(s); SgPoint p; in3 >> SgReadPoint(p); if (! in3) throw SgException("Invalid point"); var.push_back(p); } ret.push_back(var); } SgDebug() << "GoAutoBook::ParseWorkList: Read " << ret.size() << " variations.\n"; return ret; }
/// \brief Fonction de lecture du fichier d'adjacence /// \param g Matrice d'adjacence à remplir /// \throws ReaderException when an error occurs void parse(std::string const & filename, Graph & g) { int i1, i2; bool line_error = false, found= false; edge_descriptor e; std::string line, tempString, linkType; vertex_descriptor v,vv ; //mapping typedef std::map< int , Graph::vertex_descriptor> as_number_to_vertex_type; as_number_to_vertex_type as_number_to_vertex; try { std::ifstream file(filename.c_str()); if( file.is_open() ) { //remplissage de la matrice while(std::getline(file, line)) { // std::cout << "je lis la ligne" << file.tellg() << std::endl; std::istringstream lineStream(line); if(lineStream >> tempString) { std::istringstream in1(tempString); if(lineStream >> tempString) { std::istringstream in2(tempString); //Si tout rentre dans chacun des conteneurs... if(lineStream >> linkType && in1 >> i1 && in2 >> i2) { // // std::cout << i1 << "," << i2 << std::endl; as_number_to_vertex_type::const_iterator found_i1 = as_number_to_vertex.find(i1); if( found_i1 == as_number_to_vertex.end()) { v = boost::add_vertex(g); as_number_to_vertex[i1] = v; g[v].asn=i1; } else v = found_i1->second; as_number_to_vertex_type::const_iterator found_i2 = as_number_to_vertex.find(i2); if( found_i2 == as_number_to_vertex.end()) { vv = boost::add_vertex(g); as_number_to_vertex[i2] = vv; g[vv].asn=i2; } else vv = found_i2->second; int type = addEdge(v, vv, linkType, found, e, g); if(!found) line_error=true; else g[e].link_type = type; } else { line_error=true; } } else line_error=true; } else line_error=true; }
int test_colt_nested_cells() { char *outer1[] = { "1962", "1977", "1989", "2010" }; char *outer2[] = { "1990", "2001", "2008", "2015" }; char *outer3[] = { "1993", "2001", "2009", "2013" }; char *inner1[] = { "Jan", "Feb", "March" }; char *inner2[] = { "Apr", "May", "June" }; char *inner3[] = { "July", "August", "September" }; char *inner4[] = { "October", "November", "December" }; char *deep1[] = { "14", "9", "2" }; char *deep2[] = { "25", "4", "0" }; char *head1[] = { "Birth", "start", "better", "bests" }; char *head2[] = { "Mon1", "mon2", "Month3" }; char *head3[] = { "father", "daughter", "son" }; colt_nested_cells deepest1(deep1, 3, head3, "days"); colt_nested_cells deepest2(deep2, 3, head3, "days"); colt_nested_cells in11(inner1, 3, head2, "Months", &deepest1); colt_nested_cells in12(inner1, 3, head2, "Months", &deepest2); colt_nested_cells in2(inner2, 3, head2, "Months"); colt_nested_cells in3(inner3, 3, head2, "Months"); colt_nested_cells in4(inner4, 3, head2, "Months"); colt_nested_cells out11(outer1, 4, head1, "Dates", &in11); colt_nested_cells out11a(outer1, 4, head1, "Dates", &in12); colt_nested_cells out12(outer1, 4, head1, "Dates", &in2); colt_nested_cells out13(outer1, 4, head1, "Dates", &in3); colt_nested_cells out21(outer2, 4, head1, "Dates", &in4); colt_nested_cells out22(outer2, 4, head1, "Dates", &in3); colt_nested_cells out23(outer2, 4, head1, "Dates", &in11); colt_nested_cells out31(outer3, 4, head1, "Dates", &in2); colt_nested_cells out32(outer3, 4, head1, "Dates", &in11); colt_nested_cells out33(outer3, 4, head1, "Dates", &in4); std::ofstream mine("mine.yml"); // out11.start(); out11.nested_output(NULL, 0, &mine); out11a.nested_output(&out11, 0, &mine); out12.nested_output(&out11a, 0, &mine); out23.nested_output(&out12, 0, &mine); out21.nested_output(&out23, 0, &mine); out22.nested_output(&out21, 0, &mine); out31.nested_output(&out22, 0, &mine); out32.nested_output(&out31, 0, &mine); out33.nested_output(&out32, 0, &mine); // out13.end(xxx+1); // out11.end(); }
int main(int argc, char ** argv){ if (argc < 4){ printf("USAGE: naive_multiply input_file_1.ext input_file_2.ext output_file.ext\n"); printf("where ext is either hdf5 or txt\n"); return 0; } std::string in1_str(argv[1]);//convert char* -> string std::string in2_str(argv[2]); std::string out_str(argv[3]); std::string in1_ext= GetFileExtension(in1_str);//extract file extention std::string in2_ext= GetFileExtension(in2_str); std::string out_ext= GetFileExtension(out_str); std::vector<int> in1(0,0);//doesn't matter what we initialize to, read will clear it std::vector<int> in2(0,0); std::vector<int> out(0,0); //read first input file if(in1_ext.compare("txt")==0){ text_read(in1_str,in1); }else{// if(in1_ext.compare("hdf5")==0){ hdf5_read(in1_str,in1);//hdf5 read }//else{ // std::cout << in1_ext << " files not supported!!" << std::endl; // return 1; //} //read second input file if(in2_ext.compare("txt")==0){ text_read(in2_str,in2); }else{// if(out_ext.compare("hdf5")==0){ hdf5_read(in2_str,in2);//hdf5 read }//else{ // std::cout << in2_ext << " files not supported!" << std::endl; // return 1; //} clock_t start=clock(); //do the matrix multiply multiply(in1,in2,out); std::cout << (in1[0]) << " " << (clock()-start) << std::endl; //write the output file if(out_ext.compare("txt")==0){ text_write(out_str,out); }else if(out_ext.compare("hdf5")==0){ hdf5_write(out_str,out);//hdf5 write }else{ std::cout << out_ext << " files not supported" << std::endl; return 1; } return 0; }
/// \brief Fonction de lecture du fichier d'adjacence /// \param g Matrice d'adjacence à remplir /// \throws ReaderException when an error occurs void File_reader::parse(Graph & g) { int retour = 0; int nbPoint = 0, i1, i2; bool line_error = false, found= false; edge_descriptor e; vertex_descriptor oldVertex_descriptor; std::string line, tempString, linkType; vertex_descriptor v,vv ; try { std::ifstream file(filename.c_str()); int oldVertex=0, vertexType=-1; int peersCount=0, clientsCount=0; if( file.is_open() ) { //remplissage de la matrice while(std::getline(file, line)) { // std::cout << "je lis la ligne" << file.tellg() << std::endl; std::istringstream lineStream(line); if(lineStream >> tempString) { std::istringstream in1(tempString); if(lineStream >> tempString) { std::istringstream in2(tempString); //Si tout rentre dans chacun des conteneurs... if(lineStream >> linkType && in1 >> i1 && in2 >> i2) { v = boost::vertex(i1,g); vv = boost::vertex(i2,g); vertexType=addEdge(v, vv, linkType, found, e, g); if(!found) { line_error=true; }else{ stubs_testing(peersCount, clientsCount, i1, oldVertex, vertexType, oldVertex_descriptor); oldVertex=i1; oldVertex_descriptor = v; } } else { line_error=true; } } } } if(peersCount == 0 && clientsCount == 0){ stubs_testing(peersCount, clientsCount, i1, oldVertex, vertexType, oldVertex_descriptor); } create_peers_graph(); file.close(); } else{ throw ReaderException("Fichier inexistant ou non lisible", filename,ReaderException::CRITICAL); } }
void Profiler::compareLists() { QList<QString> list2; QString dataDirectory2 = "/home/asehati/Desktop/build-GraphFetcher-online-Desktop-Debug"; dataDirectory2.append("/profiles2/"); //2 means old resource list QFile listFile2(dataDirectory2 + uniqueFileName(this->url)); if(!listFile2.exists()) { qDebug() << "The old resource list file does not exist in profiles2 directory"; return; } QTextStream in2(&listFile2); if (!listFile2.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "Could not open " << listFile2.fileName(); return; } QString line; while (!in2.atEnd()) { line = in2.readLine(); list2.append(line); } int count = 0; QSet<QUrl>::ConstIterator it = urlSet.constBegin(),end = urlSet.constEnd(); for (; it != end; ++it) { if(list2.contains((*it).toString(QUrl::FullyEncoded))) { count++; // qDebug() << (*it).toString(QUrl::FullyEncoded); } } qDebug() << "The ratio of new list that is already in old list (usefulness): " << (double)count / (double)urlSet.size(); // format in file: url usefulness hitRate statOut << this->url << "\t" << (double)count / (double)urlSet.size() << "\t" << (double)count / (double)list2.size() << "\n"; statOut.flush(); statFile.close(); listFile2.close(); list2.clear(); urlSet.clear(); }
std::shared_ptr<Shape> Arrow(const Vector &boundVertex1, const Vector &boundVertex2, int direction, const Color * inputColorPointer, float lengthRatio, float widthRatio) { Vector low = boundVertex1.Min(boundVertex2); Vector high = boundVertex1.Max(boundVertex2); Vector size = high - low; Vector handleVertex1, handleVertex2, triangleVertex1, triangleVertex2, triangleVertex3; float xin = 0.5F * (1.0F - widthRatio) * size.x; float yin = 0.5F * (1.0F - widthRatio) * size.y; // direction: 0right, 1up, 2left, 3down switch (direction) { case 0: handleVertex1 = low + Vector(0.0F, yin); handleVertex2 = Vector(low.x + lengthRatio * size.x, high.y - yin); triangleVertex1 = high - Vector(0.0F, 0.5F * size.y); triangleVertex2 = Vector(handleVertex2.x, high.y); triangleVertex3 = Vector(handleVertex2.x, low.y); break; case 1: handleVertex1 = low + Vector(xin); handleVertex2 = Vector(high.x - xin, low.y + lengthRatio * size.y); triangleVertex1 = high - Vector(0.5 * size.x); triangleVertex2 = Vector(low.x, handleVertex2.y); triangleVertex3 = Vector(high.x, handleVertex2.y); break; case 2: handleVertex1 = Vector(high.x - lengthRatio * size.x, low.y + yin); handleVertex2 = high - Vector(0.0F, yin); triangleVertex1 = low + Vector(0.0F, 0.5 * size.y); triangleVertex2 = Vector(handleVertex1.x, low.y); triangleVertex3 = Vector(handleVertex1.x, high.y); break; case 3: handleVertex1 = Vector(low.x + xin, high.y - lengthRatio * size.y); handleVertex2 = high - Vector(xin); triangleVertex1 = low + Vector(0.5 * size.x); triangleVertex2 = Vector(high.x, handleVertex1.y); triangleVertex3 = Vector(low.x, handleVertex1.y); break; } std::shared_ptr<CSG> u(new Union(inputColorPointer, true)); std::shared_ptr<CSG> in1(new Intersection(inputColorPointer, true)); std::shared_ptr<CSG> in2(new Intersection(inputColorPointer, true)); std::shared_ptr<Shape> rect(new ConvexPoly(Rectangle(handleVertex1, handleVertex2))); std::shared_ptr<Shape> tri(new ConvexPoly(Triangle({triangleVertex1, triangleVertex2, triangleVertex3}))); in1->AddElement(rect); in2->AddElement(tri); u->AddElement(in1); u->AddElement(in2); return u; }
void CMAC::Test(int num_in1, int num_in2, string path) { std::ofstream infile; infile.open(path.c_str()); vector<double> in1(num_in1); for(int i = 0; i < (num_in1-1); i++) { in1[i] = (0.5+i)*320.0/double(num_in1-1); } vector<double> in2(num_in2); for(int i = 0; i < (num_in2-1); i++) { in2[i] = (0.5+i)*240.0/double(num_in2-1); } in1[num_in1-1] = 320;in2[num_in2-1] = 240; vector<double> input(2); vector<double> output(2); for(int i = 0; i<num_in1; i++) { for(int j = 0; j < num_in2; j++) { input[0] = in1[i]; input[1] = in2[j]; cmacMap(input, output); infile<< std::fixed<<std::setprecision(5)<<input[0]<<","<<input[1]<<","<<output[0]<<","<<output[1]<<","<<endl; } } // bool mark; // for(int i = 0; i < sampleNum; i++) // { // cmacMap(inputData[i],output); // mark = false; // for(int j=0;j<N_y;j++) // { // if (abs(output[j]-desiredOutput[i][j])>= 0.1) // { // mark = true; // } // } // if (mark) { // infile<<"##########this line is wrong#################"; // } // for(int j=0;j<N_y;j++) // { // infile<<inputData[i][j]<<","; // } // for(int j=0;j<N_y;j++) // { // infile<<output[j]<<","; // } // infile<<endl; // } infile.close(); }
void merge( const QString& newname, const QString& oldname, const QString& resname ) { QFile f1(newname); if ( !f1.open( IO_ReadOnly) ) return; QFile f2(oldname); if ( !f2.open( IO_ReadOnly) ) return; QBuffer fout; fout.open(IO_WriteOnly); QTextStream in1( &f1 ); QTextStream in2( &f2 ); QTextStream out( &fout ); QString buf1 = in1.readLine().stripWhiteSpace(); QString buf2 = in2.readLine().stripWhiteSpace(); Item i1 = getItem( in1, buf1 ); Item i2 = getItem( in2, buf2 ); while ( !i1.isNull() || !i2.isNull() ) { Status s = compare( i1, i2 ); if ( s == Equal ) { writemerge(out,i1,i2); i1 = getItem( in1, buf1 ); i2 = getItem( in2, buf2 ); } else if ( s == First ) { writenew( out, i1 ); i1 = getItem( in1, buf1 ); } else if ( s == FirstJunk ) { //solitary comment writejunk( out, i1 ); i1 = getItem( in1, buf1 ); } else if ( s == Second ) { writeold( out, i2 ); i2 = getItem( in2, buf2 ); } else if ( s == SecondJunk ) { //solitary comment writejunk( out, i2 ); i2 = getItem( in2, buf2 ); } } f1.close(); f2.close(); fout.close(); QFile fileout(resname); if ( !fileout.open( IO_WriteOnly | IO_Translate ) ) return; fileout.writeBlock(fout.buffer()); fileout.close(); }
// test to run processing/example.py TEST_F(SignalProcessingInterfaceTest, exampleTest) { android::String8 functionName("example"); int nInputs = 8; int nOutputs = 4; bool inputTypes[8] = { true, true, true, true, false, false, false, false }; bool outputTypes[4] = { true, true, false, false }; android::sp<Buffer> in0(new Buffer(16, 16, true)); char* data0 = in0->getData(); for (size_t i = 0; i < in0->getSize(); i++) { data0[i] = i; } android::sp<Buffer> in1(new Buffer(16, 16, true)); char* data1 = in1->getData(); for (size_t i = 0; i < in1->getSize(); i++) { data1[i] = i; } android::sp<Buffer> in2(new Buffer(8, 8, false)); char* data2 = in2->getData(); for (size_t i = 0; i < in2->getSize(); i++) { data2[i] = i; } android::sp<Buffer> in3(new Buffer(8, 8, false)); char* data3 = in3->getData(); for (size_t i = 0; i < in3->getSize(); i++) { data3[i] = i; } TaskCase::Value in4((int64_t)100); TaskCase::Value in5((int64_t)100); TaskCase::Value in6(1.0f); TaskCase::Value in7(1.0f); void* inputs[8] = { &in0, &in1, &in2, &in3, &in4, &in5, &in6, &in7 }; android::sp<Buffer> out0(new Buffer(16, 16, true)); char* outdata0 = out0->getData(); for (size_t i = 0; i < out0->getSize(); i++) { outdata0[i] = 0xaa; } android::sp<Buffer> out1(new Buffer(8, 8, false)); char* outdata1 = out1->getData(); for (size_t i = 0; i < out1->getSize(); i++) { outdata1[i] = 0xbb; } TaskCase::Value out2((int64_t)1000); TaskCase::Value out3(-1.0f); void *outputs[4] = { &out0, &out1, &out2, &out3 }; ASSERT_TRUE(mSp->run( functionName, nInputs, inputTypes, inputs, nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK); ASSERT_TRUE(*(in0.get()) == *(out0.get())); ASSERT_TRUE(*(in2.get()) == *(out1.get())); ASSERT_TRUE(in4 == out2); ASSERT_TRUE(in6 == out3); }
TEST(RealWordTest, OR) { typedef NeuralNetwork<double, StepActivationFunction<double >> network; network nn; nn.setEntries(2); nn.setExits(1); nn.setLayersCount(1); nn.init(); std::vector<double> in1(2); std::vector<double> in2(2); std::vector<double> in3(2); std::vector<double> in4(2); in1[0] = 0; in1[1] = 0; in2[0] = 1; in2[1] = 0; in3[0] = 0; in3[1] = 1; in4[0] = 1; in4[1] = 1; std::vector<double> out0(1); std::vector<double> out1(1); out0[0] = 0; out1[0] = 1; //uczenie for (int i = 0; i < 100; ++i) { nn.setInput(in1.begin(), in1.end()); nn.calcOutput(); nn.learn(out0.begin(), out0.end()); nn.setInput(in2.begin(), in2.end()); nn.calcOutput(); nn.learn(out1.begin(), out1.end()); nn.setInput(in3.begin(), in3.end()); nn.calcOutput(); nn.learn(out1.begin(), out1.end()); nn.setInput(in4.begin(), in4.end()); nn.calcOutput(); nn.learn(out1.begin(), out1.end()); } //test std::vector<double> out; nn.setInput(in1.begin(), in1.end()); out = nn.calcOutput(); ASSERT_EQ(out[0], 0); nn.setInput(in2.begin(), in2.end()); out = nn.calcOutput(); ASSERT_EQ(out[0], 1); nn.setInput(in3.begin(), in3.end()); out = nn.calcOutput(); ASSERT_EQ(out[0], 1); nn.setInput(in4.begin(), in4.end()); out = nn.calcOutput(); ASSERT_EQ(out[0], 1); }
PassRefPtr<FilterEffect> SVGFECompositeElement::build(SVGFilterBuilder* filterBuilder) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); FilterEffect* input2 = filterBuilder->getEffectById(in2()); if (!input1 || !input2) return 0; return FEComposite::create(input1, input2, static_cast<CompositeOperationType>(_operator()), k1(), k2(), k3(), k4()); }
int main(int argc, char ** argv) { size_t n = atoi(argv[1]); size_t m = atoi(argv[2]); DB::Arena pool; std::vector<StringRef> data(n); std::cerr << "sizeof(Key) = " << sizeof(StringRef) << ", sizeof(Value) = " << sizeof(Value) << std::endl; { Stopwatch watch; DB::ReadBufferFromFileDescriptor in1(STDIN_FILENO); DB::CompressedReadBuffer in2(in1); std::string tmp; for (size_t i = 0; i < n && !in2.eof(); ++i) { DB::readStringBinary(tmp, in2); data[i] = StringRef(pool.insert(tmp.data(), tmp.size()), tmp.size()); } watch.stop(); std::cerr << std::fixed << std::setprecision(2) << "Vector. Size: " << n << ", elapsed: " << watch.elapsedSeconds() << " (" << n / watch.elapsedSeconds() << " elem/sec.)" << std::endl; } if (!m || m == 1) bench<StringRef_Compare1_Ptrs> (data, "StringRef_Compare1_Ptrs"); if (!m || m == 2) bench<StringRef_Compare1_Index> (data, "StringRef_Compare1_Index"); if (!m || m == 3) bench<StringRef_CompareMemcmp> (data, "StringRef_CompareMemcmp"); if (!m || m == 4) bench<StringRef_Compare8_1_byUInt64> (data, "StringRef_Compare8_1_byUInt64"); if (!m || m == 5) bench<StringRef_Compare16_1_byMemcmp> (data, "StringRef_Compare16_1_byMemcmp"); if (!m || m == 6) bench<StringRef_Compare16_1_byUInt64_logicAnd>(data, "StringRef_Compare16_1_byUInt64_logicAnd"); if (!m || m == 7) bench<StringRef_Compare16_1_byUInt64_bitAnd> (data, "StringRef_Compare16_1_byUInt64_bitAnd"); #if __SSE4_1__ if (!m || m == 8) bench<StringRef_Compare16_1_byIntSSE> (data, "StringRef_Compare16_1_byIntSSE"); if (!m || m == 9) bench<StringRef_Compare16_1_byFloatSSE> (data, "StringRef_Compare16_1_byFloatSSE"); if (!m || m == 10) bench<StringRef_Compare16_1_bySSE4> (data, "StringRef_Compare16_1_bySSE4"); if (!m || m == 11) bench<StringRef_Compare16_1_bySSE4_wide> (data, "StringRef_Compare16_1_bySSE4_wide"); if (!m || m == 12) bench<StringRef_Compare16_1_bySSE_wide> (data, "StringRef_Compare16_1_bySSE_wide"); #endif if (!m || m == 100) bench<StringRef_CompareAlwaysTrue> (data, "StringRef_CompareAlwaysTrue"); if (!m || m == 101) bench<StringRef_CompareAlmostAlwaysTrue> (data, "StringRef_CompareAlmostAlwaysTrue"); /// 10 > 8, 9 /// 1, 2, 5 - bad return 0; }
void csv::boundary_scan(){ FILE *fp2; fp2 = fopen("script_jtag2.txt", "w"); fprintf(fp2,"cable jz47xx\n"); fprintf(fp2,"detect\n"); fprintf(fp2,"instruction CFG_OUT 000100 BYPASS\n"); fprintf(fp2,"instruction CFG_IN 000101 BYPASS\n"); fprintf(fp2,"instruction JSTART 001100 BYPASS\n"); fprintf(fp2,"instruction JPROGRAM 001011 BYPASS\n"); fprintf(fp2,"pld load /root/Generador_Script/pulsa.bit\n"); fprintf(fp2,"reset\n"); fprintf(fp2,"quit"); fclose(fp2); system("jtag script_jtag2.txt"); QStringList pin; QString signals_name1; QString line; QFile file(dir_csv.toAscii().data());// Lectura CSV if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ QMessageBox::about(this,"Error", "Error opening CSV file"); return; } QTextStream in(&file); QFile file2("register_out.txt"); if (!file2.open(QIODevice::ReadOnly | QIODevice::Text)){ QMessageBox::about(this,"Error", "Error opening UrJtag file"); return; } while (!in.atEnd()) { line = in.readLine(); if(line.contains("#",Qt::CaseInsensitive)!=true && line.isEmpty()!=true){ pin=line.split(","); if(pin[4]=="INPUT" || pin[4]=="OUTPUT" || pin[4]=="BIDIR"){ signals_name1=signals_name1.append(pin[1]+','); } } } signals_name=signals_name1.split(','); QTextStream in2(&file2); line=in2.readAll(); remove("register_out.txt"); registers=line.split("\n"); remove("script_jtag2.txt"); }
PassRefPtr<FilterEffect> SVGFEDisplacementMapElement::build(SVGFilterBuilder* filterBuilder) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); FilterEffect* input2 = filterBuilder->getEffectById(in2()); if (!input1 || !input2) return 0; return FEDisplacementMap::create(input1, input2, static_cast<ChannelSelectorType>(xChannelSelector()), static_cast<ChannelSelectorType>(yChannelSelector()), scale()); }
void System::updateProfileInterfaces(QString name) { QString pathString2; QTextStream pathStream2(&pathString2); pathStream2 << this->systemPath << "/profiles/" << name << "-interfaces.txt"; QFile currentProfileInterfaces(pathString2); currentProfileInterfaces.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream in2(¤tProfileInterfaces); int nrOfInterfaces = in2.readLine().toInt(); for (int i=0;i<nrOfInterfaces;i++) this->currentProfile->addInterface(in2.readLine()); currentProfileInterfaces.close(); }
void ReconstructionHandler::readMatchesFromFileAfterRansac(){ QString filePath1 = sceneModel->folderPath + "nmatches.ransac.txt"; QFile f1(filePath1); f1.open(QIODevice::ReadOnly); QTextStream in1(&f1); QString filePath2= sceneModel->folderPath + "matches.ransac.txt"; QFile f2(filePath2); f2.open(QIODevice::ReadOnly); QTextStream in2(&f2); QString line = in1.readLine(); int numImages = line.toInt(); for (int i=0; i<numImages; ++i){ line = in1.readLine(); QStringList fields = line.split(" "); for (int j=0; j<numImages; ++j){ std::vector< cv::DMatch > matches; int numberMatches = fields[j].toInt(); // If no matches - continue if (numberMatches==0) continue; //We want to read these matches from second file while (1){ QString lineMatches = in2.readLine(); if (lineMatches.length()==0) continue; // We have valid line QStringList fieldsMatches = lineMatches.split(" "); for (int k=0; k<numberMatches; ++k){ int matchIdx1 = fieldsMatches[2*k].toInt(); int matchIdx2 = fieldsMatches[2*k+1].toInt(); matches.push_back(cv::DMatch(matchIdx1, matchIdx2, 1.0)); } break; } sceneModel->addMatches(i, j, matches); std::vector<cv::DMatch> matchesFlipped = featureHandler->flipMatches(matches); sceneModel->addMatches(j, i,matchesFlipped); } } f1.close(); f2.close(); }
int main() { universe *u = new universe("patterns"); list *colors = new list(u); list *names = new list(u); list *grids = new list(u); grid *g; color24 *c24; char *s2 = new char[100], *s, *s3, *s4 = new char[100]; int rows, cols; strcpy(s2, "../A/patterns/"); s = s2 + strlen(s2); ifstream in ("../A/data/patterns"); in >> s; while (!in.eof()) { names->enqueue((item *) new ascii(u, s)); s3 = s + strlen(s); strcpy(s3, ".A"); ifstream in2 (s2); in2 >> rows >> cols >> s4; cout << "Opening \"" << s2 << "\" (" << rows << ", " << cols << ", " << s4 << ")." << endl; cout.flush(); c24 = new color24(s4); g = new grid(u, find_or_create(u, colors, c24), rows, cols); grids->enqueue((item *) g); delete c24; for (int i=0; i<rows; i++) { for (int j=0; j<cols; j++) { in2 >> s4; c24 = new color24(s4); g->set(i, j, find_or_create(u, colors, c24)); delete c24; } } in2.close(); in >> s; } in.close(); //*/ ofstream out ("patterns"); u->serialize(out); out.close(); //*/ delete u; }
bool SVGFECompositeElement::build(SVGResourceFilter* filterResource) { FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); FilterEffect* input2 = filterResource->builder()->getEffectById(in2()); if(!input1 || !input2) return false; RefPtr<FilterEffect> effect = FEComposite::create(input1, input2, static_cast<CompositeOperationType>(_operator()), k1(), k2(), k3(), k4()); filterResource->addFilterEffect(this, effect.release()); return true; }
bool SVGFECompositeElement::build(FilterBuilder* builder) { FilterEffect* input1 = builder->getEffectById(in1()); FilterEffect* input2 = builder->getEffectById(in2()); if(!input1 || !input2) return false; RefPtr<FilterEffect> addedEffect = FEComposite::create(input1, input2, static_cast<CompositeOperationType> (_operator()), k1(), k2(), k3(), k4()); builder->add(result(), addedEffect.release()); return true; }
int main(int argc, char* argv[]) { setbuf(stdout,NULL) ; init(argv, 0, 0, 0, true, false); double* data = (double*)malloc(4*sizeof(double)); data[0] = 10; data[1] = 20; data[2] = 30; data[3] = 40 ; input<double> in1(1, 1, 4, 1, "pvmtslave1"); input<double*> in2(2, 1, data, 4, "pvmtslave1"); input<double> in3(1, 2, 6, 1, "pvmtslave1"); bool is = INSTANTINATE(":prog1", "group1", 1, in1, in2); //is = SEND("", "pvmtslave", "group1", in1, in2); is = SEND("main:all_tasks.main.1:group1.prog1.pvmtslave.1", "group1", in3); //printlog(DEBUG, "instantinate returns %d\n", is); usleep(6000); input<double> in4_1(1, 1, 4, 1, "pvmtslave1"); input<double*> in5_2(2, 1, data, 4, "pvmtslave1"); is = SEND("main:all_tasks.main.1:group1.prog1.pvmtslave.1", "group1", in4_1, in5_2); free(data); //usleep(3000); //END("group1", true); //is = SEND("main", "group1.main:pvmtslave.1", "group1", in1, in2 ); //printlog(DEBUG, "SEND returns %d\n", is); /*is = SEND("main", "group1.main:pvmtslave.1", "group1", in2 ); printlog(DEBUG, "SEND returns %d\n", is);*/ //int slavetid = 321; //int input = 0 ; //double num = 6 ; ////gs_spawn("pvmtslave", argv, 0, "", 1, &slavetid) ; //gs_pack("%lf", 0, &num) ; //pvm_joingroup("group1"); ////pvm_initsend(PvmDataDefault) ; ////pvm_pkint(&input, 1, 1) ; ////pvm_pkdouble(&num, 1, 1) ; //pvm_send(slavetid, 1) ; //int bufid = pvm_recv(slavetid, 1) ; //pvm_upkdouble(&num, 1, 1) ; ////gs_unpack("lf", bufid, &num ) ; ////int info = pvm_catchout(stdout) ; ////info = pvm_spawn("pvmtslave",argv, 0, "", 1, &slavetid) ; //printf("num = %lf\n", num) ; //pvm_catchout(0) ; //pvm_kill(slavetid) ; ////pvm_exit() ; //system("pause") ; return 0; }
int main() { using vector_type = hpx::partitioned_vector<double>; const std::size_t height = 16; const std::size_t width = 16; std::size_t local_height = 16; std::size_t local_width = 16; std::size_t local_leading_dimension = local_height; std::size_t raw_size = (height * width) * (local_height * local_width); auto layout = hpx::container_layout(height * width, hpx::find_all_localities()); // Vector instantiations for test 1 vector_type in1(raw_size, layout); vector_type out1(raw_size, layout); std::string in1_name("in1"); std::string out1_name("out1"); in1.register_as(hpx::launch::sync, in1_name); out1.register_as(hpx::launch::sync, out1_name); // Vector instantiations for test 2 vector_type in2(raw_size, layout); vector_type out2(raw_size, layout); std::string in2_name("in2"); std::string out2_name("out2"); in2.register_as(hpx::launch::sync, in2_name); out2.register_as(hpx::launch::sync, out2_name); // Launch tests hpx::future<void> join1 = hpx::lcos::define_spmd_block("block1", 4, bulk_test_action(), height, width, local_height, local_width, local_leading_dimension, in1_name, out1_name); hpx::future<void> join2 = hpx::lcos::define_spmd_block("block2", 4, async_bulk_test_action(), height, width, local_height, local_width, local_leading_dimension, in2_name, out2_name); hpx::wait_all(join1, join2); return 0; }
bool SVGFEDisplacementMapElement::build(FilterBuilder* builder) { FilterEffect* input1 = builder->getEffectById(in1()); FilterEffect* input2 = builder->getEffectById(in2()); if(!input1 || !input2) return false; RefPtr<FilterEffect> addedEffect = FEDisplacementMap::create(input1, input2, static_cast<ChannelSelectorType> (xChannelSelector()), static_cast<ChannelSelectorType> (yChannelSelector()), scale()); builder->add(result(), addedEffect.release()); return true; }