//******************************************************************* // 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; }
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); };
PassRefPtr<FilterEffect> SVGFEComponentTransferElement::build(SVGFilterBuilder* filterBuilder) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); if (!input1) return 0; ComponentTransferFunction red; ComponentTransferFunction green; ComponentTransferFunction blue; ComponentTransferFunction alpha; for (Node* n = firstChild(); n != 0; n = n->nextSibling()) { if (n->hasTagName(SVGNames::feFuncRTag)) red = static_cast<SVGFEFuncRElement*>(n)->transferFunction(); else if (n->hasTagName(SVGNames::feFuncGTag)) green = static_cast<SVGFEFuncGElement*>(n)->transferFunction(); else if (n->hasTagName(SVGNames::feFuncBTag)) blue = static_cast<SVGFEFuncBElement*>(n)->transferFunction(); else if (n->hasTagName(SVGNames::feFuncATag)) alpha = static_cast<SVGFEFuncAElement*>(n)->transferFunction(); } return FEComponentTransfer::create(input1, red, green, blue, alpha); }
/** * @param in :: Input fitting parameter values * @param out :: Derivatives * @param xValues :: X values for data points * @param nData :: Number of data points */ void UserFunction1D::functionDeriv(const double* in, Jacobian* out, const double* xValues, const size_t nData) { //throw Exception::NotImplementedError("No derivative function provided"); if (nData == 0) return; std::vector<double> dp(m_nPars); std::vector<double> in1(m_nPars); for(int i=0;i<m_nPars;i++) { in1[i] = in[i]; m_parameters[i] = in[i]; if (m_parameters[i] != 0.0) dp[i] = m_parameters[i]*0.01; else dp[i] = 0.01; } if (!m_tmp) { m_tmp.reset(new double[nData]); m_tmp1.reset(new double[nData]); } function(in, m_tmp.get(),xValues, nData); for (int j = 0; j < m_nPars; j++) { in1[j] += dp[j]; function(&in1[0], m_tmp1.get(),xValues, nData); for (size_t i = 0; i < nData; i++) { out->set(i,j, (m_tmp1[i] - m_tmp[i])/dp[j]); } in1[j] -= dp[j]; } }
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; }
bool Csv::readFile() { QFile file(fullPath); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return false; QString str; QTextStream in; QTextStream in1(&file); str = in1.readAll(); file.close(); in.setString(&str); //set progressBar max value maxValueProgbar = str.length(); //Parser QStringList outList; LexerCsv mylex; connect(&mylex, SIGNAL(returnedToken(int)), this, SLOT(checkProgressStream(int)), Qt::DirectConnection); QString header = in.readLine(); if (header.startsWith("CALIBRATION VALUES V")) { char ch; //parse "Description Header" for "unit delimiter, string delimiter, comment in.seek(20); mylex.getNextToken(in); if (mylex.getToken() == Float) { mylex.getNextToken(in); if (mylex.getToken() == ValueSeparator && (mylex.getLexem() == "," || mylex.getLexem() == ";" || mylex.getLexem() == "\t")) { mylex.valueSeparator = mylex.getLexem().at(0); mylex.getNextToken(in); if (mylex.getToken() == Text && (mylex.getLexem() == "," || mylex.getLexem() == ".")) { mylex.decimalPointSeparator = mylex.getLexem().at(0); in >> ch; if (ch == mylex.valueSeparator) { in >> mylex.commentIndicator; in >> ch; if (ch == mylex.valueSeparator) { char c1, c2; in >> c1; in >> c2; if (c1 == c2) mylex.stringDelimiter = c1; else { showError("CSV description Header : parser error at line " + QString::number(mylex.getLine()) + " with lexem " + QString(mylex.getLexem().c_str())); return false; } }
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; }
// two instances of python processing processes should work TEST_F(SignalProcessingInterfaceTest, TwoInstanceTest) { SignalProcessingImpl* sp2 = new SignalProcessingImpl(); ASSERT_TRUE(sp2 != NULL); ASSERT_TRUE(sp2->init(SignalProcessingImpl::MAIN_PROCESSING_SCRIPT)); android::String8 functionName("intsum"); int nInputs = 2; int nOutputs = 1; bool inputTypes[2] = { false, false }; bool outputTypes[1] = { false }; TaskCase::Value in0((int64_t)10); TaskCase::Value in1((int64_t)100); void* inputs[2] = { &in0, &in1 }; TaskCase::Value out0((int64_t)0); void *outputs[1] = { &out0 }; ASSERT_TRUE(mSp->run( functionName, nInputs, inputTypes, inputs, nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK); ASSERT_TRUE(out0.getInt64() == (in0.getInt64() + in1.getInt64())); out0.setInt64(0); ASSERT_TRUE(sp2->run( functionName, nInputs, inputTypes, inputs, nOutputs, outputTypes, outputs) == TaskGeneric::EResultOK); ASSERT_TRUE(out0.getInt64() == (in0.getInt64() + in1.getInt64())); delete sp2; }
void server::textEdit(user *who, QList<QByteArray> comands) { int type; int coursorStart; int coursorEnd; int anchor; quint8 ct; QString diff; QList<QByteArray> comands1 = comands; QByteArray b; while(!comands1.isEmpty()){ b = comands1.takeAt(0); QDataStream in1(&b, QIODevice::ReadOnly); in1 >> ct >> type >> coursorStart >> coursorEnd >> anchor >> diff; file = updateText(file, (editType)type, coursorStart, coursorEnd, anchor, diff); } f->open(QIODevice::WriteOnly); f->write(file.toUtf8()); f->close(); QByteArray block; QDataStream out(&block, QIODevice::WriteOnly); out << user::list << comands; for (QList<user*>::iterator i = clients.begin(); i != clients.end(); ++i){ // Передаем изменения всем клиентам редактирующим текущий файл emit log ((*i)->getName() + " " + QString::number((int)(*i)->isAuthentificatedUser()) + " " + QString::number(type)+" "+QString::number(coursorStart)+" "+QString::number(coursorEnd)+" "+diff); if ((*i)->isAuthentificatedUser() && *i != who){ (*i)->getSocket()->write(block); } } }
/// \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; }
PassRefPtr<FilterEffect> SVGFEOffsetElement::build(SVGFilterBuilder* filterBuilder) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); if (!input1) return 0; return FEOffset::create(input1, dx(), dy()); }
/// \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); } }
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; }
PassRefPtr<FilterEffect> SVGFEGaussianBlurElement::build(SVGFilterBuilder* filterBuilder) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); if (!input1) return 0; return FEGaussianBlur::create(input1, stdDeviationX(), stdDeviationY()); }
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(); }
PassRefPtr<FilterEffect> SVGFEConvolveMatrixElement::build(SVGFilterBuilder* filterBuilder) { FilterEffect* input1 = filterBuilder->getEffectById(in1()); if (!input1) return 0; Vector<float> kernelMatrixValues; SVGNumberList* numbers = kernelMatrix(); ExceptionCode ec = 0; int numberOfItems = numbers->numberOfItems(); for (int i = 0; i < numberOfItems; ++i) kernelMatrixValues.append(numbers->getItem(i, ec)); int orderXValue = orderX(); int orderYValue = orderY(); if (!hasAttribute(SVGNames::orderAttr)) { orderXValue = 3; orderYValue = 3; } // The spec says this is a requirement, and should bail out if fails if (orderXValue * orderYValue != numberOfItems) return 0; int targetXValue = targetX(); int targetYValue = targetY(); if (hasAttribute(SVGNames::targetXAttr) && (targetXValue < 0 || targetXValue >= orderXValue)) return 0; // The spec says the default value is: targetX = floor ( orderX / 2 )) if (!hasAttribute(SVGNames::targetXAttr)) targetXValue = static_cast<int>(floorf(orderXValue / 2)); if (hasAttribute(SVGNames::targetYAttr) && (targetYValue < 0 || targetYValue >= orderYValue)) return 0; // The spec says the default value is: targetY = floor ( orderY / 2 )) if (!hasAttribute(SVGNames::targetYAttr)) targetYValue = static_cast<int>(floorf(orderYValue / 2)); float divisorValue = divisor(); if (hasAttribute(SVGNames::divisorAttr) && !divisorValue) return 0; if (!hasAttribute(SVGNames::divisorAttr)) { for (int i = 0; i < numberOfItems; ++i) divisorValue += kernelMatrixValues[i]; if (!divisorValue) divisorValue = 1; } RefPtr<FilterEffect> effect = FEConvolveMatrix::create( IntSize(orderXValue, orderYValue), divisorValue, bias(), IntPoint(targetXValue, targetYValue), static_cast<EdgeModeType>(edgeMode()), FloatPoint(kernelUnitLengthX(), kernelUnitLengthX()), preserveAlpha(), kernelMatrixValues); effect->inputEffects().append(input1); return effect.release(); }
// 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); }
bool SVGFETileElement::build(FilterBuilder* builder) { FilterEffect* input1 = builder->getEffectById(in1()); if(!input1) return false; builder->add(result(), FETile::create(input1)); return true; }
int main() { Instrument in1("gehbrkpegw"); Guitar in2; in1.makeSound(); in2.makeSound(); Instrument in[yoloVar]; for(int x=0;x<yoloVar;x++) in[x].makeSound(); } // main()
bool SVGFEGaussianBlurElement::build(FilterBuilder* builder) { FilterEffect* input1 = builder->getEffectById(in1()); if(!input1) return false; builder->add(result(), FEGaussianBlur::create(input1, stdDeviationX(), stdDeviationY())); return true; }
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()); }
bool SVGFETileElement::build(SVGResourceFilter* filterResource) { FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); if(!input1) return false; RefPtr<FilterEffect> effect = FETile::create(input1); filterResource->addFilterEffect(this, effect.release()); return true; }
Eigen::MatrixXd ptcloudFromCorrespondences(const std::string& correspondencesFilename, const std::string& extrinsicsFilename, const std::string& ptcloudFilename) { // THE UNDISTORTED POINTS (calibrated by K in P1, P2) std::ifstream in1(correspondencesFilename); if (in1.bad()) return Eigen::MatrixXd(1,3); unsigned int N = 0; char buf[256]; for (; in1.good(); N++) in1.getline(buf, 256); N--; // Advanced past for loop in1.close(); std::ifstream in(correspondencesFilename); if (in.bad()) return Eigen::MatrixXd(1, 3); char c; std::vector< cv::Point2d > x1v, x2v; for (unsigned int i = 0; i < N && !in.bad(); i++) { double x1x, x1y, x2x, x2y, max, qwx, qwy; in >> x1x >> c >> x1y >> c >> x2x >> c >> x2y >> c >> max >> c >> qwx >> c >> qwy; // Hardcoded threshold of .6, qw > .5 if ((max > .6))// && (qwx > .5) && (qwy > .5)) // if stabilization { x1v.push_back(cv::Point2d(x1x, x1y)); x2v.push_back(cv::Point2d(x2x, x2y)); } } Eigen::MatrixXd x1(2, x1v.size()); Eigen::MatrixXd x2(2, x2v.size()); unsigned int co = 0; for (std::vector<cv::Point2d>::iterator x1r = x1v.begin(), x2r = x2v.begin(); ((x1r != x1v.end()) && (x2r != x2v.end())); x1r++, x2r++, co++) { x1(0, co) = x1r->x; x1(1, co) = x1r->y; x2(0, co) = x2r->x; x2(1, co) = x2r->y; } Eigen::MatrixXd P1 = Eigen::MatrixXd::Identity(3, 4), P2 = Eigen::MatrixXd::Identity(3, 4); P2(0, 3) = 1.0; if (extrinsicsFilename != "") { std::ifstream extrinsicsFile(extrinsicsFilename); if (extrinsicsFile.bad()) return Eigen::MatrixXd(1, 3); double rx, ry, rz, tx, ty, tz; extrinsicsFile >> rx >> c >> ry >> c >> rz >> c; extrinsicsFile >> tx >> c >> ty >> c >> tz >> c; std::cout << "Getting extrinsics: " << rx << ',' << ry << ',' << rz << ',' << tx << ',' << ty << ',' << tz << std::endl; P2 = cameraMatrixKnownRT(rx, ry, rz, tx, ty, tz); }
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; }
bool SVGFEGaussianBlurElement::build(SVGResourceFilter* filterResource) { FilterEffect* input1 = filterResource->builder()->getEffectById(in1()); if (!input1) return false; RefPtr<FilterEffect> effect = FEGaussianBlur::create(input1, stdDeviationX(), stdDeviationY()); filterResource->addFilterEffect(this, effect.release()); return true; }
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 middle3::timer_update_currentTabInfo() { myThread1->start("bash modify.sh"); if(!myThread1->waitForStarted()) { qDebug()<<"failed start!"; } while(true == myThread1->waitForFinished()); { QString ver1 = myThread1->readAllStandardOutput(); time->setText(ver1); } myThread->start("bash ps-file.sh"); if(!myThread->waitForStarted()) { qDebug()<<"failed start!"; } while(true == myThread->waitForFinished()); { bool ok2; QString ver = myThread->readAllStandardOutput(); int dec = ver.toInt(&ok2,10); if(dec >=1) { QFile fromFile1("/tmp/filenum.sh"); fromFile1.open(QIODevice::ReadOnly); QTextStream in1(&fromFile1); while(!in1.atEnd()) { line = in1.readLine(); } } } if((line.toInt() == 0 || line.toInt() > temp) && flag == 1) { result_label1->setText("查杀中,请稍后。。。"); temp++; char str[10]; QString str1; sprintf(str,"%d",temp); str1 = str; safnum->setText(str1); } if(line.toInt() == temp && temp != 0) { result_label1->setText("无病毒文件,亲可以放心啦~"); } }