这篇教程C++ work函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中work函数的典型用法代码示例。如果您正苦于以下问题:C++ work函数的具体用法?C++ work怎么用?C++ work使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了work函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: num_threadsvoid S<T>::test(){ #pragma omp parallel num_threads(n) // { dg-error "must be integral" } work();}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.toolchain,代码行数:5,
示例2: cloud_in/* * Receive callback for the /camera/depth_registered/points subscription */std::vector<suturo_perception_msgs::PerceivedObject> SuturoPerceptionKnowledgeROSNode::receive_image_and_cloud(const sensor_msgs::ImageConstPtr& inputImage, const sensor_msgs::PointCloud2ConstPtr& inputCloud){ // process only one cloud pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_in (new pcl::PointCloud<pcl::PointXYZRGB>()); pcl::fromROSMsg(*inputCloud,*cloud_in); logger.logInfo((boost::format("Received a new point cloud: size = %s") % cloud_in->points.size()).str()); // Gazebo sends us unorganized pointclouds! // Reorganize them to be able to compute the ROI of the objects // This workaround is only tested for gazebo 1.9! if(!cloud_in->isOrganized ()) { logger.logInfo((boost::format("Received an unorganized PointCloud: %d x %d .Convert it to a organized one ...") % cloud_in->width % cloud_in->height ).str()); pcl::PointCloud<pcl::PointXYZRGB>::Ptr org_cloud (new pcl::PointCloud<pcl::PointXYZRGB>()); org_cloud->width = 640; org_cloud->height = 480; org_cloud->is_dense = false; org_cloud->points.resize(640 * 480); for (int i = 0; i < cloud_in->points.size(); i++) { pcl::PointXYZRGB result; result.x = 0; result.y = 0; result.z = 0; org_cloud->points[i]=cloud_in->points[i]; } cloud_in = org_cloud; } cv_bridge::CvImagePtr cv_ptr; cv_ptr = cv_bridge::toCvCopy(inputImage, enc::BGR8); // Make a deep copy of the passed cv::Mat and set a new // boost pointer to it. boost::shared_ptr<cv::Mat> img(new cv::Mat(cv_ptr->image.clone())); sp.setOriginalRGBImage(img); logger.logInfo("processing..."); sp.setOriginalCloud(cloud_in); sp.processCloudWithProjections(cloud_in); logger.logInfo("Cloud processed. Lock buffer and return the results"); mutex.lock(); perceivedObjects = sp.getPerceivedObjects(); if(sp.getOriginalRGBImage()->cols != sp.getOriginalCloud()->width && sp.getOriginalRGBImage()->rows != sp.getOriginalCloud()->height) { // Adjust the ROI if the image is at 1280x1024 and the pointcloud is at 640x480 if(sp.getOriginalRGBImage()->cols == 1280 && sp.getOriginalRGBImage()->rows == 1024) { for (int i = 0; i < perceivedObjects.size(); i++) { ROI roi = perceivedObjects.at(i).get_c_roi(); roi.origin.x*=2; roi.origin.y*=2; roi.width*=2; roi.height*=2; perceivedObjects.at(i).set_c_roi(roi); } } else { logger.logError("UNSUPPORTED MIXTURE OF IMAGE AND POINTCLOUD DIMENSIONS"); } } // Execution pipeline // Each capability provides an enrichment for the // returned PerceivedObject // initialize threadpool boost::asio::io_service ioService; boost::thread_group threadpool; std::auto_ptr<boost::asio::io_service::work> work(new boost::asio::io_service::work(ioService)); // Add worker threads to threadpool for(int i = 0; i < numThreads; ++i) { threadpool.create_thread( boost::bind(&boost::asio::io_service::run, &ioService) ); } for (int i = 0; i < perceivedObjects.size(); i++) { // Initialize Capabilities ColorAnalysis ca(perceivedObjects[i]); ca.setLowerSThreshold(color_analysis_lower_s); ca.setUpperSThreshold(color_analysis_upper_s); ca.setLowerVThreshold(color_analysis_lower_v); ca.setUpperVThreshold(color_analysis_upper_v); suturo_perception_shape_detection::RandomSampleConsensus sd(perceivedObjects[i]); //suturo_perception_vfh_estimation::VFHEstimation vfhe(perceivedObjects[i]); // suturo_perception_3d_capabilities::CuboidMatcherAnnotator cma(perceivedObjects[i]); // Init the cuboid matcher with the table coefficients//.........这里部分代码省略.........
开发者ID:SUTURO,项目名称:suturo_perception,代码行数:101,
示例3: mainint main(){ init(); work(); return 0;}
开发者ID:dementrock,项目名称:acm,代码行数:6,
示例4: HibernateBootvoid HibernateBoot(char *image_filename){ long long size, imageSize, codeSize, allocSize; long mem_base; IOHibernateImageHeader _header; IOHibernateImageHeader * header = &_header; long buffer; size = ReadFileAtOffset (image_filename, header, 0, sizeof(IOHibernateImageHeader)); printf("header read size %x/n", size); imageSize = header->image1Size; codeSize = header->restore1PageCount << 12; if (kIOHibernateHeaderSignature != header->signature) { printf ("Incorrect image signature/n"); return; } if (header->encryptStart) { printf ("Resuming from Encrypted image is unsupported./n" "Uncheck /"Use secure virtual memory/" in /"Security/" pane on system preferences./n" "Press any key to proceed with normal boot./n"); getc (); return; }// depends on NVRAM#if 0 { uint32_t machineSignature; size = GetProp(gChosenPH, kIOHibernateMachineSignatureKey, (char *)&machineSignature, sizeof(machineSignature)); if (size != sizeof(machineSignature)) machineSignature = 0; if (machineSignature != header->machineSignature) break; }#endif allocSize = imageSize + ((4095 + sizeof(hibernate_graphics_t)) & ~4095); mem_base = getmemorylimit() - allocSize;//TODO: lower this printf("mem_base %x/n", mem_base); if (!((long long)mem_base+allocSize<1024*bootInfo->extmem+0x100000)) { printf ("Not enough space to restore image. Press any key to proceed with normal boot./n"); getc (); return; } bcopy(header, (void *) mem_base, sizeof(IOHibernateImageHeader)); header = (IOHibernateImageHeader *) mem_base; imageSize -= sizeof(IOHibernateImageHeader); buffer = (long)(header + 1); if (header->previewSize) { uint64_t preview_offset = header->fileExtentMapSize - sizeof(header->fileExtentMap) + codeSize; uint8_t progressSaveUnder[kIOHibernateProgressCount][kIOHibernateProgressSaveUnderSize]; ReadFileAtOffset (image_filename, (char *)buffer, sizeof(IOHibernateImageHeader), preview_offset+header->previewSize); drawPreview ((void *)(long)(buffer+preview_offset + header->previewPageListSize), &(progressSaveUnder[0][0])); previewTotalSectors = (imageSize-(preview_offset+header->previewSize))/512; previewLoadedSectors = 0; previewSaveunder = &(progressSaveUnder[0][0]); if (preview_offset+header->previewSize<imageSize) ReadFileAtOffset (image_filename, (char *)(long)(buffer+preview_offset+header->previewSize), sizeof(IOHibernateImageHeader)+preview_offset+header->previewSize, imageSize-(preview_offset+header->previewSize)); previewTotalSectors = 0; previewLoadedSectors = 0; previewSaveunder = 0; #if 0 AsereBLN: check_vga_nvidia() didn't work as expected (recursion level > 0 & return value). Unforutnaltely I cannot find a note why to switch back to text mode for nVidia cards only and because it check_vga_nvidia does not work (cards normally are behind a bridge) I will remove it completely setVideoMode( VGA_TEXT_MODE, 0 );#endif }
开发者ID:AlexSeverinov,项目名称:Chameleon,代码行数:83,
示例5: new_work_agg // a new aggregate is to be inserted into the work queue inline void new_work_agg(db::node *node, db::simple_tuple *stpl) { process::work work(node, stpl, process::mods::LOCAL_TUPLE | process::mods::FORCE_AGGREGATE); new_agg(work); }
开发者ID:adikolo,项目名称:visiblesim,代码行数:6,
示例6: GetNcoeffs//.........这里部分代码省略......... /// we simulate the multiplication by the identity matrix. /// The results stored in outarray is one of the columns of the weak advection oprators /// which are then stored in MATRIX for the futher eigenvalues calculation. switch (m_projectionType) { case MultiRegions::eDiscontinuous: { WeakDGAdvection(inarray, WeakAdv,true,true,1); m_fields[0]->MultiplyByElmtInvMass(WeakAdv[0],WeakAdv[0]); m_fields[0]->BwdTrans(WeakAdv[0],outarray[0]); Vmath::Neg(npoints,outarray[0],1); break; } case MultiRegions::eGalerkin: case MultiRegions::eMixed_CG_Discontinuous: { // Calculate -V/cdot Grad(u); for(i = 0; i < nvariables; ++i) { //Projection m_fields[i]->FwdTrans(inarray[i],WeakAdv[i]); m_fields[i]->BwdTrans_IterPerExp(WeakAdv[i],tmp[i]); //Advection operator AdvectionNonConservativeForm(m_velocity,tmp[i],outarray[i]); Vmath::Neg(npoints,outarray[i],1); //m_fields[i]->MultiplyByInvMassMatrix(WeakAdv[i],WeakAdv[i]); //Projection m_fields[i]->FwdTrans(outarray[i],WeakAdv[i]); m_fields[i]->BwdTrans_IterPerExp(WeakAdv[i],outarray[i]); } break; } } /// The result is stored in outarray (is the j-th columns of the weak advection operator). /// We now store it in MATRIX(j) Vmath::Vcopy(npoints,&(outarray[0][0]),1,&(MATRIX[j]),npoints); /// Set the j-th entry of inarray back to zero inarray[0][j] = 0.0; } //////////////////////////////////////////////////////////////////////////////// /// Calulating the eigenvalues of the weak advection operator stored in (MATRIX) /// using Lapack routines char jobvl = 'N'; char jobvr = 'N'; int info = 0, lwork = 3*npoints; NekDouble dum; Array<OneD, NekDouble> EIG_R(npoints); Array<OneD, NekDouble> EIG_I(npoints); Array<OneD, NekDouble> work(lwork); Lapack::Dgeev(jobvl,jobvr,npoints,MATRIX.get(),npoints,EIG_R.get(),EIG_I.get(),&dum,1,&dum,1,&work[0],lwork,info); //////////////////////////////////////////////////////// //Print Matrix FILE *mFile; mFile = fopen ("WeakAdvMatrix.txt","w"); for(int j = 0; j<npoints; j++) { for(int k = 0; k<npoints; k++) { fprintf(mFile,"%e ",MATRIX[j*npoints+k]); } fprintf(mFile,"/n"); } fclose (mFile); //////////////////////////////////////////////////////// //Output of the EigenValues FILE *pFile; pFile = fopen ("Eigenvalues.txt","w"); for(int j = 0; j<npoints; j++) { fprintf(pFile,"%e %e/n",EIG_R[j],EIG_I[j]); } fclose (pFile); cout << "/nEigenvalues : " << endl; for(int j = 0; j<npoints; j++) { cout << EIG_R[j] << "/t" << EIG_I[j] << endl; } cout << endl; }
开发者ID:certik,项目名称:nektar,代码行数:101,
示例7: mainint main(){ while (work()); return 0;}
开发者ID:Cathy-ye,项目名称:NOIP-openjudge,代码行数:5,
示例8: fscanfvoid Solve::solve(FILE *fin, FILE *fout){ int cnt = 1; for(int i = 0; i <= 10; i ++, cnt *= 2) lb[cnt] = i; fscanf(fin, "%d%d", &n, &m); for(int i = 1; i <= n; i ++) for(int j = 1; j <= m; j ++) fscanf(fin, "%d", &object[i][j].a); for(int i = 1; i <= n; i ++) for(int j = 1; j <= m; j ++) fscanf(fin, "%d", &object[i][j].d); for(int i = 1; i <= n; i ++) for(int j = 1; j <= m; j ++) fscanf(fin, "%d", &object[i][j].hp); fscanf(fin, "%d%d%d", &llx.a, &llx.d, &llx.hp); fscanf(fin, "%d", &nBaby); for(int i = 1; i <= nBaby; i ++) fscanf(fin, "%d%d%d", &baby[i].a, &baby[i].d, &baby[i].hp); for(int i = 1; i <= n; i ++) for(int j = 1; j <= m; j ++) { Stuff &lyd = object[i][j]; if(llx.a <= lyd.d) w[i][j][0] = INFINITY; else { int t1 = ceilDiv(lyd.hp, llx.a-lyd.d); int tmp = (t1 - 1) * MAX(0, lyd.a - llx.d); if(tmp >= llx.hp) w[i][j][0] = INFINITY; else w[i][j][0] = tmp; } for(int k = 1; k <= nBaby; k ++) { Stuff &bb = baby[k]; if(bb.a <= lyd.d) w[i][j][k] = INFINITY; else { int t1 = ceilDiv(lyd.hp, bb.a - lyd.d); int tmp = (t1 - 1) * MAX(0, lyd.a - bb.d); if(tmp >= bb.hp) { int t2 = ceilDiv(bb.hp, lyd.a - bb.d); tmp = t2 * MAX(0, bb.a - lyd.d); //baby died if(llx.a <= lyd.d) w[i][j][k] = INFINITY; else { int t1 = ceilDiv(lyd.hp - tmp, llx.a-lyd.d); tmp = (t1 - 1) * MAX(0, lyd.a - llx.d); if(tmp >= llx.hp) w[i][j][k] = INFINITY; else w[i][j][k] = tmp; } } else w[i][j][k] = 0; } } } upperlim = (1 << nBaby) - 1; work(fin, fout);}
开发者ID:alxsoares,项目名称:OI,代码行数:68,
示例9: mainint main(int argc, char **argv){ // Add some plugin searhc paths plugin_search_path=list_new(free); const char *infilename=NULL; const char *outfilename=NULL; char tmp[256]; char *assetfilename="assets.h"; int i; for (i=1;i<argc;i++){ if (strcmp(argv[i], "--help")==0){ help(NULL); return 0; } else if ((strcmp(argv[i], "--templatetagsdir")==0) || (strcmp(argv[i], "-t")==0)){ i++; if (argc<=i){ help("Missing templatedir name"); return 3; } snprintf(tmp, sizeof(tmp), "%s/lib%%s.so", argv[i]); ONION_DEBUG("Added templatedir %s", tmp); list_add(plugin_search_path, strdup(tmp)); // dup, remember to free later. } else if ((strcmp(argv[i], "--no-orig-lines")==0) || (strcmp(argv[i], "-n")==0)){ use_orig_line_numbers=0; ONION_DEBUG("Disable original line numbers"); } else if ((strcmp(argv[i], "--asset-file")==0) || (strcmp(argv[i], "-a")==0)){ i++; if (argc<=i){ help("Missing assets file name"); return 3; } assetfilename=argv[i]; ONION_DEBUG("Assets file: %s", assetfilename); } else{ if (infilename){ if (outfilename){ help("Too many arguments"); return 1; } outfilename=argv[i]; ONION_DEBUG("Set outfilename %s", outfilename); } else{ infilename=argv[i]; ONION_DEBUG("Set infilename %s", infilename); } } } if (!infilename || !outfilename){ help("Missing input or output filename"); return 2; } if (strcmp(infilename,"-")==0){ infilename=""; } else{ char tmp2[256]; strncpy(tmp2, argv[1], sizeof(tmp2)-1); snprintf(tmp, sizeof(tmp), "%s/lib%%s.so", dirname(tmp2)); list_add(plugin_search_path, strdup(tmp)); strncpy(tmp2, argv[1], sizeof(tmp2)-1); snprintf(tmp, sizeof(tmp), "%s/templatetags/lib%%s.so", dirname(tmp2)); list_add(plugin_search_path, strdup(tmp)); } // Default template dirs list_add_with_flags(plugin_search_path, "lib%s.so", LIST_ITEM_NO_FREE); list_add_with_flags(plugin_search_path, "templatetags/lib%s.so", LIST_ITEM_NO_FREE); char tmp2[256]; strncpy(tmp2, argv[0], sizeof(tmp2)-1); snprintf(tmp, sizeof(tmp), "%s/templatetags/lib%%s.so", dirname(tmp2)); list_add(plugin_search_path, strdup(tmp)); // dupa is ok, as im at main. strncpy(tmp2, argv[0], sizeof(tmp2)-1); snprintf(tmp, sizeof(tmp), "%s/lib%%s.so", dirname(tmp2)); list_add(plugin_search_path, strdup(tmp)); // dupa is ok, as im at main. list_add_with_flags(plugin_search_path, "/usr/local/lib/otemplate/templatetags/lib%s.so", LIST_ITEM_NO_FREE); list_add_with_flags(plugin_search_path, "/usr/lib/otemplate/templatetags/lib%s.so", LIST_ITEM_NO_FREE); onion_assets_file *assetsfile=onion_assets_file_new(assetfilename); int error=work(infilename, outfilename, assetsfile); onion_assets_file_free(assetsfile); list_free(plugin_search_path); return error;}
开发者ID:anuragagarwal561994,项目名称:onion,代码行数:93,
示例10: main//.........这里部分代码省略......... { schema_registrys.push_back(csi::kafka::broker_address(i->host_name, schema_registry_port)); } } // right now the schema registry class cannot handle severel hosts so just stick to the first one. used_schema_registry = schema_registrys[0].host_name + ":" + std::to_string(schema_registrys[0].port); std::string kafka_broker_str = ""; for (std::vector<csi::kafka::broker_address>::const_iterator i = kafka_brokers.begin(); i != kafka_brokers.end(); ++i) { kafka_broker_str += i->host_name + ":" + std::to_string(i->port); if (i != kafka_brokers.end() - 1) kafka_broker_str += ", "; } BOOST_LOG_TRIVIAL(info) << "kafka broker(s): " << kafka_broker_str; BOOST_LOG_TRIVIAL(info) << "topic : " << topic; std::string schema_registrys_info; for (std::vector<csi::kafka::broker_address>::const_iterator i = schema_registrys.begin(); i != schema_registrys.end(); ++i) { schema_registrys_info += i->host_name + ":" + std::to_string(i->port); if (i != schema_registrys.end() - 1) schema_registrys_info += ", "; } BOOST_LOG_TRIVIAL(info) << "schema_registry(s) : " << schema_registrys_info; BOOST_LOG_TRIVIAL(info) << "used schema registry: " << used_schema_registry; int64_t total = 0; boost::asio::io_service fg_ios; std::auto_ptr<boost::asio::io_service::work> work(new boost::asio::io_service::work(fg_ios)); boost::thread fg(boost::bind(&boost::asio::io_service::run, &fg_ios)); csi::kafka::highlevel_producer producer(fg_ios, topic, -1, 200, 1000000); confluent::registry registry(fg_ios, used_schema_registry); confluent::codec avro_codec(registry); producer.connect(kafka_brokers); BOOST_LOG_TRIVIAL(info) << "connected to kafka"; producer.connect_forever(kafka_brokers); boost::thread do_log([&producer] { while (true) { boost::this_thread::sleep(boost::posix_time::seconds(1)); std::vector<csi::kafka::highlevel_producer::metrics> metrics = producer.get_metrics(); size_t total_queue = 0; uint32_t tx_msg_sec_total = 0; uint32_t tx_kb_sec_total = 0; for (std::vector<csi::kafka::highlevel_producer::metrics>::const_iterator i = metrics.begin(); i != metrics.end(); ++i) { total_queue += (*i).msg_in_queue; tx_msg_sec_total += (*i).tx_msg_sec; tx_kb_sec_total += (*i).tx_kb_sec; } BOOST_LOG_TRIVIAL(info) << "/t /tqueue:" << total_queue << "/t" << tx_msg_sec_total << " msg/s /t" << (tx_kb_sec_total / 1024) << "MB/s"; } });
开发者ID:bitbouncer,项目名称:csi-samples,代码行数:65,
示例11: mainint main(){ read(); work(); return 0;}
开发者ID:fanzhongrui,项目名称:ACMICPCSolutions,代码行数:6,
示例12: Basis_HGRAD_LINE_Cn_FEM Basis_HGRAD_LINE_Cn_FEM<SpT,OT,PT>:: Basis_HGRAD_LINE_Cn_FEM( const ordinal_type order, const EPointType pointType ) { this->basisCardinality_ = order+1; this->basisDegree_ = order; this->basisCellTopology_ = shards::CellTopology(shards::getCellTopologyData<shards::Line<2> >() ); this->basisType_ = BASIS_FEM_FIAT; this->basisCoordinates_ = COORDINATES_CARTESIAN; const ordinal_type card = this->basisCardinality_; // points are computed in the host and will be copied Kokkos::DynRankView<typename scalarViewType::value_type,typename SpT::array_layout,Kokkos::HostSpace> dofCoords("Hgrad::Line::Cn::dofCoords", card, 1); switch (pointType) { case POINTTYPE_EQUISPACED: case POINTTYPE_WARPBLEND: { // lattice ordering { const ordinal_type offset = 0; PointTools::getLattice( dofCoords, this->basisCellTopology_, order, offset, pointType ); } // topological order // { // // two vertices // dofCoords(0,0) = -1.0; // dofCoords(1,0) = 1.0; // // internal points // typedef Kokkos::pair<ordinal_type,ordinal_type> range_type; // auto pts = Kokkos::subview(dofCoords, range_type(2, card), Kokkos::ALL()); // const auto offset = 1; // PointTools::getLattice( pts, // this->basisCellTopology_, // order, offset, // pointType ); // } break; } case POINTTYPE_GAUSS: { // internal points only PointTools::getGaussPoints( dofCoords, order ); break; } default: { INTREPID2_TEST_FOR_EXCEPTION( !isValidPointType(pointType), std::invalid_argument , ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM) invalid pointType." ); } } this->dofCoords_ = Kokkos::create_mirror_view(typename SpT::memory_space(), dofCoords); Kokkos::deep_copy(this->dofCoords_, dofCoords); // form Vandermonde matrix; actually, this is the transpose of the VDM, // this matrix is used in LAPACK so it should be column major and left layout const ordinal_type lwork = card*card; Kokkos::DynRankView<typename scalarViewType::value_type,Kokkos::LayoutLeft,Kokkos::HostSpace> vmat("Hgrad::Line::Cn::vmat", card, card), work("Hgrad::Line::Cn::work", lwork), ipiv("Hgrad::Line::Cn::ipiv", card); const double alpha = 0.0, beta = 0.0; Impl::Basis_HGRAD_LINE_Cn_FEM_JACOBI:: getValues<Kokkos::HostSpace::execution_space,Parameters::MaxNumPtsPerBasisEval> (vmat, dofCoords, order, alpha, beta, OPERATOR_VALUE); ordinal_type info = 0; Teuchos::LAPACK<ordinal_type,typename scalarViewType::value_type> lapack; lapack.GETRF(card, card, vmat.data(), vmat.stride_1(), (ordinal_type*)ipiv.data(), &info); INTREPID2_TEST_FOR_EXCEPTION( info != 0, std::runtime_error , ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM) lapack.GETRF returns nonzero info." ); lapack.GETRI(card, vmat.data(), vmat.stride_1(), (ordinal_type*)ipiv.data(), work.data(), lwork, &info); INTREPID2_TEST_FOR_EXCEPTION( info != 0, std::runtime_error , ">>> ERROR: (Intrepid2::Basis_HGRAD_LINE_Cn_FEM) lapack.GETRI returns nonzero info." ); // create host mirror Kokkos::DynRankView<typename scalarViewType::value_type,typename SpT::array_layout,Kokkos::HostSpace> vinv("Hgrad::Line::Cn::vinv", card, card);//.........这里部分代码省略.........
开发者ID:brian-kelley,项目名称:Trilinos,代码行数:101,
示例13: BCsvoid PBCmgr::maintain (const int_t step , const Field* P , const AuxField** Us , const AuxField** Uf , const bool timedep)// ---------------------------------------------------------------------------// Update storage for evaluation of high-order pressure boundary// condition. Storage order for each edge represents a CCW traverse// of element boundaries.//// If the velocity field varies in time on HOPB field boundaries// (e.g. due to time-varying BCs) the local fluid acceleration will be// estimated from input velocity fields by explicit extrapolation if// timedep is true. This correction cannot be carried out at the// first timestep, since the required extrapolation cannot be done.// If the acceleration is known, (for example, a known reference frame// acceleration) it is probably better to leave timedep unset, and to// use PBCmgr::accelerate() to add in the accelerative term. Note// also that since grad P is dotted with n, the unit outward normal,// at a later stage, timedep only needs to be set if there are// wall-normal accelerative terms. NB: The default value of timedep// is 1.//// Field* master gives a list of pressure boundary conditions with// which to traverse storage areas (note this assumes equal-order// interpolations).//// No smoothing is done to high-order spatial derivatives computed here.// ---------------------------------------------------------------------------{ const real_t nu = Femlib::value ("KINVIS"); const real_t invDt = 1.0 / Femlib::value ("D_T"); const int_t nTime = Femlib::ivalue ("N_TIME"); const int_t nEdge = P -> _nbound; const int_t nZ = P -> _nz; const int_t nP = Geometry::nP(); const int_t base = Geometry::baseMode(); const int_t nMode = Geometry::nModeProc(); const int_t mLo = (Geometry::procID() == 0) ? 1 : 0; const AuxField* Ux = Us[0]; const AuxField* Uy = Us[1]; const AuxField* Uz = (nZ > 1) ? Us[2] : 0; const AuxField* Nx = Uf[0]; const AuxField* Ny = Uf[1]; const vector<Boundary*>& BC = P -> _bsys -> BCs (0); register Boundary* B; register int_t i, k, q; int_t m, offset, skip, Je; // -- Roll grad P storage area up, load new level of nonlinear terms Uf. rollv (_Pnx, nTime); rollv (_Pny, nTime); for (i = 0; i < nEdge; i++) { B = BC[i]; offset = B -> dOff (); skip = B -> dSkip(); for (k = 0; k < nZ; k++) { ROOTONLY if (k == 1) continue; Veclib::copy (nP, Nx -> _plane[k] + offset, skip, _Pnx[0][i][k], 1); Veclib::copy (nP, Ny -> _plane[k] + offset, skip, _Pny[0][i][k], 1); // -- For cylindrical coordinates, N_ are radius-premultiplied. Cancel. if (Geometry::cylindrical()) { B -> divY (_Pnx[0][i][k]); B -> divY (_Pny[0][i][k]); } } } // -- Add in -nu * curl curl u. vector<real_t> work (5 * sqr(nP) + 7 * nP + Integration::OrderMax + 1); real_t *UxRe, *UxIm, *UyRe, *UyIm, *UzRe, *UzIm, *tmp; real_t* wrk = &work[0]; real_t* xr = wrk + 5*sqr(nP) + 3*nP; real_t* xi = xr + nP; real_t* yr = xi + nP; real_t* yi = yr + nP; real_t* alpha = yi + nP; for (i = 0; i < nEdge; i++) { B = BC[i]; offset = B -> dOff (); skip = B -> dSkip(); ROOTONLY { // -- Deal with 2D/zero Fourier mode terms. UxRe = Ux -> _plane[0]; UyRe = Uy -> _plane[0]; B -> curlCurl (0,UxRe,0,UyRe,0,0,0,xr,0,yr,0,wrk); Blas::axpy (nP, -nu, xr, 1, _Pnx[0][i][0], 1); Blas::axpy (nP, -nu, yr, 1, _Pny[0][i][0], 1);//.........这里部分代码省略.........
开发者ID:jueqingsizhe66,项目名称:MrWang,代码行数:101,
示例14: workvoido3d3xx::FrameGrabber::Run(){ boost::asio::io_service::work work(this->io_service_); // // setup the camera for image acquistion // std::string cam_ip; int cam_port; try { cam_ip = this->cam_->GetIP(); cam_port = std::stoi(this->cam_->GetParameter("PcicTcpPort")); } catch (const o3d3xx::error_t& ex) { LOG(ERROR) << "Could not get IP/Port of the camera: " << ex.what(); return; } LOG(INFO) << "Camera connection info: ip=" << cam_ip << ", port=" << cam_port; try { this->cam_->RequestSession(); this->cam_->SetOperatingMode(o3d3xx::Camera::operating_mode::RUN); this->cam_->CancelSession(); } catch (const o3d3xx::error_t& ex) { LOG(ERROR) << "Failed to setup camera for image acquisition: " << ex.what(); return; } // // init the asio structures // boost::asio::ip::tcp::socket sock(this->io_service_); boost::asio::ip::tcp::endpoint endpoint( boost::asio::ip::address::from_string(cam_ip), cam_port); // // Forward declare our read handlers (because they need to call // eachother). // o3d3xx::FrameGrabber::WriteHandler result_schema_write_handler; o3d3xx::FrameGrabber::ReadHandler ticket_handler; o3d3xx::FrameGrabber::ReadHandler image_handler; // // image data callback // std::size_t bytes_read = 0; std::size_t buff_sz = 0; // bytes image_handler = [&, this] (const boost::system::error_code& ec, std::size_t bytes_transferred) { if (ec) { throw o3d3xx::error_t(ec.value()); } bytes_read += bytes_transferred; //DLOG(INFO) << "Read " << bytes_read << " image bytes of " // << buff_sz; if (bytes_read == buff_sz) { DLOG(INFO) << "Got full image!"; bytes_read = 0; // 1. verify the data if (o3d3xx::verify_image_buffer(this->back_buffer_)) { DLOG(INFO) << "Image OK"; // 2. move the data to the front buffer in O(1) time complexity this->front_buffer_mutex_.lock(); this->back_buffer_.swap(this->front_buffer_); this->front_buffer_mutex_.unlock(); // 3. notify waiting clients this->front_buffer_cv_.notify_all(); } else { LOG(WARNING) << "Bad image!"; } // read another ticket sock.async_read_some( boost::asio::buffer(this->ticket_buffer_.data(), o3d3xx::IMG_TICKET_SZ), ticket_handler); return; }//.........这里部分代码省略.........
开发者ID:bigcmos,项目名称:libo3d3xx,代码行数:101,
示例15: mainint main(int argc, char *argv[]){ const char *url; int i, threads; pthread_t *t; int *args; lList *answer_list = NULL; lListElem *spooling_context; DENTER_MAIN(TOP_LAYER, "test_berkeleydb_mt"); /* parse commandline parameters */ if (argc < 3) { ERROR((SGE_EVENT, "usage: test_berkeleydb_mt <url> <threads> [<delay>]/n")); ERROR((SGE_EVENT, " <url> = path or host:database/n")); ERROR((SGE_EVENT, " <threads> = number of threads/n")); ERROR((SGE_EVENT, " <delay> = delay after writing [ms]/n")); SGE_EXIT(NULL, 1); } url = argv[1]; threads = atoi(argv[2]); if (argc > 3) { delay = atoi(argv[3]); } /* allocate memory for pthreads and arguments */ t = (pthread_t *)malloc(threads * sizeof(pthread_t)); args = (int *)malloc(threads * sizeof(int)); DPRINTF(("writing to database %s from %d threads/n", url, threads)); /* initialize spooling */ spooling_context = spool_create_dynamic_context(&answer_list, NULL, url, NULL); answer_list_output(&answer_list); if (spooling_context == NULL) { SGE_EXIT(NULL, EXIT_FAILURE); } spool_set_default_context(spooling_context); if (!spool_startup_context(&answer_list, spooling_context, true)) { answer_list_output(&answer_list); SGE_EXIT(NULL, EXIT_FAILURE); } answer_list_output(&answer_list); /* let n threads to parallel spooling */ for (i = 0; i < threads; i++) { args[i] = i + 1; pthread_create(&(t[i]), NULL, work, (void*)(&args[i])); } /* also work in current thread */ work((void *)0); /* wait for termination of all threads */ for (i = 0; i < threads; i++) { pthread_join(t[i], NULL); } /* shutdown spooling */ spool_shutdown_context(&answer_list, spooling_context); answer_list_output(&answer_list); sge_free(&t); DEXIT; return EXIT_SUCCESS;}
开发者ID:valhallasw,项目名称:son-of-gridengine,代码行数:72,
示例16: sumNumbers int sumNumbers(TreeNode *root) { int ret = 0; //travel all the path work(root, ret, 0); return ret; }
开发者ID:klion26,项目名称:LeetCode,代码行数:6,
示例17: magma_ztrevc3magma_int_t magma_ztrevc3( magma_side_t side, magma_vec_t howmany, magma_int_t *select, // logical in Fortran magma_int_t n, magmaDoubleComplex *T, magma_int_t ldt, magmaDoubleComplex *VL, magma_int_t ldvl, magmaDoubleComplex *VR, magma_int_t ldvr, magma_int_t mm, magma_int_t *mout, magmaDoubleComplex *work, magma_int_t lwork, double *rwork, magma_int_t *info ){ #define T(i,j) ( T + (i) + (j)*ldt ) #define VL(i,j) (VL + (i) + (j)*ldvl) #define VR(i,j) (VR + (i) + (j)*ldvr) #define work(i,j) (work + (i) + (j)*n) // .. Parameters .. const magmaDoubleComplex c_zero = MAGMA_Z_ZERO; const magmaDoubleComplex c_one = MAGMA_Z_ONE; const magma_int_t nbmin = 16, nbmax = 128; const magma_int_t ione = 1; // .. Local Scalars .. magma_int_t allv, bothv, leftv, over, rightv, somev; magma_int_t i, ii, is, j, k, ki, iv, n2, nb, nb2, version; double ovfl, remax, scale, smin, smlnum, ulp, unfl; // Decode and test the input parameters bothv = (side == MagmaBothSides); rightv = (side == MagmaRight) || bothv; leftv = (side == MagmaLeft ) || bothv; allv = (howmany == MagmaAllVec); over = (howmany == MagmaBacktransVec); somev = (howmany == MagmaSomeVec); // Set mout to the number of columns required to store the selected // eigenvectors. if ( somev ) { *mout = 0; for( j=0; j < n; ++j ) { if ( select[j] ) { *mout += 1; } } } else { *mout = n; } *info = 0; if ( ! rightv && ! leftv ) *info = -1; else if ( ! allv && ! over && ! somev ) *info = -2; else if ( n < 0 ) *info = -4; else if ( ldt < max( 1, n ) ) *info = -6; else if ( ldvl < 1 || ( leftv && ldvl < n ) ) *info = -8; else if ( ldvr < 1 || ( rightv && ldvr < n ) ) *info = -10; else if ( mm < *mout ) *info = -11; else if ( lwork < max( 1, 2*n ) ) *info = -14; if ( *info != 0 ) { magma_xerbla( __func__, -(*info) ); return *info; } // Quick return if possible. if ( n == 0 ) { return *info; } // Use blocked version (2) if sufficient workspace. // Requires 1 vector to save diagonal elements, and 2*nb vectors for x and Q*x. // (Compared to dtrevc3, rwork stores 1-norms.) // Zero-out the workspace to avoid potential NaN propagation. nb = 2; if ( lwork >= n + 2*n*nbmin ) { version = 2; nb = (lwork - n) / (2*n); nb = min( nb, nbmax ); nb2 = 1 + 2*nb; lapackf77_zlaset( "F", &n, &nb2, &c_zero, &c_zero, work, &n ); } else { version = 1; } // Set the constants to control overflow. unfl = lapackf77_dlamch( "Safe minimum" ); ovfl = 1. / unfl; lapackf77_dlabad( &unfl, &ovfl ); ulp = lapackf77_dlamch( "Precision" ); smlnum = unfl*( n / ulp );//.........这里部分代码省略.........
开发者ID:EmergentOrder,项目名称:magma,代码行数:101,
示例18: TEUCHOS_TEST_FOR_EXCEPTION void ISVDMultiCD::makePass() { Epetra_LAPACK lapack; Epetra_BLAS blas; bool firstPass = (curRank_ == 0); const int numCols = A_->NumVectors(); TEUCHOS_TEST_FOR_EXCEPTION( !firstPass && (numProc_ != numCols), std::logic_error, "RBGen::ISVDMultiCD::makePass(): after first pass, numProc should be numCols"); // compute W = I - Z T Z^T from current V_ Teuchos::RCP<Epetra_MultiVector> lclAZT, lclZ; double *Z_A, *AZT_A; int Z_LDA, AZT_LDA; int oldRank = 0; double Rerr = 0.0; if (!firstPass) { // copy V_ into workZ_ lclAZT = Teuchos::rcp( new Epetra_MultiVector(::View,*workAZT_,0,curRank_) ); lclZ = Teuchos::rcp( new Epetra_MultiVector(::View,*workZ_,0,curRank_) ); { Epetra_MultiVector lclV(::View,*V_,0,curRank_); *lclZ = lclV; } // compute the Householder QR factorization of the current right basis // Vhat = W*R int info, lwork = curRank_; std::vector<double> tau(curRank_), work(lwork); info = lclZ->ExtractView(&Z_A,&Z_LDA); TEUCHOS_TEST_FOR_EXCEPTION(info != 0, std::logic_error, "RBGen::ISVDMultiCD::makePass(): error calling ExtractView on Epetra_MultiVector Z."); lapack.GEQRF(numCols,curRank_,Z_A,Z_LDA,&tau[0],&work[0],lwork,&info); TEUCHOS_TEST_FOR_EXCEPTION(info != 0, std::logic_error, "RBGen::ISVDMultiCD::makePass(): error calling GEQRF on current right basis while constructing next pass coefficients."); if (debug_) { // we just took the QR factorization of a set of orthonormal vectors // they should have an R factor which is diagonal, with unit elements (/pm 1) // check it Rerr = 0.0; for (int j=0; j<curRank_; j++) { for (int i=0; i<j; i++) { Rerr += abs(Z_A[j*Z_LDA+i]); } Rerr += abs(abs(Z_A[j*Z_LDA+j]) - 1.0); } } // compute the block representation // W = I - Z T Z^T lapack.LARFT('F','C',numCols,curRank_,Z_A,Z_LDA,&tau[0],workT_->A(),workT_->LDA()); // LARFT left upper tri block of Z unchanged // note: it should currently contain R factor of V_, which is very close to // diag(/pm 1, ..., /pm 1) // // we need to set it to: // [1 0 0 ... 0] // [ 1 0 ... 0] // [ .... ] // [ 1] // // see documentation for LARFT // for (int j=0; j<curRank_; j++) { Z_A[j*Z_LDA+j] = 1.0; for (int i=0; i<j; i++) { Z_A[j*Z_LDA+i] = 0.0; } } // compute part of A W: A Z T // put this in workAZT_ // first, A Z info = lclAZT->Multiply('N','N',1.0,*A_,*lclZ,0.0); TEUCHOS_TEST_FOR_EXCEPTION(info != 0,std::logic_error, "RBGen::ISVDMultiCD::makePass(): Error calling Epetra_MultiVector::Multiply() for A*Z"); // second, (A Z) T (in situ, as T is upper triangular) info = lclAZT->ExtractView(&AZT_A,&AZT_LDA); TEUCHOS_TEST_FOR_EXCEPTION(info != 0, std::logic_error, "RBGen::ISVDMultiCD::makePass(): error calling ExtractView on Epetra_MultiVector AZ."); blas.TRMM('R','U','N','N',numCols,curRank_,1.0,workT_->A(),workT_->LDA(),AZT_A,AZT_LDA); // save oldRank: it tells us the width of Z oldRank = curRank_; curRank_ = 0; numProc_ = 0; } else { // firstPass == true curRank_ = 0; numProc_ = 0; } while (numProc_ < numCols) { // // determine lup // // want lup >= lmin // lup <= lmax // need lup <= numCols - numProc // lup <= maxBasisSize - curRank // int lup; if (curRank_ == 0) { // first step uses startRank_//.........这里部分代码省略.........
开发者ID:ChiahungTai,项目名称:Trilinos,代码行数:101,
示例19: new_work_self // a new work was created for the current executing node inline void new_work_self(db::node *node, db::simple_tuple *stpl, const process::work_modifier mod = process::mods::NOTHING) { process::work work(node, stpl, process::mods::LOCAL_TUPLE | mod); new_work(node, work); }
开发者ID:adikolo,项目名称:visiblesim,代码行数:6,
示例20: umSOLVE_LS// DGELSS computes minimum norm solution to a real linear // least squares problem: Minimize 2-norm(| b - A*x |). // using the singular value decomposition (SVD) of A. // A is an M-by-N matrix which may be rank-deficient. //---------------------------------------------------------void umSOLVE_LS(const DMat& mat, const DMat& B, DMat& X)//---------------------------------------------------------{ if (!mat.ok()) {umWARNING("umSOLVE_LS()", "system is empty"); return;} DMat A(mat); // work with copy of input. int rows=A.num_rows(), cols=A.num_cols(), mmn=A.min_mn(); int LDB=A.max_mn(), NRHS=B.num_cols(); if (rows!=B.num_rows()) {umERROR("umSOLVE_LS(A,B)", "Inconsistant matrix sizes.");} DVec s(mmn); // allocate array for singular values // X must be big enough to store various results. // Resize X so that its leading dimension = max(M,N), // then load the set of right hand sides. X.resize(LDB,NRHS, true, 0.0); for (int j=1; j<=NRHS; ++j) // loop across colums for (int i=1; i<=rows; ++i) // loop down rows X(i,j) = B(i,j); // RCOND is used to determine the effective rank of A. // Singular values S(i) <= RCOND*S(1) are treated as zero. // If RCOND < 0, machine precision is used instead. //double rcond = 1.0 / 1.0e16; double rcond = -1.0; // NBN: ACML does not use the work vector. int mnLo=A.min_mn(), mnHi=A.max_mn(), rank=1, info=1; int lwork = 10*mnLo + std::max(2*mnLo, std::max(mnHi, NRHS)); DVec work(lwork); // Solve the system GELSS (rows, cols, NRHS, A.data(), rows, X.data(), LDB, s.data(), rcond, rank, work.data(), lwork, info); //--------------------------------------------- // Report: //--------------------------------------------- if (info == 0) { umLOG(1, "umSOLVE_LS reports successful LS-solution." "/nRCOND = %0.6e, " "/nOptimal length of work array was %d/n", rcond, lwork); } else { if (info < 0) { X = 0.0; umERROR("umSOLVE_LS(DMat&, DMat&)", "Error in input argument (%d)/nNo solution or error bounds computed.", -info); } else if (info > 0) { X = 0.0; umERROR("umSOLVE_LS(DMat&, DMat&)", "/nThe algorithm for computing the SVD failed to converge./n" "/n%d off-diagonal elements of an intermediate " "/nbidiagonal form did not converge to zero./n " "/nRCOND = %0.6e, " "/nOptimal length of work array was %d./n", info, rcond, lwork); } }}
开发者ID:Chang-Liu-0520,项目名称:nodal-dg,代码行数:70,
示例21: mainint main(){ freopen("input.in","r",stdin); work(); return 0;}
开发者ID:caorenxxy,项目名称:poj,代码行数:6,
示例22: inverselu//************************************************************************//Обращение матрицы, заданной LU-разложением////Входные параметры:// A - LU-разложение матрицы (результат работы подпрограммы// LUDecomposition).// Pivots - таблица перестановок, произведенных в ходе LU-разложения.// (результат работы подпрограммы LUDecomposition).// N - размерность матрицы////Выходные параметры:// A - матрица, обратная к исходной. Массив с нумерацией// элементов [1..N, 1..N]////Результат:// True, если исходная матрица невырожденная.// False, если исходная матрица вырожденная.//// -- LAPACK routine (version 3.0) --// Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,// Courant Institute, Argonne National Lab, and Rice University// February 29, 1992//************************************************************************bool inverselu(ap::real_2d_array& a, const ap::integer_1d_array& pivots, int n){ bool result; ap::real_1d_array work; int i; int iws; int j; int jb; int jj; int jp; int jp1; double v; result = true; // // Quick return if possible // if( n==0 ) { return result; } work.setbounds(1, n); // // Form inv(U) // if( !invtriangular(a, n, true, false) ) { result = false; return result; } // // Solve the equation inv(A)*L = inv(U) for inv(A). // for(j = n; j >= 1; j--) { // // Copy current column of L to WORK and replace with zeros. // for(i = j+1; i <= n; i++) { work(i) = a(i,j); a(i,j) = 0; } // // Compute current column of inv(A). // if( j<n ) { jp1 = j+1; for(i = 1; i <= n; i++) { v = ap::vdotproduct(a.getrow(i, jp1, n), work.getvector(jp1, n)); a(i,j) = a(i,j)-v; } } } // // Apply column interchanges. // for(j = n-1; j >= 1; j--) { jp = pivots(j); if( jp!=j ) { ap::vmove(work.getvector(1, n), a.getcolumn(j, 1, n)); ap::vmove(a.getcolumn(j, 1, n), a.getcolumn(jp, 1, n)); ap::vmove(a.getcolumn(jp, 1, n), work.getvector(1, n)); } } return result;//.........这里部分代码省略.........
开发者ID:Medcheg,项目名称:sources_old,代码行数:101,
示例23: operator void operator()(){ work(); }
开发者ID:Gyoorey,项目名称:Snooker,代码行数:3,
示例24: work void Emulator::WorkerRun() { boost::asio::io_service::work work(mIo); mIo.run(); }
开发者ID:0xee,项目名称:NfcEmu,代码行数:4,
示例25: dieharderSEXP dieharder(SEXP genS, SEXP testS, SEXP seedS, SEXP psamplesS, SEXP verbS, SEXP infileS, SEXP ntupleS) { int verb, testarg; unsigned int i; SEXP result = NULL, vec, pv, name, desc, nkps; char *inputfile; /* Setup argv to allow call of parsecl() to let dieharder set globals */ char *argv[] = { "dieharder" }; optind = 0; parsecl(1, argv); /* Parse 'our' parameters from R */ generator = INTEGER_VALUE(genS); testarg = INTEGER_VALUE(testS); diehard = rgb = sts = user = 0; if (testarg < 100) { diehard = testarg; } else if (testarg < 200) { rgb = testarg - 100; } else if (testarg < 300) { sts = testarg - 200; } else { user = testarg - 300; } Seed = (unsigned long int) INTEGER_VALUE(seedS); /* (user-select) Seed, not (save switch) seed */ psamples = INTEGER_VALUE(psamplesS); verb = INTEGER_VALUE(verbS); inputfile = (char*) CHARACTER_VALUE(infileS); ntuple = INTEGER_VALUE(ntupleS); rdh_testptr = NULL; rdh_dtestptr = NULL; /* to be safe, explicitly flag as NULL; cf test in output.c */ if (strcmp(inputfile, "") != 0) { strncpy(filename, inputfile, 128); fromfile = 1; /* flag this as file input */ } if (Seed == 0) { seed = random_seed(); } else { seed = (unsigned long int) Seed; } if (verb) { Rprintf("Dieharder called with gen=%d test=%d seed=%lu/n", generator, diehard, seed); quiet = 0; hist_flag = 1; } else { quiet = 1; /* override dieharder command-line default */ hist_flag = 0; } /* Now do the work that dieharder.c does */ startup(); work(); gsl_rng_free(rng); reset_bit_buffers(); /* And then bring our results back to R */ /* create vector of size four: [0] is vector (!!) ks_pv, [1] is pvalues vec, [2] name, [3] nkps */ PROTECT(result = allocVector(VECSXP, 4)); /* alloc vector and scalars, and set it */ PROTECT(pv = allocVector(REALSXP, rdh_dtestptr->nkps)); PROTECT(name = allocVector(STRSXP, 1)); PROTECT(nkps = allocVector(INTSXP, 1)); if (rdh_testptr != NULL && rdh_dtestptr != NULL) { for (i=0; i<rdh_dtestptr->nkps; i++) { /* there can be nkps p-values per test */ REAL(pv)[i] = rdh_testptr[i]->ks_pvalue; } PROTECT(vec = allocVector(REALSXP, rdh_testptr[0]->psamples)); /* alloc vector and set it */ for (i = 0; i < rdh_testptr[0]->psamples; i++) { REAL(vec)[i] = rdh_testptr[0]->pvalues[i]; } SET_STRING_ELT(name, 0, mkChar(rdh_dtestptr->name)); INTEGER(nkps)[0] = rdh_dtestptr->nkps; /* nb of Kuiper KS p-values in pv vector */ } else { PROTECT(vec = allocVector(REALSXP, 1)); REAL(pv)[0] = R_NaN; REAL(vec)[0] = R_NaN; SET_STRING_ELT(name, 0, mkChar("")); INTEGER(nkps)[0] = R_NaN; } /* insert vectors and scalars into result vector */ SET_VECTOR_ELT(result, 0, pv); SET_VECTOR_ELT(result, 1, vec); SET_VECTOR_ELT(result, 2, name); SET_VECTOR_ELT(result, 3, nkps); UNPROTECT(5); return result;}
开发者ID:gondree,项目名称:dieharder,代码行数:98,
示例26: magma_zgetrf2_gpuextern "C" magma_int_tmagma_zgetrf2_gpu( magma_int_t m, magma_int_t n, magmaDoubleComplex_ptr dA, size_t dA_offset, magma_int_t ldda, magma_int_t *ipiv, magma_queue_t queues[2], magma_int_t *info ){/* -- clMAGMA (version 1.3.0) -- Univ. of Tennessee, Knoxville Univ. of California, Berkeley Univ. of Colorado, Denver @date November 2014 Purpose ======= ZGETRF computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges. The factorization has the form A = P * L * U where P is a permutation matrix, L is lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n). This is the right-looking Level 3 BLAS version of the algorithm. Arguments ========= M (input) INTEGER The number of rows of the matrix A. M >= 0. N (input) INTEGER The number of columns of the matrix A. N >= 0. A (input/output) COMPLEX_16 array on the GPU, dimension (LDDA,N). On entry, the M-by-N matrix to be factored. On exit, the factors L and U from the factorization A = P*L*U; the unit diagonal elements of L are not stored. LDDA (input) INTEGER The leading dimension of the array A. LDDA >= max(1,M). IPIV (output) INTEGER array, dimension (min(M,N)) The pivot indices; for 1 <= i <= min(M,N), row i of the matrix was interchanged with row IPIV(i). INFO (output) INTEGER = 0: successful exit < 0: if INFO = -i, the i-th argument had an illegal value or another error occured, such as memory allocation failed. > 0: if INFO = i, U(i,i) is exactly zero. The factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations. ===================================================================== */ #define dA(i_, j_) dA, dA_offset + (i_)*nb + (j_)*nb*ldda #define dAT(i_, j_) dAT, dAT_offset + (i_)*nb*lddat + (j_)*nb #define dAP(i_, j_) dAP, (i_) + (j_)*maxm #define work(i_) (work + (i_)) magmaDoubleComplex c_one = MAGMA_Z_ONE; magmaDoubleComplex c_neg_one = MAGMA_Z_NEG_ONE; magma_int_t iinfo, nb; magma_int_t maxm, maxn, mindim; magma_int_t i, j, rows, s, lddat, ldwork; magmaDoubleComplex_ptr dAT, dAP; magmaDoubleComplex *work; size_t dAT_offset; /* Check arguments */ *info = 0; if (m < 0) *info = -1; else if (n < 0) *info = -2; else if (ldda < max(1,m)) *info = -4; if (*info != 0) { magma_xerbla( __func__, -(*info) ); return *info; } /* Quick return if possible */ if (m == 0 || n == 0) return *info; /* Function Body */ mindim = min(m, n); nb = magma_get_zgetrf_nb(m); s = mindim / nb; if (nb <= 1 || nb >= min(m,n)) { /* Use CPU code. */ if ( MAGMA_SUCCESS != magma_zmalloc_cpu( &work, m*n )) { *info = MAGMA_ERR_HOST_ALLOC; return *info;//.........这里部分代码省略.........
开发者ID:kjbartel,项目名称:clmagma,代码行数:101,
注:本文中的work函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ work_m_00000000004134447467_2073120511_init函数代码示例 C++ words函数代码示例 |