当前位置: 首页>>代码示例>>C++>>正文


C++ dy函数代码示例

本文整理汇总了C++中dy函数的典型用法代码示例。如果您正苦于以下问题:C++ dy函数的具体用法?C++ dy怎么用?C++ dy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

/*
        check if (m_skin_filter != 0 && m_skin_filter->status() == 0) before call
*/
void HaarDetector::skin_filter(char** r, char** g, char** b, const vec2Di* search_mask)
{
        float ivec[3] = {0.0f, 0.0f, 0.0f};    //0.0 ... 1.0f range
        float ovec = 0.0f;

        m_search_mask->set(0);

        unsigned int skin_pixels = 0;
        unsigned int total_pixels = 0;
        for (unsigned int y = dy(); y < m_search_mask->height() - dy(); y++) {
                for (unsigned int x = dx(); x < m_search_mask->width() - dx(); x++) {
                        total_pixels++;

                        if (search_mask != 0 && ((*search_mask)(y, x) == 0))                                 
                                continue;

                        ivec[0] = (float)((int)r[y][x] + 128) / 255.0f;
                        ivec[1] = (float)((int)g[y][x] + 128) / 255.0f;
                        ivec[2] = (float)((int)b[y][x] + 128) / 255.0f;
                        if (m_skin_filter->classify(ivec, &ovec) >= 0) {
                                (*m_search_mask)(y, x) = 1;
                                skin_pixels++;
                        }
                }
        }
        m_skin_amount = float(skin_pixels) / float(total_pixels);

        m_tmp_search_mask->dilate(*m_search_mask, 5, 5);
        m_search_mask->erode(*m_tmp_search_mask, 5, 5);
}
开发者ID:oshaar,项目名称:agenteinteligente-xiller,代码行数:33,代码来源:HaarDetector.cpp

示例2: STKUNIT_UNIT_TEST

STKUNIT_UNIT_TEST(function, stringFunction_derivative)
{
  EXCEPTWATCH;
  for (unsigned ipts = 0; ipts < NPTS; ipts++)
  {
    double x = testpoints[ipts][0];
    double y = testpoints[ipts][1];
    double z = testpoints[ipts][2];
    double t = testpoints[ipts][3];

    // start_demo_stringFunction_derivative
    StringFunction sfxy(" x - y ");
    StringFunction dsfxy_y("-1");
    MDArrayString dy(1,1);
    dy(0,0)="y";
    std::string dy1[1][1] = {{"y"}};
    std::cout << "dy1= " << dy1[0][0] << std::endl;
    //Teuchos::RCP<Function> dsfxy_y_1 = sfxy.derivative(MDArrayString_from(dy1));
    //Teuchos::RCP<Function> dsfxy_y_1 = sfxy.derivative(dy);
    Teuchos::RCP<Function> dsfxy_y_1 = sfxy.derivative_test(dy);


    double         dvxy   = eval(x, y, z, t, *dsfxy_y_1);
    double         dvxy1  = eval(x, y, z, t, dsfxy_y);

    // the two different functions should give the same result
    STKUNIT_EXPECT_DOUBLE_EQ(dvxy, dvxy1);

    // and they should give the same result as C++
    STKUNIT_EXPECT_DOUBLE_EQ(dvxy, -1.0);

    // end_demo
  }
}
开发者ID:gitter-badger,项目名称:quinoa,代码行数:34,代码来源:UnitTestStringFunction.cpp

示例3: main

