bool DrawingTouch::update(QBrush *color) { bool wasVisible = false; if (ellipse) { wasVisible = ellipse->isVisible(); ellipse->setVisible(TrackingId() >= 0); } else { ellipse = scene->addEllipse(QRectF(Cx() - radius, Cy() - radius, 2 * radius, 2 * radius)); } if (TrackingId() >= 0) { QRectF rect = ellipse->rect(); rect.moveCenter(QPointF(Cx(), Cy())); ellipse->setRect(rect); ellipse->setPen(Pressed() ? pressedPen : releasedPen); if (!wasVisible) { ellipse->setBrush(*color); ellipse->show(); return true; } } return false; }
typename std::enable_if<is_blas_lapack_type<typename VTX::value_type>::value && have_same_value_type<VTX, VTY, MT>::value>::type ger(typename VTX::value_type alpha, VTX const &X, VTY const &Y, MT &A) { static_assert(is_amv_value_or_view_class<MT>::value, "ger : A must be a matrix or a matrix_view"); if ((first_dim(A) != Y.size()) || (second_dim(A) != X.size())) TRIQS_RUNTIME_ERROR << "Dimension mismatch in ger : A : " << get_shape(A()) << " while X : " << get_shape(X()) << " and Y : " << get_shape(Y()); const_qcache<VTX> Cx(X); // mettre la condition a la main const_qcache<VTY> Cy(Y); // mettre la condition a la main reflexive_qcache<MT> Ca(A); if (Ca().memory_layout_is_c()) // tA += alpha y tx f77::ger(get_n_rows(Ca()), get_n_cols(Ca()), alpha, Cy().data_start(), Cy().stride(), Cx().data_start(), Cx().stride(), Ca().data_start(), get_ld(Ca())); else f77::ger(get_n_rows(Ca()), get_n_cols(Ca()), alpha, Cx().data_start(), Cx().stride(), Cy().data_start(), Cy().stride(), Ca().data_start(), get_ld(Ca())); /* std::cerr << " Meme labout C"<< Ca().memory_layout_is_c() << " "<<A.memory_layout_is_c()<<std::endl ; std::cerr<< " has_contiguous_data(A) : "<< has_contiguous_data(A) << std::endl; std::cerr<< Ca()<< std::endl; std::cerr<< Ca()(0,0) << " "<< Ca()(1,0) << " "<< Ca()(0,1) << " "<< Ca()(1,1) << " "<< std::endl; std::cerr<< Ca().data_start()[0]<< " "<< Ca().data_start()[1]<< " "<< Ca().data_start()[2]<< " " << Ca().data_start()[3]<< " "<<std::endl; std::cerr<< A<< std::endl; std::cerr<< A(0,0) << " "<< A(1,0) << " "<< A(0,1) << " "<< A(1,1) << " "<< std::endl; std::cerr<< A.data_start()[0]<< " "<< A.data_start()[1]<< " "<< A.data_start()[2]<< " " << A.data_start()[3]<< " "<<std::endl; */ }
void SDraw::Init(const Vector<Rect>& rs, int height, Point offset) { Cy(height); Cloff& c = cloff.Add(); c.clip <<= rs; c.offset = offset; }
void SDraw::Init(const Rect& r) { Cy(r.GetHeight()); Cloff& c = cloff.Add(); c.clip.Add(r); c.offset = r.TopLeft(); }
int main() { deque<Pow> all(99*99,0); Cx(99)Cy(99) all[x*99+y] = Pow(x+2,y+2); sort(all.begin(),all.end()); all.assign(all.begin(),unique(all.begin(),all.end())); cout<<all.size()<<endl; }
bool Reference::recalculateStationHeadingCurvature() { if (this->numOfPoints <= 1) { return false; } // Recalculate s for(int i = 0; i < this->numOfPoints ; i++) { if(i == 0) { this->s[0] = 0; } else { double ds = hypot(this->x[i] - this->x[i-1], this->y[i] - this->y[i-1]); this->s[i] = this->s[i-1] + ds; } } // Recalculate theta, k and dk if(this->numOfPoints < NUM_FIT_FRONT + NUM_FIT_BACK + 1) { int i = 0; for( i = 0; i < this->numOfPoints; i++) { if(i == this->numOfPoints - 1) { this->theta[i] = this->theta[i-1]; this->k[i] = 0; break; } this->theta[i] = atan2(this->y[i+1] - this->y[i], this->x[i+1] - this->x[i]); this->k[i] = 0; } } else { for(int i = 0; i < this->numOfPoints; i++) { int id0 = (i-NUM_FIT_FRONT >= 0) ? (i-NUM_FIT_FRONT):(0); int id1 = (i+NUM_FIT_BACK < this->numOfPoints) ? (i+NUM_FIT_BACK):(this->numOfPoints-1); double si, xi, yi, /*ei,*/ chisq; gsl_matrix *S, *cov; gsl_vector *x, *y, *w, *cx, *cy; int n = id1-id0+1; S = gsl_matrix_alloc (n, 3); x = gsl_vector_alloc (n); y = gsl_vector_alloc (n); w = gsl_vector_alloc (n); cx = gsl_vector_alloc (3); cy = gsl_vector_alloc (3); cov = gsl_matrix_alloc (3, 3); for (int j = 0; j < n; j++) { si = this->s[id0+j]; xi = this->x[id0+j]; yi = this->y[id0+j]; gsl_matrix_set (S, j, 0, 1.0); gsl_matrix_set (S, j, 1, si); gsl_matrix_set (S, j, 2, si*si); gsl_vector_set (x, j, xi); gsl_vector_set (y, j, yi); gsl_vector_set (w, j, 1.0); } gsl_multifit_linear_workspace * work = gsl_multifit_linear_alloc (n, 3); gsl_multifit_wlinear (S, w, x, cx, cov, &chisq, work); gsl_multifit_linear_free (work); work = gsl_multifit_linear_alloc (n, 3); gsl_multifit_wlinear (S, w, y, cy, cov, &chisq, work); gsl_multifit_linear_free (work); #define Cx(i) (gsl_vector_get(cx,(i))) #define Cy(i) (gsl_vector_get(cy,(i))) double s_ = this->s[i]; // double x_ = Cx(2) * s_ * s_ + Cx(1) * s_ + Cx(0); double xd_ = 2 * Cx(2) * s_ + Cx(1); double xdd_ = 2 * Cx(2); // double y_ = Cy(2) * s_ * s_ + Cy(1) * s_ + Cy(0); double yd_ = 2 * Cy(2) * s_ + Cy(1); double ydd_ = 2 * Cy(2); this->theta[i] = atan2(yd_, xd_); this->k[i] = (xd_ * ydd_ - yd_ * xdd_) / ( sqrt( (xd_*xd_ + yd_*yd_)*(xd_*xd_ + yd_*yd_)*(xd_*xd_ + yd_*yd_) ) ); gsl_matrix_free(S); gsl_vector_free (x); gsl_vector_free (y); gsl_vector_free (w); gsl_vector_free (cx); gsl_vector_free (cy); gsl_matrix_free (cov); } } return true; }
/* readonly attribute nsIDOMSVGAnimatedLength cy; */ NS_IMETHODIMP SVGRadialGradientElement::GetCy(nsIDOMSVGAnimatedLength * *aCy) { *aCy = Cy().get(); return NS_OK; }