这篇教程C++ x函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中x函数的典型用法代码示例。如果您正苦于以下问题:C++ x函数的具体用法?C++ x怎么用?C++ x使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了x函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: xbool IntRect::intersects(const IntRect& other) const { // Checking emptiness handles negative widths as well as zero. return !isEmpty() && !other.isEmpty() && x() < other.maxX() && other.x() < maxX() && y() < other.maxY() && other.y() < maxY();}
开发者ID:mirror,项目名称:chromium,代码行数:5,
示例2: PositionMetaDatavoid ProcessorGraphicsItem::saveMeta() { PositionMetaData* meta = new PositionMetaData(static_cast<int>(x()), static_cast<int>(y())); processor_->getMetaDataContainer().addMetaData("ProcessorGraphicsItem", meta);}
开发者ID:molsimmsu,项目名称:3mview,代码行数:5,
示例3: MPI_Comm_rankvoid sLinsysRootAug::solveWithBiCGStab( sData *prob, SimpleVector& b){ int n = b.length(); const int maxit=500; const double tol=1e-12, EPS=2e-16; double iter=0.0; int myRank; MPI_Comm_rank(mpiComm, &myRank); SimpleVector r(n); //residual SimpleVector s(n); //residual associated with half iterate SimpleVector rt(n); //shadow residual SimpleVector xmin(n); //minimal residual iterate SimpleVector x(n); //iterate SimpleVector xhalf(n); // half iterate of BiCG SimpleVector p(n),paux(n); SimpleVector v(n), t(n); int flag; double imin; double n2b; //norm of b double normr, normrmin; //norm of the residual and norm of residual at min-resid iterate double normr_act; double tolb; //relative tolerance double rho, omega, alpha; int stag, maxmsteps, maxstagsteps, moresteps; double relres; //maxit = n/2+1; ////////////////////////////////////////////////////////////////// // Problem Setup and intialization ////////////////////////////////////////////////////////////////// n2b = b.twonorm(); tolb = n2b*tol;#ifdef TIMING taux = MPI_Wtime();#endif //initial guess x.copyFrom(b); solver->Dsolve(x); //initial residual r.copyFrom(b);#ifdef TIMING troot_total += (MPI_Wtime()-taux); taux = MPI_Wtime();#endif //applyA(1.0, r, -1.0, x); SCmult(1.0,r, -1.0,x, prob);#ifdef TIMING tchild_total += (MPI_Wtime()-taux);#endif normr=r.twonorm();#ifdef TIMING if(myRank==0) cout << "BiCG: initial rel resid: " << normr/n2b << endl;#endif if(normr<tolb) { //initial guess is good enough b.copyFrom(x); flag=0; return; } rt.copyFrom(r); //Shadow residual double* resvec = new double[2*maxit+1]; resvec[0] = normr; normrmin=normr; rho=1.0; omega=1.0; stag=0; maxmsteps=min(min(n/50, 5), n-maxit); maxstagsteps=3; moresteps=0; ////////////////////////////////////////////////////////////////// // loop over maxit iterations ////////////////////////////////////////////////////////////////// int ii=0; while(ii<maxit) { //cout << ii << " "; flag=-1; /////////////////////////////// // First half of the iterate /////////////////////////////// double rho1=rho; double beta; rho = rt.dotProductWith(r); //printf("rho=%g/n", rho); if(0.0==rho) { flag=4; break; } if(ii==0) p.copyFrom(r); else { beta = (rho/rho1)*(alpha/omega); if(beta==0.0) { flag=4; break; } //-------- p = r + beta*(p - omega*v) -------- p.axpy(-omega, v); p.scale(beta); p.axpy(1.0, r); }#ifdef TIMING//.........这里部分代码省略.........
开发者ID:qiakeyufeiniao,项目名称:PIPS,代码行数:101,
示例4: QuaternionQuaternion Quaternion::operator*(const float c) const { return Quaternion(x() * c, y() * c, z() * c, w() * c);}
开发者ID:Akz-,项目名称:residual,代码行数:3,
示例5: xHeapWord* GenCollectorPolicy::satisfy_failed_allocation(size_t size, bool is_tlab) { GenCollectedHeap *gch = GenCollectedHeap::heap(); GCCauseSetter x(gch, GCCause::_allocation_failure); HeapWord* result = NULL; assert(size != 0, "Precondition violated"); if (GC_locker::is_active_and_needs_gc()) { // GC locker is active; instead of a collection we will attempt // to expand the heap, if there's room for expansion. if (!gch->is_maximal_no_gc()) { result = expand_heap_and_allocate(size, is_tlab); } return result; // could be null if we are out of space } else if (!gch->incremental_collection_will_fail()) { // The gc_prologues have not executed yet. The value // for incremental_collection_will_fail() is the remanent // of the last collection. // Do an incremental collection. gch->do_collection(false /* full */, false /* clear_all_soft_refs */, size /* size */, is_tlab /* is_tlab */, number_of_generations() - 1 /* max_level */); } else { // Try a full collection; see delta for bug id 6266275 // for the original code and why this has been simplified // with from-space allocation criteria modified and // such allocation moved out of the safepoint path. gch->do_collection(true /* full */, false /* clear_all_soft_refs */, size /* size */, is_tlab /* is_tlab */, number_of_generations() - 1 /* max_level */); } result = gch->attempt_allocation(size, is_tlab, false /*first_only*/); if (result != NULL) { assert(gch->is_in_reserved(result), "result not in heap"); return result; } // OK, collection failed, try expansion. result = expand_heap_and_allocate(size, is_tlab); if (result != NULL) { return result; } // If we reach this point, we're really out of memory. Try every trick // we can to reclaim memory. Force collection of soft references. Force // a complete compaction of the heap. Any additional methods for finding // free memory should be here, especially if they are expensive. If this // attempt fails, an OOM exception will be thrown. { IntFlagSetting flag_change(MarkSweepAlwaysCompactCount, 1); // Make sure the heap is fully compacted gch->do_collection(true /* full */, true /* clear_all_soft_refs */, size /* size */, is_tlab /* is_tlab */, number_of_generations() - 1 /* max_level */); } result = gch->attempt_allocation(size, is_tlab, false /* first_only */); if (result != NULL) { assert(gch->is_in_reserved(result), "result not in heap"); return result; } // What else? We might try synchronous finalization later. If the total // space available is large enough for the allocation, then a more // complete compaction phase than we've tried so far might be // appropriate. return NULL;}
开发者ID:tetratec,项目名称:Runescape-Launcher,代码行数:76,
示例6: assert bool SolverSLAM2DLinear::solveOrientation() { assert(_optimizer->indexMapping().size() + 1 == _optimizer->vertices().size() && "Needs to operate on full graph"); assert(_optimizer->vertex(0)->fixed() && "Graph is not fixed by vertex 0"); VectorXD b, x; // will be used for theta and x/y update b.setZero(_optimizer->indexMapping().size()); x.setZero(_optimizer->indexMapping().size()); typedef Eigen::Matrix<double, 1, 1, Eigen::ColMajor> ScalarMatrix; ScopedArray<int> blockIndeces(new int[_optimizer->indexMapping().size()]); for (size_t i = 0; i < _optimizer->indexMapping().size(); ++i) blockIndeces[i] = i+1; SparseBlockMatrix<ScalarMatrix> H(blockIndeces.get(), blockIndeces.get(), _optimizer->indexMapping().size(), _optimizer->indexMapping().size()); // building the structure, diagonal for each active vertex for (size_t i = 0; i < _optimizer->indexMapping().size(); ++i) { OptimizableGraph::Vertex* v = _optimizer->indexMapping()[i]; int poseIdx = v->hessianIndex(); ScalarMatrix* m = H.block(poseIdx, poseIdx, true); m->setZero(); } HyperGraph::VertexSet fixedSet; // off diagonal for each edge for (SparseOptimizer::EdgeContainer::const_iterator it = _optimizer->activeEdges().begin(); it != _optimizer->activeEdges().end(); ++it) {# ifndef NDEBUG EdgeSE2* e = dynamic_cast<EdgeSE2*>(*it); assert(e && "Active edges contain non-odometry edge"); //# else EdgeSE2* e = static_cast<EdgeSE2*>(*it);# endif OptimizableGraph::Vertex* from = static_cast<OptimizableGraph::Vertex*>(e->vertices()[0]); OptimizableGraph::Vertex* to = static_cast<OptimizableGraph::Vertex*>(e->vertices()[1]); int ind1 = from->hessianIndex(); int ind2 = to->hessianIndex(); if (ind1 == -1 || ind2 == -1) { if (ind1 == -1) fixedSet.insert(from); // collect the fixed vertices if (ind2 == -1) fixedSet.insert(to); continue; } bool transposedBlock = ind1 > ind2; if (transposedBlock){ // make sure, we allocate the upper triangle block std::swap(ind1, ind2); } ScalarMatrix* m = H.block(ind1, ind2, true); m->setZero(); } // walk along the Minimal Spanning Tree to compute the guess for the robot orientation assert(fixedSet.size() == 1); VertexSE2* root = static_cast<VertexSE2*>(*fixedSet.begin()); VectorXD thetaGuess; thetaGuess.setZero(_optimizer->indexMapping().size()); UniformCostFunction uniformCost; HyperDijkstra hyperDijkstra(_optimizer); hyperDijkstra.shortestPaths(root, &uniformCost); HyperDijkstra::computeTree(hyperDijkstra.adjacencyMap()); ThetaTreeAction thetaTreeAction(thetaGuess.data()); HyperDijkstra::visitAdjacencyMap(hyperDijkstra.adjacencyMap(), &thetaTreeAction); // construct for the orientation for (SparseOptimizer::EdgeContainer::const_iterator it = _optimizer->activeEdges().begin(); it != _optimizer->activeEdges().end(); ++it) { EdgeSE2* e = static_cast<EdgeSE2*>(*it); VertexSE2* from = static_cast<VertexSE2*>(e->vertices()[0]); VertexSE2* to = static_cast<VertexSE2*>(e->vertices()[1]); double omega = e->information()(2,2); double fromThetaGuess = from->hessianIndex() < 0 ? 0. : thetaGuess[from->hessianIndex()]; double toThetaGuess = to->hessianIndex() < 0 ? 0. : thetaGuess[to->hessianIndex()]; double error = normalize_theta(-e->measurement().rotation().angle() + toThetaGuess - fromThetaGuess); bool fromNotFixed = !(from->fixed()); bool toNotFixed = !(to->fixed()); if (fromNotFixed || toNotFixed) { double omega_r = - omega * error; if (fromNotFixed) { b(from->hessianIndex()) -= omega_r; (*H.block(from->hessianIndex(), from->hessianIndex()))(0,0) += omega; if (toNotFixed) { if (from->hessianIndex() > to->hessianIndex()) (*H.block(to->hessianIndex(), from->hessianIndex()))(0,0) -= omega; else (*H.block(from->hessianIndex(), to->hessianIndex()))(0,0) -= omega; } } if (toNotFixed ) { b(to->hessianIndex()) += omega_r; (*H.block(to->hessianIndex(), to->hessianIndex()))(0,0) += omega; } } }//.........这里部分代码省略.........
开发者ID:2maz,项目名称:g2o,代码行数:101,
示例7: mainint main(){ std::random_device rd; std::mt19937_64 rng(rd()); const int sawtooth = 1; const int do_rand = 2; const int stagger = 3; const int plateau = 4; const int shuffle = 5; for (size_t n : {100, 1023, 1024, 1025, (2 << 16) - 1, 2 << 16, (2 << 16) + 1}) { std::cerr << "/nSize: " << n << ": "; for (size_t m = 1; m < 2 * n; m *= 2) { std::cerr << m; for (auto dist : {sawtooth, do_rand, stagger, plateau, shuffle}) { std::cerr << "."; std::vector<int64_t> x(n); size_t i = 0, j = 0, k = 1; switch (dist) { case sawtooth: for (; i < n; i++) { x[i] = i % m; } break; case do_rand: for (; i < n; i++) { x[i] = rng() % m; } break; case stagger: for (; i < n; i++) { x[i] = (i * m + i) % n; } break; case plateau: for (; i < n; i++) { x[i] = std::min(i, m); } break; case shuffle: for (; i < n; i++) { x[i] = rng() % m ? (j += 2) : (k += 2); } break; } Ioss::qsort(x); // Copy of x assert(verify_sorted(x)); std::reverse(x.begin(), x.end()); // Reversed Ioss::qsort(x); assert(verify_sorted(x)); std::reverse(&x[0], &x[n / 2]); // Front half reversed Ioss::qsort(x); assert(verify_sorted(x)); std::reverse(&x[n / 2], &x[n]); // Back half reversed Ioss::qsort(x); assert(verify_sorted(x)); Ioss::qsort(x); // Already sorted assert(verify_sorted(x)); for (size_t p = 0; p < n; p++) { x[p] += p % 5; } Ioss::qsort(x); // Dithered assert(verify_sorted(x)); } } } std::cerr << "/nDone/n";}
开发者ID:jbcarleton,项目名称:seacas,代码行数:76,
示例8: lod_cn_travelling_wave// NB : matrix is passed in Column-Major storage. voidlod_cn_travelling_wave(double* const inout_matrix, const int space_nb_x, const int space_nb_y, const double final_time, const double tau, const double eps){ double h_x = 1./((double)space_nb_x-1.), h_y = 1./((double)space_nb_y-1.); Eigen::VectorXd x_border, y_border, x(space_nb_x), y(space_nb_y); Eigen::MatrixXd values, after_x, after_y, after_reaction; Eigen::SparseMatrix<double> operator_x, operator_y, laplace_x, unit_matrix_x, laplace_y, unit_matrix_y; // Boundaries. x_border.setLinSpaced(space_nb_x, 0., 1.); y_border.setLinSpaced(space_nb_y, 0., 1.); // Initial values. initial_values(values, x_border, y_border, eps); // Operators initialization; laplace_operator_1d(laplace_x, space_nb_x); identity_operator(unit_matrix_x, space_nb_x); laplace_operator_1d(laplace_y, space_nb_y); identity_operator(unit_matrix_y, space_nb_y); space_operator(operator_x, laplace_x, (tau*eps)/(h_x*h_x), unit_matrix_x); space_operator(operator_y, laplace_y, (tau*eps)/(h_y*h_y), unit_matrix_y);#ifdef DEBUG_LOD_CNdebug_print("init values", values, 5, 5);debug_print("laplace x", laplace_x, 5, 5);debug_print("I x", unit_matrix_x, 5, 5);debug_print("laplace y", laplace_y, 5, 5);debug_print("I y", unit_matrix_y, 5, 5);debug_print("Op x", operator_x, 5, 5);debug_print("Op y", operator_y, 5, 5);#endif double time = 0.; const double tcoeff = 1.; while (time < final_time) { // Step in x direction. // NB. Operators x and y are hermitian, so that we can commute them. // Apply an operator in x direction.#ifdef DEBUG_LOD_CNdebug_print("values", values, 5, 5);#endif after_x = values*operator_x; bc_x(y, y_border, time, 0., eps); after_x.col(0) = y*tcoeff; bc_x(y, y_border, time, 1., eps); after_x.col(space_nb_x-1) = y*tcoeff;#ifdef DEBUG_LOD_CNdebug_print("after_x", after_x, 5, 5);#endif // Apply an operator in y direction. after_y = operator_y*values; bc_y(x, x_border, time, 0., eps); after_y.row(0) = x.transpose()*tcoeff; bc_y(x, x_border, time, 1., eps); after_y.row(space_nb_y-1) = x.transpose()*tcoeff;#ifdef DEBUG_LOD_CNdebug_print("after_y", after_y, 5, 5);#endif // Apply the reaction operator. auto transform = ::boost::bind(reaction_operator, _1, tau/eps); after_reaction = after_y+after_y.unaryExpr(transform); #ifdef DEBUG_LOD_CNdebug_print("after_reaction", after_reaction, 5, 5);#endif // Time advance. time += tau; // Second application of an operator in y direction. after_y = operator_y*after_reaction; bc_y(x, x_border, time, 0., eps); after_y.row(0) = x.transpose()*tcoeff; bc_y(x, x_border, time, 1., eps); after_y.row(space_nb_y-1) = x.transpose()*tcoeff;#ifdef DEBUG_LOD_CNdebug_print("after_y", after_y, 5, 5);#endif // Second application of an operator in x direction. values = after_y*operator_x; bc_x(y, y_border, time, 0., eps); values.col(0) = y*tcoeff; bc_x(y, y_border, time, 1., eps); values.col(space_nb_x-1) = y*tcoeff; } // Copy to the return value. memcpy(inout_matrix, values.data(), space_nb_x*space_nb_y*sizeof(double));}
开发者ID:aoboturov,项目名称:m2-mo-pde-numerical-methods,代码行数:90,
示例9: addvoid add(int u, int v, int cost, int cap) { edge x(v, int(ed[v].size()), cost, cap); edge y(u, int(ed[u].size()), -cost, 0); ed[u].push_back(x); ed[v].push_back(y);}
开发者ID:eddrda,项目名称:cpp,代码行数:6,
示例10: fl_clip_boxvoid console_widget_t::draw(){ if (console == NULL) { int x_, y_, w_, h_; fl_clip_box(x(),y(),w(),h(), x_, y_, w_, h_); fl_color(FL_BLACK); fl_rectf(x_, y_, w_, h_); return; } fl_font(font_name, font_size); int x_, y_, w_, h_, cx, cy; fl_clip_box(x(), y(), w(), h(), x_, y_, w_, h_); cx = x(); cy = y(); cx -= (fit_x - w()) / 2; cy -= (fit_y - h()) / 2; x_ -= cx; y_ -= cy; int x1 = x_ / letter_x; int x2 = (x_ + w_) / letter_x + 1; int y1 = y_ / letter_y; int y2 = (y_ + h_) / letter_y + 1; int yi = 0; if (x_ < 0) { fl_color(FL_BLACK); fl_rectf(x(), y(), -x_, h_); x1 = 0; cx += x1 * letter_x; } if (y_ < 0) { fl_color(FL_BLACK); fl_rectf(cx, y(), fit_x, -y_); } if (x_ + w_ > fit_x) { fl_color(FL_BLACK); fl_rectf(cx + fit_x, y(), x_ + w_ - fit_x, h_); x2 = console->config.x; } if (y_ + h_ > fit_y) { fl_color(FL_BLACK); fl_rectf(cx, cy + fit_y, fit_x, y_ + h_ - fit_y); } fl_push_clip(x(), y(), w(), h()); for (yi = y1; yi < y2; yi++) { if (yi < 0) continue; if (yi >= console->config.y) break; co_console_cell_t* row_start = &console->screen[(yi+scroll_lines) * console->config.x]; co_console_cell_t* cell; co_console_cell_t* start; co_console_cell_t* end; char text_buff[0x100]; start = row_start + x1; end = row_start + x2; cell = start; if (end > cell_limit) { // co_debug("BUG: end=%p limit=%p row=%p start=%p x1=%d x2=%d y1=%d y2=%d", // end, limit, row_start, start, x1, x2, y1, y2); end = cell_limit; // Hack: Fix the overrun! } while (cell < end) { while (cell < end && start->attr == cell->attr && cell - start < (int)sizeof(text_buff)) { text_buff[cell - start] = cell->ch; cell++; } FL_RGB_COLOR((start->attr >> 4) & 0xf); fl_rectf(cx + letter_x * (start - row_start), cy + letter_y * (yi), (cell - start) * letter_x, letter_y); FL_RGB_COLOR((start->attr) & 0xf); fl_draw(text_buff, cell - start, cx + letter_x * (start - row_start), cy + letter_y * (yi + 1) - fl_descent());//.........这里部分代码省略.........
开发者ID:matt81093,项目名称:Original-Colinux,代码行数:101,
示例11: visualOverflowRectvoid RenderSVGRoot::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOffset){ // An empty viewport disables rendering. if (pixelSnappedBorderBoxRect().isEmpty()) return; // Don't paint, if the context explicitely disabled it. if (paintInfo.context->paintingDisabled()) return; Page* page = 0; if (Frame* frame = this->frame()) page = frame->page(); // Don't paint if we don't have kids, except if we have filters we should paint those. if (!firstChild()) { SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject(this); if (!resources || !resources->filter()) { if (page && paintInfo.phase == PaintPhaseForeground) page->addRelevantUnpaintedObject(this, visualOverflowRect()); return; } } if (page && paintInfo.phase == PaintPhaseForeground) page->addRelevantRepaintedObject(this, visualOverflowRect()); // Make a copy of the PaintInfo because applyTransform will modify the damage rect. PaintInfo childPaintInfo(paintInfo); childPaintInfo.context->save(); // Apply initial viewport clip - not affected by overflow handling childPaintInfo.context->clip(pixelSnappedIntRect(overflowClipRect(paintOffset, paintInfo.renderRegion))); // Convert from container offsets (html renderers) to a relative transform (svg renderers). // Transform from our paint container's coordinate system to our local coords. IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset); childPaintInfo.applyTransform(AffineTransform::translation(adjustedPaintOffset.x() - x(), adjustedPaintOffset.y() - y()) * localToParentTransform()); SVGRenderingContext renderingContext; bool continueRendering = true; if (childPaintInfo.phase == PaintPhaseForeground) { renderingContext.prepareToRenderSVGContent(this, childPaintInfo); continueRendering = renderingContext.isRenderingPrepared(); } if (continueRendering) RenderBox::paint(childPaintInfo, LayoutPoint()); childPaintInfo.context->restore();}
开发者ID:dzhshf,项目名称:WebKit,代码行数:51,
示例12: qMakePairvoid QQuickParticleEmitter::burst(int num){ m_burstQueue << qMakePair(num, QPointF(x(), y()));}
开发者ID:SamuelNevala,项目名称:qtdeclarative,代码行数:4,
示例13: foovoid foo() { X x(1); // { dg-error "incomplete type" } bar(x); // { dg-error "3:'bar' was not declared" }}
开发者ID:MaxKellermann,项目名称:gcc,代码行数:4,
示例14: updateClockvoid CommercialGraphic::showClock() { clockStatus = SHOW_CLOCK; updateClock(); if (show) scene()->update(x() + CLOCK_X, y(), CLOCK_WIDTH, GRAPHIC_HEIGHT);}
开发者ID:db4soundman,项目名称:HockeyQt,代码行数:6,
示例15: fooint foo (){ std::decimal::decimal64 x(0); bar (x);}
开发者ID:Arhzi,项目名称:dragonegg,代码行数:5,
示例16: xvoid ADFun<Base>::optimize(void){ // place to store the optimized version of the recording recorder<Base> rec; // number of independent variables size_t n = ind_taddr_.size();# ifndef NDEBUG size_t i, j, m = dep_taddr_.size(); CppAD::vector<Base> x(n), y(m), check(m); bool check_zero_order = taylor_per_var_ > 0; Base max_taylor(0); if( check_zero_order ) { // zero order coefficients for independent vars for(j = 0; j < n; j++) { CPPAD_ASSERT_UNKNOWN( play_.GetOp(j+1) == InvOp ); CPPAD_ASSERT_UNKNOWN( ind_taddr_[j] == j+1 ); x[j] = taylor_[ ind_taddr_[j] * taylor_col_dim_ + 0]; } // zero order coefficients for dependent vars for(i = 0; i < m; i++) { CPPAD_ASSERT_UNKNOWN( dep_taddr_[i] < total_num_var_ ); y[i] = taylor_[ dep_taddr_[i] * taylor_col_dim_ + 0]; } // maximum zero order coefficient not counting BeginOp at beginning // (which is correpsonds to uninitialized memory). for(i = 1; i < total_num_var_; i++) { if( abs_geq(taylor_[i*taylor_col_dim_+0] , max_taylor) ) max_taylor = taylor_[i*taylor_col_dim_+0]; } }# endif // create the optimized recording CppAD::optimize<Base>(n, dep_taddr_, &play_, &rec); // number of variables in the recording total_num_var_ = rec.num_rec_var(); // now replace the recording play_.get(rec); // free memory allocated for sparse Jacobian calculation // (the results are no longer valid) for_jac_sparse_pack_.resize(0, 0); for_jac_sparse_set_.resize(0,0); // free old Taylor coefficient memory taylor_.free(); taylor_per_var_ = 0; taylor_col_dim_ = 0;# ifndef NDEBUG if( check_zero_order ) { // zero order forward calculation using new operation sequence check = Forward(0, x); // check results Base eps = 10. * epsilon<Base>(); for(i = 0; i < m; i++) CPPAD_ASSERT_KNOWN( abs_geq( eps * max_taylor , check[i] - y[i] ) , "Error during check of f.optimize()." ); // Erase memory that this calculation was done so NDEBUG gives // same final state for this object (from users perspective) taylor_per_var_ = 0; }# endif}
开发者ID:markpayneatwork,项目名称:adcomp,代码行数:71,
示例17: image_areavoid animation_preview_widget::handle_draw() const{ graphics::draw_rect(rect(x(),y(),width(),height()), graphics::color(0,0,0,196)); rect image_area(x(), y(), (width()*3)/4, height() - 30); const graphics::texture image_texture(graphics::texture::get(obj_["image"].as_string())); if(image_texture.valid()) { const graphics::clip_scope clipping_scope(image_area.sdl_rect()); const rect focus_area(frame_->area().x(), frame_->area().y(), (frame_->area().w() + frame_->pad())*frame_->num_frames_per_row(), (frame_->area().h() + frame_->pad())*(frame_->num_frames()/frame_->num_frames_per_row() + (frame_->num_frames()%frame_->num_frames_per_row() ? 1 : 0))); GLfloat scale = 2.0; for(int n = 0; n != abs(scale_); ++n) { scale *= (scale_ < 0 ? 0.5 : 2.0); } while(image_area.w()*scale*2.0 < image_area.w() && image_area.h()*scale*2.0 < image_area.h()) { scale *= 2.0; scale_++; update_zoom_label(); } while(focus_area.w()*scale > image_area.w() || focus_area.h()*scale > image_area.h()) { scale *= 0.5; scale_--; update_zoom_label(); } const int show_width = image_area.w()/scale; const int show_height = image_area.h()/scale; int x1 = focus_area.x() + (focus_area.w() - show_width)/2; int y1 = focus_area.y() + (focus_area.h() - show_height)/2; int x2 = x1 + show_width; int y2 = y1 + show_height; int xpos = image_area.x(); int ypos = image_area.y(); src_rect_ = rect(x1, y1, x2 - x1, y2 - y1); dst_rect_ = rect(xpos, ypos, (x2-x1)*scale, (y2-y1)*scale); graphics::blit_texture(image_texture, xpos, ypos, (x2-x1)*scale, (y2-y1)*scale, 0.0, GLfloat(x1)/image_texture.width(), GLfloat(y1)/image_texture.height(), GLfloat(x2)/image_texture.width(), GLfloat(y2)/image_texture.height()); for(int n = 0; n != frame_->num_frames(); ++n) { const int row = n/frame_->num_frames_per_row(); const int col = n%frame_->num_frames_per_row(); const int x = xpos - x1*scale + (frame_->area().x() + col*(frame_->area().w()+frame_->pad()))*scale; const int y = ypos - y1*scale + (frame_->area().y() + row*(frame_->area().h()+frame_->pad()))*scale; const rect box(x, y, frame_->area().w()*scale, frame_->area().h()*scale); graphics::draw_hollow_rect(box.sdl_rect(), n == 0 ? graphics::color_yellow() : graphics::color_white(), frame_->frame_number(cycle_) == n ? 0xFF : 0x88); } int mousex, mousey; if(anchor_x_ != -1 && SDL_GetMouseState(&mousex, &mousey) && point_in_rect(point(mousex, mousey), dst_rect_)) { const point p1 = mouse_point_to_image_loc(point(mousex, mousey)); const point p2 = mouse_point_to_image_loc(point(anchor_x_, anchor_y_)); int xpos1 = xpos - x1*scale + p1.x*scale; int xpos2 = xpos - x1*scale + p2.x*scale; int ypos1 = ypos - y1*scale + p1.y*scale; int ypos2 = ypos - y1*scale + p2.y*scale; if(xpos2 < xpos1) { std::swap(xpos1, xpos2); } if(ypos2 < ypos1) { std::swap(ypos1, ypos2); } rect area(xpos1, ypos1, xpos2 - xpos1, ypos2 - ypos1); graphics::draw_hollow_rect(area.sdl_rect(), graphics::color_white()); } } rect preview_area(x() + (width()*3)/4, y(), width()/4, height()); GLfloat scale = 1.0; while(false && (frame_->width()*scale > preview_area.w() || frame_->height()*scale > preview_area.h())) { scale *= 0.5; } frame_->draw( preview_area.x() + (preview_area.w() - frame_->width()*scale)/2, preview_area.y() + (preview_area.h() - frame_->height()*scale)/2, true, false, cycle_, 0, scale); if(++cycle_ >= frame_->duration()) { cycle_ = 0; } foreach(const_widget_ptr w, widgets_) {//.........这里部分代码省略.........
开发者ID:Marjoe,项目名称:frogatto,代码行数:101,
示例18: SkIRectIntRect::operator SkIRect() const{ SkIRect rect = { x(), y(), maxX(), maxY() }; return rect;}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:5,
示例19: normalizeQuaternion Quaternion::inverse() { normalize(); return Quaternion(-x(), -y(), -z(), w());}
开发者ID:Akz-,项目名称:residual,代码行数:4,
示例20: SkRectIntRect::operator SkRect() const{ SkRect rect; rect.set(SkIntToScalar(x()), SkIntToScalar(y()), SkIntToScalar(maxX()), SkIntToScalar(maxY())); return rect;}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:6,
示例21: QRectQRect MythRect::toQRect() const{ return QRect(x(),y(),width(),height());}
开发者ID:gdenning,项目名称:mythtv,代码行数:4,
示例22: xbool doigt::operator==(doigt& d) { if(existe() == d.existe()) return true; return d.x() == x() && d.y() == y();}
开发者ID:oin,项目名称:parkayapravesh,代码行数:4,
示例23: QPointQPoint MythPoint::toQPoint() const{ return QPoint(x(),y());}
开发者ID:gdenning,项目名称:mythtv,代码行数:4,
示例24: r2void sLinsysRootAug::solveWithIterRef( sData *prob, SimpleVector& r){ SimpleVector r2(&r[locnx], locmy); SimpleVector r1(&r[0], locnx); //SimpleVector realRhs(&r[0], locnx+locmy);#ifdef TIMING taux=MPI_Wtime();#endif double rhsNorm=r.twonorm(); //r== the initial rhs of the reduced system here int myRank; MPI_Comm_rank(mpiComm, &myRank); SimpleVector rxy(locnx+locmy); rxy.copyFrom(r); SimpleVector x(locnx+locmy); x.setToZero(); //solution SimpleVector dx(locnx+locmy); //update from iter refinement SimpleVector x_prev(locnx+locmy); int refinSteps=0; std::vector<double> histResid; int maxRefinSteps=(gLackOfAccuracy>0?9:8); do { //iterative refinement#ifdef TIMING taux=MPI_Wtime();#endif x_prev.copyFrom(x); //dx = Ainv * r dx.copyFrom(rxy); solver->Dsolve(dx); //update x x.axpy(1.0,dx);#ifdef TIMING troot_total += (MPI_Wtime()-taux);#endif if(gLackOfAccuracy<0) break; if(refinSteps==maxRefinSteps) break; ////////////////////////////////////////////////////////////////////// //iterative refinement ////////////////////////////////////////////////////////////////////// //compute residual //if (iAmDistrib) { //only one process substracts [ (Q+Dx0+C'*Dz0*C)*xx + A'*xy ] from r // [ A*xx ] if(myRank==0) { rxy.copyFrom(r); if(locmz>0) { SparseSymMatrix* CtDC_sp = dynamic_cast<SparseSymMatrix*>(CtDC); CtDC_sp->mult(1.0,&rxy[0],1, 1.0,&x[0],1); } SparseSymMatrix& Q = prob->getLocalQ(); Q.mult(1.0,&rxy[0],1, -1.0,&x[0],1); SimpleVector& xDiagv = dynamic_cast<SimpleVector&>(*xDiag); assert(xDiagv.length() == locnx); for(int i=0; i<xDiagv.length(); i++) rxy[i] -= xDiagv[i]*x[i]; SparseGenMatrix& A=prob->getLocalB(); A.transMult(1.0,&rxy[0],1, -1.0,&x[locnx],1); A.mult(1.0,&rxy[locnx],1, -1.0,&x[0],1); } else { //other processes set r to zero since they will get this portion from process 0 rxy.setToZero(); }#ifdef TIMING taux=MPI_Wtime();#endif // now children add [0 A^T C^T ]*inv(KKT)*[0;A;C] x SimpleVector xx(&x[0], locnx); for(size_t it=0; it<children.size(); it++) { children[it]->addTermToSchurResidual(prob->children[it],rxy,xx); }#ifdef TIMING tchild_total += (MPI_Wtime()-taux);#endif //~done computing residual #ifdef TIMING taux=MPI_Wtime();#endif //all-reduce residual if(iAmDistrib) { dx.setToZero(); //we use dx as the recv buffer MPI_Allreduce(rxy.elements(), dx.elements(), locnx+locmy, MPI_DOUBLE, MPI_SUM, mpiComm); rxy.copyFrom(dx); }#ifdef TIMING tcomm_total += (MPI_Wtime()-taux);#endif double relResNorm=rxy.twonorm()/rhsNorm; if(relResNorm<1.0e-10) { break; } else {//.........这里部分代码省略.........
开发者ID:qiakeyufeiniao,项目名称:PIPS,代码行数:101,
示例25: eDebugCIvoid eDVBCIInterfaces::recheckPMTHandlers(){ eDebugCI("recheckPMTHAndlers()"); for (PMTHandlerList::iterator it(m_pmt_handlers.begin()); it != m_pmt_handlers.end(); ++it) { CAID_LIST caids; ePtr<eDVBService> service; eServiceReferenceDVB ref; eDVBCISlot *tmp = it->cislot; eDVBServicePMTHandler *pmthandler = it->pmthandler; eDVBServicePMTHandler::program p; bool plugged_cis_exist = false; pmthandler->getServiceReference(ref); pmthandler->getService(service); eDebugCI("recheck %p %s", pmthandler, ref.toString().c_str()); for (eSmartPtrList<eDVBCISlot>::iterator ci_it(m_slots.begin()); ci_it != m_slots.end(); ++ci_it) if (ci_it->plugged && ci_it->getCAManager()) { eDebug("Slot %d plugged", ci_it->getSlotID()); ci_it->plugged = false; plugged_cis_exist = true; } // check if this pmt handler has already assigned CI(s) .. and this CI(s) are already running if (!plugged_cis_exist) { while(tmp) { if (!tmp->running_services.empty()) break; tmp=tmp->linked_next; } if (tmp) // we dont like to change tsmux for running services { eDebugCI("already assigned and running CI!/n"); continue; } } if (!pmthandler->getProgramInfo(p)) { int cnt=0; std::set<eDVBServicePMTHandler::program::capid_pair> set(p.caids.begin(), p.caids.end()); for (std::set<eDVBServicePMTHandler::program::capid_pair>::reverse_iterator x(set.rbegin()); x != set.rend(); ++x, ++cnt) caids.push_front(x->caid); if (service && cnt) service->m_ca = caids; } if (service) caids = service->m_ca; if (caids.empty()) continue; // unscrambled service for (eSmartPtrList<eDVBCISlot>::iterator ci_it(m_slots.begin()); ci_it != m_slots.end(); ++ci_it) { eDebugCI("check Slot %d", ci_it->getSlotID()); bool useThis=false; bool user_mapped=true; eDVBCICAManagerSession *ca_manager = ci_it->getCAManager(); if (ca_manager) { int mask=0; if (!ci_it->possible_services.empty()) { mask |= 1; serviceSet::iterator it = ci_it->possible_services.find(ref); if (it != ci_it->possible_services.end()) { eDebug("'%s' is in service list of slot %d... so use it", ref.toString().c_str(), ci_it->getSlotID()); useThis = true; } else // check parent { eServiceReferenceDVB parent_ref = ref.getParentServiceReference(); if (parent_ref) { it = ci_it->possible_services.find(ref); if (it != ci_it->possible_services.end()) { eDebug("parent '%s' of '%s' is in service list of slot %d... so use it", parent_ref.toString().c_str(), ref.toString().c_str(), ci_it->getSlotID()); useThis = true; } } } } if (!useThis && !ci_it->possible_providers.empty()) { eDVBNamespace ns = ref.getDVBNamespace(); mask |= 2; if (!service) // subservice? { eServiceReferenceDVB parent_ref = ref.getParentServiceReference(); eDVBDB::getInstance()->getService(parent_ref, service);//.........这里部分代码省略.........
开发者ID:antivirtel,项目名称:enigma2,代码行数:101,
示例26: movevoid mainWindow::mouseReleaseEvent(QMouseEvent *e){ int dx = e->globalX()-last.x(); int dy = e->globalY()-last.y(); move(x()+dx, y()+dy);}
开发者ID:xingzb14,项目名称:wordProject,代码行数:6,
示例27: yIntRect::operator gfx::Rect() const { return gfx::Rect(x(), y(), width(), height());}
开发者ID:mirror,项目名称:chromium,代码行数:3,
注:本文中的x函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ x0函数代码示例 C++ wxstr函数代码示例 |