int main() {

  const int NN = 5;
  const int NNN = 5000;

  double C = 2.2;
  for (double k = -C; k < C; k += (0.1 * C)) {
    double x_0 = C;
    double y_0 = k;
    double x = x_0;
    double y = y_0;
    double c = 0.003;

    c *= fabs(alpha) / alpha;

    printf("draw (%1.4lf*u, %1.4lf*u)\n", x, y);
    for (int i = 0; i < NNN; i++) {
      double ddx = dx(x, y);
      double ddy = dy(x, y);
      double len = l(ddx, ddy);
      x += ddx * c;
      y += ddy * c;
      if (!(i % NN))
        printf("--(%1.4lf*u, %1.4lf*u)\n", x, y);
      if (l2(x, y) > 300) {
        printf("unstable point! \n");
        return -1;
      }
    }
    printf("withpen pencircle scaled 1pt;\n");
  }
  for (double k = -C; k < C; k += (0.1 * C)) {
    double x_0 = k;
    double y_0 = -C;

    double x = x_0;
    double y = y_0;
    double c = 0.003;

    c *= fabs(alpha) / alpha;

    printf("draw (%1.4lf*u, %1.4lf*u)\n", x, y);
    for (int i = 0; i < NNN; i++) {
      double ddx = dx(x, y);
      double ddy = dy(x, y);
      double len = l(ddx, ddy);
      x += ddx * c;
      y += ddy * c;
      if (!(i % NN))
        printf("--(%1.4lf*u, %1.4lf*u)\n", x, y);
      if (l2(x, y) > 300) {
        printf("unstable point! \n");
        return -1;
      }
    }
    printf("withpen pencircle scaled 1pt;\n");
  }
  return 0;
}
开发者ID:tokar1,项目名称:mech-math,代码行数:59,代码来源:main.cpp

示例4: w

double MQ_2::laplace(double x, double y) {
  double result = 0;
  for (int i = 0; i < _data.size() / 4; i++) {
    result += 2.0 * w(i) / core(i, x, y) \
      - w(i) * (dx(i, x) * dx(i, x) + dy(i, y) * dy(i, y)) / pow(core(i, x, y), 3);
  }
  return result;
}
开发者ID:xni,项目名称:Galperin,代码行数:8,代码来源:MQ_2.cpp

示例5: drawSlider

void drawSlider(float y,float value,bool glow,const char *str) {
	float width = .18;
	float height = .05;
	float x5 = dx(.5);
	float x65 = dx(.5+width);
	float xlerp = dx(lerp(.5,.5+width,value));
	float y05 = dy(y+height);
	al_draw_filled_triangle(x5,y05,x65,y05,x65,dy(y),COLOR_SCND);
	al_draw_filled_triangle(x5,y05,xlerp,y05,xlerp,dy(lerp(y+height,y,value)),glow?COLOR_HGHL:COLOR_TEXT);
	al_draw_text(data.font_Regular52,glow?COLOR_HGHL:COLOR_TEXT,px(.49),py(y),ALLEGRO_ALIGN_RIGHT,str);
}
开发者ID:bencz,项目名称:BCC_PI2_chernobyl,代码行数:11,代码来源:settings.c

示例6: SolveKKTSystem

/**
 * Solve the following KKT system (2.10) of [AHO98]:
 *
 *     [ 0  A^T  I ] [ dsx ] = [ rd ]
 *     [ A   0   0 ] [  dy ] = [ rp ]
 *     [ E   0   F ] [ dsz ] = [ rc ]
 *     \---- M ----/
 *
 * where
 *
 *     A  = [ Asparse ]
 *          [ Adense  ]
 *     dy = [ dysparse  dydense ]
 *     E  = Z sym I
 *     F  = X sym I
 *
 */
static inline void
SolveKKTSystem(const arma::sp_mat& Asparse,
               const arma::mat& Adense,
               const arma::mat& Z,
               const arma::mat& M,
               const arma::mat& F,
               const arma::vec& rp,
               const arma::vec& rd,
               const arma::vec& rc,
               arma::vec& dsx,
               arma::vec& dysparse,
               arma::vec& dydense,
               arma::vec& dsz)
{
  arma::mat Frd_rc_Mat, Einv_Frd_rc_Mat,
            Einv_Frd_ATdy_rc_Mat, Frd_ATdy_rc_Mat;
  arma::vec Einv_Frd_rc, Einv_Frd_ATdy_rc, dy;

  // Note: Whenever a formula calls for E^(-1) v for some v, we solve Lyapunov
  // equations instead of forming an explicit inverse.

  // Compute the RHS of (2.12)
  math::Smat(F * rd - rc, Frd_rc_Mat);
  SolveLyapunov(Einv_Frd_rc_Mat, Z, 2. * Frd_rc_Mat);
  math::Svec(Einv_Frd_rc_Mat, Einv_Frd_rc);

  arma::vec rhs = rp;
  const size_t numConstraints = Asparse.n_rows + Adense.n_rows;
  if (Asparse.n_rows)
    rhs(arma::span(0, Asparse.n_rows - 1)) += Asparse * Einv_Frd_rc;
  if (Adense.n_rows)
    rhs(arma::span(Asparse.n_rows, numConstraints - 1)) += Adense * Einv_Frd_rc;

  // TODO(stephentu): use a more efficient method (e.g. LU decomposition)
  if (!arma::solve(dy, M, rhs))
    Log::Fatal << "PrimalDualSolver::SolveKKTSystem(): Could not solve KKT "
        << "system." << std::endl;

  if (Asparse.n_rows)
    dysparse = dy(arma::span(0, Asparse.n_rows - 1));
  if (Adense.n_rows)
    dydense = dy(arma::span(Asparse.n_rows, numConstraints - 1));

  // Compute dx from (2.13)
  math::Smat(F * (rd - Asparse.t() * dysparse - Adense.t() * dydense) - rc,
      Frd_ATdy_rc_Mat);
  SolveLyapunov(Einv_Frd_ATdy_rc_Mat, Z, 2. * Frd_ATdy_rc_Mat);
  math::Svec(Einv_Frd_ATdy_rc_Mat, Einv_Frd_ATdy_rc);
  dsx = -Einv_Frd_ATdy_rc;

  // Compute dz from (2.14)
  dsz = rd - Asparse.t() * dysparse - Adense.t() * dydense;
}
开发者ID:YaweiZhao,项目名称:mlpack,代码行数:70,代码来源:primal_dual_impl.hpp

示例7: switch

double GLGPU3DDataset::Flux(int face) const
{
  // TODO: pre-compute the flux
  switch (face) {
  case 0: return -dx() * dy() * Bz();
  case 1: return -dy() * dz() * Bx(); 
  case 2: return -dz() * dx() * By(); 
  case 3: return  dx() * dy() * Bz(); 
  case 4: return  dy() * dz() * Bx(); 
  case 5: return  dz() * dx() * By();
  default: assert(false);
  }
  return 0.0;
}
开发者ID:ResearchEngr,项目名称:vortexfinder2,代码行数:14,代码来源:GLGPU3DDataset.cpp

示例8: main

int main() {
	
	float x0, y0, h;
	int j, m;
	
	//entrada de dados
	printf("Digite o valor de x inicial: \n");
	scanf("%f", &x0);
	printf("Digite o valor de y inicial: \n");
	scanf("%f", &y0);
	printf("Digite o valor do espacamente h: \n");
	scanf("%f", &h);
	printf("Informe o numero de subintervalos : \n");
	scanf("%d", &m);
	
	float x[m+1], y[m+1];
	x[0] = x0;
	y[0] = y0;
	
	// Calculo pelo metodo de Euler
	for(j = 0; j < m; j++) {
		y[j+1] = y[j] + h*dy(x[j], y[j]);
		x[j+1] = x[j] + h;
	}
	
	// mostrando o resultado
	printf("Os valores de x e y sao: \n");
	for(j = 0; j <= m; j++) {
		printf("%.4f, %.4f\n", x[j], y[j]);
	}
	
	return 0;
}
开发者ID:FelipeGodoy,项目名称:20141PC,代码行数:33,代码来源:MetodoDeEuler.cpp

示例9: qDebug

void Graph::layoutKamadaKawai( int maxiter, qreal epsilon, bool initialize)
{
    qDebug() << "Laying out KamadaKawai";
    if( initialize )
        layoutRandom( 100.0 );
    //layoutNGon();
    if(maxiter < 0)
        maxiter = 65536;
    for(int iteration = 0; iteration < maxiter; ++iteration) {
        uint id = 0;
        qreal maxdelta_m = 0.0;
        for(QMap<uint,Vertex*>::const_iterator i = m_vertices.constBegin();
                i != m_vertices.constEnd(); ++i )
        {
            qreal curdelta_m = qAbs(delta_m(*i));
            //qDebug() << "curdelta_m,maxdelta_m"<< curdelta_m << "\t" << maxdelta_m;
            if( curdelta_m >= maxdelta_m ) {
                maxdelta_m = curdelta_m;
                id = (*i)->id();
            }
        }
        Vertex *m = m_vertices.value(id);
        qreal curdx = dx(m);
        qreal curdy = dy(m);
        qDebug() << "Picked node with id=" << id <<", moving by" << QPointF(curdx,curdy) << " to "<< m->nodePos();
        m->setNodePos( m->nodePos() + QPointF(curdx,curdy) );
        if(qAbs(delta_m(m)) < epsilon ) {
            qDebug() << "Breaking early: iteration, delta_m, epsilon" << iteration << qAbs(delta_m(m)) << epsilon;
            break;
        }
    }
}
开发者ID:sengels,项目名称:kfbgraph,代码行数:32,代码来源:Graph.cpp

示例10: main

void main() {
	IplImage* img;
	CvCapture* cap=cvCaptureFromCAM(0);
	cvNamedWindow("Line Counter", 1);
	CvFont* font1=new CvFont;
	CvFont* font2=new CvFont;
	cvInitFont(font1, CV_FONT_HERSHEY_SIMPLEX, 0.5f, 1.0f, 0, 3, 8);
	cvInitFont(font2, CV_FONT_HERSHEY_SIMPLEX, 0.5f, 1.0f, 0, 2, 8);
	int val=0, axx=0, bxx=0;
	char text[8];
	for (;;) {
		img = cvQueryFrame(cap);
		if (!img) break;
		IplImage* gray1=cvCreateImage(cvSize(img->width, img->height), 8, 1);
		IplImage* edge1=cvCreateImage(cvSize(img->width, 16), 8, 1);
		cvCvtColor(img, gray1, 7);
		extract(gray1, edge1);
		dy(edge1, edge1);
		cvThreshold(edge1, edge1, 10, 255, CV_THRESH_BINARY_INV);
		val=count(edge1);
		if (val==0&&axx==0) { axx=1; }
		if (val==2&&axx==1) { axx=0; bxx++; }
		sprintf(text, "%i", bxx);
		comb(gray1, edge1);
		cvPutText(gray1, text, cvPoint(10, 160), font1, cvScalarAll(255));
		cvPutText(gray1, text, cvPoint(10, 160), font2, cvScalarAll(0));
		cvShowImage("Line Counter", gray1);
		if (cvWaitKey(5) > 0) break;
		cvReleaseImage(&gray1);
		cvReleaseImage(&edge1);
	}
}
开发者ID:ArdWar,项目名称:Kuliah,代码行数:32,代码来源:LineCounter.cpp

示例11: back

	Point back() const
	{
		if (begin_ == end_) {
			BOOST_THROW_EXCEPTION(std::out_of_range("back() cannot be called on empty PointRange."));
		}
		return Point(end_.x - dx(), end_.y - dy());
	}
开发者ID:martong,项目名称:nng2014,代码行数:7,代码来源:PointRange.hpp

示例12: src

 void SobelTest::testManual1()
 {
     m_operator->setParameter(Sobel::PARAMETER_DATA_FLOW, runtime::Enum(Sobel::MANUAL));
     m_operator->initialize();
     m_operator->activate();
     
     runtime::DataContainer src(new cvsupport::Image("lenna.jpg", cvsupport::Image::GRAYSCALE));
     runtime::DataContainer dst(new cvsupport::Image(1000000));
     runtime::Enum ddepth(1);
     runtime::UInt32 dx(2);
     runtime::UInt32 dy(0);
     runtime::UInt32 ksize(3);
     runtime::Float64 scale(1);
     runtime::Float64 delta(0);
     
     m_operator->setInputData(Sobel::INPUT_SRC, src);
     m_operator->setInputData(Sobel::INPUT_DST, dst);
     m_operator->setParameter(Sobel::PARAMETER_DDEPTH, ddepth);
     m_operator->setParameter(Sobel::PARAMETER_DX, dx);
     m_operator->setParameter(Sobel::PARAMETER_DY, dy);
     m_operator->setParameter(Sobel::PARAMETER_KSIZE, ksize);
     m_operator->setParameter(Sobel::PARAMETER_SCALE, scale);
     m_operator->setParameter(Sobel::PARAMETER_DELTA, delta);
     
     runtime::DataContainer dstResult = m_operator->getOutputData(Sobel::OUTPUT_DST);
     
     runtime::ReadAccess dstAccess(dstResult);
     cvsupport::Image::save("SobelTest_testManual1_dst.png", dstAccess.get<runtime::Image>());
 }
开发者ID:uboot,项目名称:stromx-opencv,代码行数:29,代码来源:SobelTest.cpp

示例13: dx

TextStream& SVGFEOffset::externalRepresentation(TextStream& ts) const
{
    ts << "[type=OFFSET] ";
    SVGFilterEffect::externalRepresentation(ts)
            << " [dx=" << dx() << " dy=" << dy() << "]";
    return ts;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:7,代码来源:SVGFEOffset.cpp

示例14: setForeground

//
// Process the Expose event: draw in the window
//
void MyWindow::onExpose(XEvent& event) {
    // Erase a window
    setForeground(getBackground());
    fillRectangle(m_RWinRect);

    // Draw the coordinate axes
    drawAxes("black", true, "gray");

    // Draw a graph of function
    setForeground("red");
    drawGraphic();

    // Draw a cross on mouse click
    if (clicked) {
        if (mouseButton == Button1)
            setForeground("blue");      // Left button
        else if (mouseButton == Button2)
            setForeground("SeaGreen");  // Middle button
        else if (mouseButton == Button3)
            setForeground("brown");     // Right mouse button
        R2Vector dx(0.2, 0.);
        R2Vector dy(0., 0.2);
        drawLine(lastClick-dx, lastClick+dx);
        drawLine(lastClick-dy, lastClick+dy);
    }
}
开发者ID:tokar1,项目名称:mech-math,代码行数:29,代码来源:func.cpp

示例15: cosf

void BaseApp::controls(){
	// Compute directional vectors from euler angles
	float cosX = cosf(wx), sinX = sinf(wx), cosY = cosf(wy), sinY = sinf(wy);
	vec3 dx(cosY, 0, sinY);
	vec3 dy(-sinX * sinY,  cosX, sinX * cosY);
	vec3 dz(-cosX * sinY, -sinX, cosX * cosY);

	vec3 dir(0, 0, 0);
	if (keys[leftKey])     dir -= dx;
	if (keys[rightKey])    dir += dx;
	if (keys[downKey])     dir -= dy;
	if (keys[upKey])       dir += dy;
	if (keys[backwardKey]) dir -= dz;
	if (keys[forwardKey])  dir += dz;

	float lenSq = dot(dir, dir);
	if (lenSq > 0){
		moveCamera(dir * (1.0f / sqrtf(lenSq)));
	}

	dir = vec3(0, 0, 0);
	if (xStrafeAxis >= 0) dir += joystickAxes[xStrafeAxis] * (invertXStrafeAxis? -dx : dx);
	if (yStrafeAxis >= 0) dir += joystickAxes[yStrafeAxis] * (invertYStrafeAxis? -dy : dy);
	if (zStrafeAxis >= 0) dir += joystickAxes[zStrafeAxis] * (invertZStrafeAxis? -dz : dz);

	if (dot(dir, dir) > 0){
		moveCamera(dir);
	}

	if (xTurnAxis >= 0) wx += (invertXTurnAxis? -2.0f : 2.0f) * joystickAxes[xTurnAxis] * frameTime;
	if (yTurnAxis >= 0) wy += (invertYTurnAxis? -2.0f : 2.0f) * joystickAxes[yTurnAxis] * frameTime;
}
开发者ID:DanielNeander,项目名称:my-3d-engine,代码行数:32,代码来源:BaseApp.cpp


注:本文中的dy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。