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


C++ scale函数代码示例

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


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

示例1: synth_half

/*
 * NAME:	synth->half()
 * DESCRIPTION:	perform half frequency PCM synthesis
 */
static
void synth_half(struct mad_synth *synth, struct mad_frame /*const*/ *frame,
		unsigned int nch, unsigned int ns)
{
  unsigned int phase, ch, s, sb, pe, po;
  short int *pcm1, *pcm2;
  mad_fixed_t (*filter)[2][2][16][8];
  mad_fixed_t (*sbsample)[36][32];
  register mad_fixed_t (*fe)[8], (*fx)[8], (*fo)[8];
  register mad_fixed_t const (*Dptr)[32], *ptr ;
  register mad_fixed64hi_t hi;
  register mad_fixed64lo_t lo;
  mad_fixed_t raw_sample;
  
  static short int short_sample_buff[16];

  phase = synth->phase;

  for (s = 0; s < ns; ++s)
  {
    memset (short_sample_buff, 0x00, sizeof(short_sample_buff));

    for (ch = 0; ch < nch; ++ch)
    {
      sbsample = &frame->sbsample[ch];
      filter   = &synth->filter[ch];      
      pcm1     = short_sample_buff;

      dct32((*sbsample)[s], phase >> 1,
	    (*filter)[0][phase & 1], (*filter)[1][phase & 1]);

      pe = phase & ~1;
      po = ((phase - 1) & 0xf) | 1;

      /* calculate 16 samples */

      fe = &(*filter)[0][ phase & 1][0];
      fx = &(*filter)[0][~phase & 1][0];
      fo = &(*filter)[1][~phase & 1][0];

      Dptr = &D[0];

      ptr = *Dptr + po;
      ML0(hi, lo, (*fx)[0], ptr[ 0]);
      MLA(hi, lo, (*fx)[1], ptr[14]);
      MLA(hi, lo, (*fx)[2], ptr[12]);
      MLA(hi, lo, (*fx)[3], ptr[10]);
      MLA(hi, lo, (*fx)[4], ptr[ 8]);
      MLA(hi, lo, (*fx)[5], ptr[ 6]);
      MLA(hi, lo, (*fx)[6], ptr[ 4]);
      MLA(hi, lo, (*fx)[7], ptr[ 2]);
      MLN(hi, lo);

      ptr = *Dptr + pe;
      MLA(hi, lo, (*fe)[0], ptr[ 0]);
      MLA(hi, lo, (*fe)[1], ptr[14]);
      MLA(hi, lo, (*fe)[2], ptr[12]);
      MLA(hi, lo, (*fe)[3], ptr[10]);
      MLA(hi, lo, (*fe)[4], ptr[ 8]);
      MLA(hi, lo, (*fe)[5], ptr[ 6]);
      MLA(hi, lo, (*fe)[6], ptr[ 4]);
      MLA(hi, lo, (*fe)[7], ptr[ 2]);

      raw_sample = SHIFT(MLZ(hi, lo));
      raw_sample = scale(raw_sample);
      (*pcm1++) += (short int)raw_sample;
      pcm2 = pcm1 + 14;

      for (sb = 1; sb < 16; ++sb)
      {
        ++fe;
        ++Dptr;

        /* D[32 - sb][i] == -D[sb][31 - i] */

        ptr = *Dptr + po;
        ML0(hi, lo, (*fo)[0], ptr[ 0]);
        MLA(hi, lo, (*fo)[1], ptr[14]);
        MLA(hi, lo, (*fo)[2], ptr[12]);
        MLA(hi, lo, (*fo)[3], ptr[10]);
        MLA(hi, lo, (*fo)[4], ptr[ 8]);
        MLA(hi, lo, (*fo)[5], ptr[ 6]);
        MLA(hi, lo, (*fo)[6], ptr[ 4]);
        MLA(hi, lo, (*fo)[7], ptr[ 2]);
        MLN(hi, lo);

        ptr = *Dptr + pe;
        MLA(hi, lo, (*fe)[7], ptr[ 2]);
        MLA(hi, lo, (*fe)[6], ptr[ 4]);
        MLA(hi, lo, (*fe)[5], ptr[ 6]);
        MLA(hi, lo, (*fe)[4], ptr[ 8]);
        MLA(hi, lo, (*fe)[3], ptr[10]);
        MLA(hi, lo, (*fe)[2], ptr[12]);
        MLA(hi, lo, (*fe)[1], ptr[14]);
        MLA(hi, lo, (*fe)[0], ptr[ 0]);

//.........这里部分代码省略.........
开发者ID:KYHuang,项目名称:arm-mp3-player,代码行数:101,代码来源:synth.c

示例2: scale

		void GRect::scale(double scl) 
		{ 
			scale(scl,scl);
		}
开发者ID:ViacheslavN,项目名称:GIS,代码行数:4,代码来源:Rect.cpp

示例3: transform

void PianoView::wheelEvent(QWheelEvent* event)
      {
      int step = event->delta() / 120;
      double xmag = transform().m11();
      double ymag = transform().m22();

      if (event->modifiers() == Qt::ControlModifier) {
            if (step > 0) {
                  for (int i = 0; i < step; ++i) {
                        if (xmag > 10.0)
                              break;
                        scale(1.1, 1.0);
                        xmag *= 1.1;
                        }
                  }
            else {
                  for (int i = 0; i < -step; ++i) {
                        if (xmag < 0.001)
                              break;
                        scale(.9, 1.0);
                        xmag *= .9;
                        }
                  }
            emit magChanged(xmag, ymag);

            int tpix  = (480 * 4) * xmag;
            magStep = -5;
            if (tpix <= 4000)
                  magStep = -4;
            if (tpix <= 2000)
                  magStep = -3;
            if (tpix <= 1000)
                  magStep = -2;
            if (tpix <= 500)
                  magStep = -1;
            if (tpix <= 128)
                  magStep = 0;
            if (tpix <= 64)
                  magStep = 1;
            if (tpix <= 32)
                  magStep = 2;
            if (tpix <= 16)
                  magStep = 3;
            if (tpix <= 8)
                  magStep = 4;
            if (tpix <= 4)
                  magStep = 5;
            if (tpix <= 2)
                  magStep = 6;

            //
            // if xpos <= 0, then the scene is centered
            // there is no scroll bar anymore sending
            // change signals, so we have to do it here:
            //
            double xpos = -(mapFromScene(QPointF()).x());
            if (xpos <= 0)
                  emit xposChanged(xpos);
            }
      else if (event->modifiers() == Qt::ShiftModifier) {
            QWheelEvent we(event->pos(), event->delta(), event->buttons(), 0, Qt::Horizontal);
            QGraphicsView::wheelEvent(&we);
            }
      else if (event->modifiers() == 0) {
            QGraphicsView::wheelEvent(event);
            }
      else if (event->modifiers() == (Qt::ShiftModifier | Qt::ControlModifier)) {
            if (step > 0) {
                  for (int i = 0; i < step; ++i) {
                        if (ymag > 3.0)
                              break;
                        scale(1.0, 1.1);
                        ymag *= 1.1;
                        }
                  }
            else {
                  for (int i = 0; i < -step; ++i) {
                        if (ymag < 0.4)
                              break;
                        scale(1.0, .9);
                        ymag *= .9;
                        }
                  }
            emit magChanged(xmag, ymag);
            }
      }
开发者ID:WeiChou,项目名称:MuseScore,代码行数:86,代码来源:pianoview.cpp

示例4: toHours

 virtual uint64_t toHours(const uint64_t d) {
     return scale(d, (C6 / C5), (TimeUnit::MAX / (C6 / C5)));
 }
开发者ID:janvierja,项目名称:decaf,代码行数:3,代码来源:TimeUnit.hpp

示例5: framesToRun

/* ------------------------------------------------------------------ run --- */
int BASE::run()
{
	int	i = 0;
	double roomsig[2][BUFLEN], rvbsig[2][BUFLEN];

	const int totalSamps = insamps + tapcount;

	const int frameCount = framesToRun();
	
	DBG1(printf("%s::run(): totalSamps = %d\n", name(), totalSamps));

	// this will return frameCount' worth of input, even if we have
	// passed the end of the input (will produce zeros)

	getInput(cursamp, frameCount);

	DBG1(printf("getInput(%d, %d) called\n", cursamp, frameCount));
	
	int bufsamps = getBufferSize();
	
	// loop for required number of output samples

	while (i < frameCount) {
		// limit buffer size to end of current pull (chunksamps)
		if (frameCount - i < bufsamps)
			bufsamps = max(0, frameCount - i);

		DBG1(printf("top of main loop: i = %d  cursamp = %d  bufsamps = %d\n",
				   i, cursamp, bufsamps));
		DBG(printf("input signal:\n"));
		DBG(PrintInput(&in[i], bufsamps));
		
		// add signal to delay
		put_tap(cursamp, &in[i], bufsamps);

		// if processing input signal or flushing delay lines ... 

		if (cursamp < totalSamps) {
			// limit buffer size of end of input data
			if (totalSamps - cursamp < bufsamps)
				bufsamps = max(0, totalSamps - cursamp);
			
			if ((tapcount = updatePosition(cursamp)) < 0)
				return PARAM_ERROR;

			DBG1(printf("  inner loop: bufsamps = %d\n", bufsamps));
		
			for (int ch = 0; ch < 2; ch++) {
				for (int path = 0; path < 13; path++) {
					Vector *vec = &m_vectors[ch][path];
					DBG(printf("vector[%d][%d]:\n", ch, path));
					/* get delayed samps */
					get_tap(cursamp, ch, path, bufsamps);
					DBG(PrintSig(vec->Sig, bufsamps));   
					/* air absorpt. filters */
		 				air(vec->Sig, bufsamps, vec->Airdata);			
					/* wall absorpt. filters */
					if (path > 0)	// no filtering of direct signal
		 				wall(vec->Sig, bufsamps, vec->Walldata);
					/* do binaural angle filters if necessary*/
					if (m_binaural)						
						fir(vec->Sig, cursamp, g_Nterms[path], 
							vec->Fircoeffs, vec->Firtaps, bufsamps);
		   				// sum unscaled reflected paths as input for RVB.
					// first path is set; the rest are summed
					if (path == 1)
						copyBuf(&roomsig[ch][0], vec->Sig, bufsamps);			 
					else if (path > 1)
						addBuf(&roomsig[ch][0], vec->Sig, bufsamps);			 
					/* now do cardioid mike effect if not binaural mode */
					if (!m_binaural)
						scale(vec->Sig, bufsamps, vec->MikeAmp);
					DBG(printf("after final scale before rvb:\n"));
					DBG(PrintSig(vec->Sig, bufsamps, 0.1));
		 		}
				/* scale reverb input by amp factor */
				scale(&roomsig[ch][0], bufsamps, m_rvbamp);
			}
			/* run 1st and 2nd generation paths through reverberator */
 			for (int n = 0; n < bufsamps; n++) {
				if (m_rvbamp != 0.0) {
					double rmPair[2];
					double rvbPair[2];
					rmPair[0] = roomsig[0][n];
					rmPair[1] = roomsig[1][n];
					RVB(rmPair, rvbPair, cursamp + n);
					rvbsig[0][n] = rvbPair[0];
					rvbsig[1][n] = rvbPair[1];
				}
				else
					rvbsig[0][n] = rvbsig[1][n] = 0.0;
			}
			DBG(printf("summing vectors\n"));
			if (!m_binaural) {
		   		// re-sum scaled direct and reflected paths as early response
				// first path is set; the rest are summed
				for (int path = 0; path < 13; path++) {
					if (path == 0) {
						copyBuf(&roomsig[0][0], m_vectors[0][path].Sig, bufsamps);
//.........这里部分代码省略.........
开发者ID:RTcmix,项目名称:RTcmix,代码行数:101,代码来源:BASE.cpp

示例6: toMicros

 virtual uint64_t toMicros(const uint64_t d) {
     return scale(d, (C6 / C1), (TimeUnit::MAX / (C6 / C1)));
 }
开发者ID:janvierja,项目名称:decaf,代码行数:3,代码来源:TimeUnit.hpp

示例7: toSeconds

 virtual uint64_t toSeconds(const uint64_t d) {
     return scale(d, (C6 / C3), (TimeUnit::MAX / (C6 / C3)));
 }
开发者ID:janvierja,项目名称:decaf,代码行数:3,代码来源:TimeUnit.hpp

示例8: ortho

void LifeCounter::Draw(mat4 view, mat4 projection) {
	projection = ortho(0.0f, 20.0f * (scene->width / (float)scene->height), 0.0f, 20.0f, -20.0f, 20.0f);
	for(int i=0; i<lives; i++) {
		Content::shader(basic).Begin();
			mat4 model = translation(position + vec3(i * icon.size.x, 0, 0))  * mat4_cast(orientation) * scale(size);
			model = model;
			glUniformMatrix4fv(Content::shader(basic)("inv_view"), 1, GL_FALSE, &(model[0][0]));
			icon.Draw(model, projection);
		Content::shader(basic).End();
	}
}
开发者ID:shader,项目名称:asteroids,代码行数:11,代码来源:life_counter.cpp

示例9: wbox

void ConvexShape::_renderDebug( ObjectRenderInst *ri, SceneRenderState *state, BaseMatInstance *mat )
{   
   GFXDrawUtil *drawer = GFX->getDrawUtil();

   GFX->setTexture( 0, NULL );

   // Render world box.
   if ( false )
   {
      Box3F wbox( mWorldBox );
      //if ( getServerObject() )      
      //   Box3F wbox = static_cast<ConvexShape*>( getServerObject() )->mWorldBox;      
      GFXStateBlockDesc desc;
      desc.setCullMode( GFXCullNone );
      desc.setFillModeWireframe();
      drawer->drawCube( desc, wbox, ColorI::RED );
   }


   const Vector< Point3F > &pointList = mGeometry.points;
	const Vector< ConvexShape::Face > &faceList = mGeometry.faces;

   // Render Edges.
   if ( false )
   {
      GFXTransformSaver saver;
      //GFXFrustumSaver fsaver;

      MatrixF xfm( getRenderTransform() );
      xfm.scale( getScale() );
      GFX->multWorld( xfm );

      GFXStateBlockDesc desc;
      desc.setZReadWrite( true, false );
      desc.setBlend( true );
      GFX->setStateBlockByDesc( desc );

      //MathUtils::getZBiasProjectionMatrix( 0.01f, state->getFrustum(), )

      const Point3F &camFvec = state->getCameraTransform().getForwardVector();



      for ( S32 i = 0; i < faceList.size(); i++ )
      {         
         const ConvexShape::Face &face = faceList[i];
         
         const Vector< ConvexShape::Edge > &edgeList = face.edges;

         const Vector< U32 > &facePntList = face.points;

         PrimBuild::begin( GFXLineList, edgeList.size() * 2 );
         
         PrimBuild::color( ColorI::WHITE * 0.8f );

         for ( S32 j = 0; j < edgeList.size(); j++ )         
         {
            PrimBuild::vertex3fv( pointList[ facePntList[ edgeList[j].p0 ] ] - camFvec * 0.001f );
            PrimBuild::vertex3fv( pointList[ facePntList[ edgeList[j].p1 ] ] - camFvec * 0.001f );
         }
         
         PrimBuild::end();
      }
   }

   ColorI faceColorsx[4] = 
   {
      ColorI( 255, 0, 0 ),
      ColorI( 0, 255, 0 ),
      ColorI( 0, 0, 255 ),
      ColorI( 255, 0, 255 )
   };

   MatrixF objToWorld( mObjToWorld );
   objToWorld.scale( mObjScale );

   // Render faces centers/colors.
   if ( false )
   {
      GFXStateBlockDesc desc;
      desc.setCullMode( GFXCullNone );
      
      Point3F size( 0.1f );

      for ( S32 i = 0; i < faceList.size(); i++ )
      {
         ColorI color = faceColorsx[ i % 4 ];
         S32 div = ( i / 4 ) * 4;
         if ( div > 0 )
            color /= div;
         color.alpha = 255;
         
         Point3F pnt;
         objToWorld.mulP( faceList[i].centroid, &pnt );
         drawer->drawCube( desc, size, pnt, color, NULL );
      }
   }

   // Render winding order.
   if ( false )
//.........这里部分代码省略.........
开发者ID:Acidburn0zzz,项目名称:Torque3D,代码行数:101,代码来源:convexShape.cpp

示例10: scale

void NavigationView::zoomIn()
{
	if (transform().m11() * ZOOMFACTOR <= MAXZOOM)	// m11 = horizontal scaling factor
		scale(ZOOMFACTOR, ZOOMFACTOR);				// of the scene.
}
开发者ID:StephenCEI,项目名称:2011,代码行数:5,代码来源:NavigationView.cpp

示例11: LOGV


//.........这里部分代码省略.........
                break;
            }
            case LANDSCAPE: { // Landscape (home button at right)

                if (prevOrientation == PORTRAIT) {

                    mRotation += (2.f * PI_F);
                    mRotateVel += (2.f * PI_F);
                }
                else if (ACCEL_CHANGED(mCurAccel.Y, y))
                    mRotateVel = (y * -ACCEL_TO_ROTATION) + ((3.f * PI_F) / 2.f);
                break;
            }
            case REV_LANDSCAPE: { // Reversed landscape

                if (ACCEL_CHANGED(mCurAccel.Y, y))
                    mRotateVel = (y * ACCEL_TO_ROTATION) + (PI_F / 2.f);
                break;
            }
            case FLAT: // Flat
            case REVERSED: { // Reversed

                if ((!ACCEL_CHANGED(mCurAccel.X, x)) && (!ACCEL_CHANGED(mCurAccel.Y, y)))
                    break;

                static unsigned char prevPos = 0;
                if ((y > 0.f) && (x < 0.f)) {

                    mRotateVel = std::atan(-x / y);
                    prevPos = 0;
                }
                else if ((y < 0.f) && (x < 0.f)) {

                    mRotateVel = std::atan(y / x) + (PI_F / 2.f);
                    prevPos = 0;
                }
                else if ((y < 0.f) && (x > 0.f)) {

                    if (prevPos == 2)
                        mRotation += (2.f * PI_F);
                    mRotateVel = PI_F - std::atan(x / y);
                    prevPos = 1;
                }
                else if ((y > 0.f) && (x > 0.f)) { // 'else if' instead of 'else' coz 'y' must be > 0

                    if (prevPos == 1)
                        mRotation -= (2.f * PI_F);
                    mRotateVel = -std::atan(x / y);
                    prevPos = 2;
                }
                //else // 'x' & 'y' are equal to 0: Nothing to do
                break;
            }
        }
        if (ACCEL_CHANGED(mCurAccel.X, x)) mCurAccel.X = x;
        if (ACCEL_CHANGED(mCurAccel.Y, y)) mCurAccel.Y = y;
        if (ACCEL_CHANGED(mCurAccel.Z, z)) mCurAccel.Z = z;

        mRotation = mRotation - ((mRotation - mRotateVel) / VELOCITY);
        rotate(ROTATION_CORRECTION + mRotation);
    }

    // Hide & Display response
    if (mCancel) {

        if (getAlpha() < ALPHA_VEL_A) {

            mToDisplay = 0;
            mToRender = false;
            mCancel = false;
            mForce = false;
        }
        else
            setAlpha(getAlpha() - (ALPHA_VEL_A * game->getDelta() / DELTA_REF));

        if (mScale < MAX_SCALE) {

            mScale += (SCALE_VELOCITY * game->getDelta() / DELTA_REF);
            scale(mScale, mScale);
        }
        return;
    }

    if (mForce) {

        mScale = MAX_SCALE;
        //setAlpha(MAX_ALPHA); // Let caller manage this
        scale(MAX_SCALE, MAX_SCALE);
        return;
    }
    if (getAlpha() < ((mToDisplay == RESPONSE_ID_STORES)? 1.f:MAX_ALPHA)) {

        setAlpha(getAlpha() + (ALPHA_VEL_A * game->getDelta() / DELTA_REF));
        if (mScale < MAX_SCALE) {

            mScale += (SCALE_VELOCITY * game->getDelta() / DELTA_REF);
            scale(mScale, mScale);
        }
    }
}
开发者ID:STUDIO-Artaban,项目名称:Kaleidoscope,代码行数:101,代码来源:Response.cpp

示例12: scene

void NavigationView::zoomOut()
{
	if (scene()->width() * transform().m11() / ZOOMFACTOR >= width() &&
		scene()->height() * transform().m11() / ZOOMFACTOR >= height())
		scale(1.0 / ZOOMFACTOR, 1.0 / ZOOMFACTOR);
}
开发者ID:StephenCEI,项目名称:2011,代码行数:6,代码来源:NavigationView.cpp

示例13: bb_scan

void bb_scan(tld::TldStruct& tld, Eigen::Vector4d const & bb,
		Eigen::Vector2i imsize, int minwin) {
	double shift = 0.1;
	//used for scaling the bb
	Eigen::VectorXd scale(21);
	scale << -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
	for (unsigned int i = 0; i < 21; i++)
		scale(i) = pow(1.2, scale(i));
	int minBB = minwin;

	if (bb_width(bb) < minwin)
		return;

	Eigen::VectorXd bbW(21);
	//scale bb on x axis
	for (unsigned int x = 0; x < 21; x++) {
		bbW(x) = floor((bb_width(bb) * scale(x)) + 0.5);
	}

	Eigen::VectorXd bbH(21);
	//scale bb on y axis
	for (unsigned int x = 0; x < 21; x++) {
		bbH(x) = floor((bb_height(bb) * scale(x)) + 0.5);
	}

	Eigen::VectorXd bbSHH(21);
	Eigen::VectorXd bbSHW(21);
	//shift the scales
	for (unsigned int x = 0; x < 21; x++)
		bbSHH(x) = bbH(x) * shift;

	for (unsigned int x = 0; x < 21; x++) {
		if (bbH(x) <= bbW(x))
			bbSHW(x) = bbH(x) * shift;
		else
			bbSHW(x) = bbW(x) * shift;
	}

	Eigen::VectorXd bbF(4);
	bbF << 2, 2, imsize(0), imsize(1);
	Eigen::Matrix<double, 6, Eigen::Dynamic> bbs;
	Eigen::Matrix<double, 6, Eigen::Dynamic> bbsbak;
	Eigen::Matrix<double, 2, Eigen::Dynamic> sca;
	//create a grid of bounding boxes with different scales
	for (unsigned int i = 0, last_scale = 0; i < 21; i++) {
		if (bbW(i) < minBB || bbH(i) < minBB)
			continue;
		Eigen::VectorXd left;
		Eigen::VectorXd leftbak;
		Eigen::VectorXd top;
		Eigen::VectorXd topbak;
		double val;

		val = bbF(0);
		for (unsigned int p = 0; val <= bbF(2) - bbW(i) - 1; val += bbSHW(i), p++) {
			leftbak.resize(left.size());
			leftbak = left;
			left.resize(p + 1);
			if (p > 0)
				left << leftbak, floor(val + 0.5);
			else
				left(0) = floor(val + 0.5);
		}

		if(left.size() == 0)
			continue;

		val = bbF(1);
		for (unsigned int p = 0; val <= bbF(3) - bbH(i) - 1; val += bbSHH(i), p++) {
			topbak.resize(top.size());
			topbak = top;
			top.resize(p + 1);
			if (p > 0)
				top << topbak, floor(val + 0.5);
			else
				top(0) = floor(val + 0.5);
		}

		if(top.size() == 0)
			continue;

		Eigen::MatrixXd grid(2, top.size() * left.size());

		unsigned int cnt = 0;
		for (int k = 0; k < left.size(); k++)
			for (int w = 0; w < top.size(); w++) {
				grid(0, cnt) = top(w);
				grid(1, cnt) = left(k);
				cnt++;
			}

		Eigen::MatrixXd bbsnew(6, grid.cols());
		bbsnew.row(0) = grid.row(1);
		bbsnew.row(1) = grid.row(0);
		bbsnew.row(2) = grid.array().row(1) + bbW(i) - 1;
		bbsnew.row(3) = grid.array().row(0) + bbH(i) - 1;
		bbsnew.row(4) = Eigen::MatrixXd::Constant(1, grid.cols(), last_scale + 1);
		bbsnew.row(5) = Eigen::MatrixXd::Constant(1, grid.cols(), left.size());
		bbsbak.resize(6, bbs.cols());
		bbsbak = bbs;
//.........这里部分代码省略.........
开发者ID:Lajnold,项目名称:OpenTLDC,代码行数:101,代码来源:bb_scan.cpp

示例14: multiplyMatrixScalar

//Here starts the main program when testing Multiply Matrix_Scalar
void multiplyMatrixScalar()
{

    agile::GPUTimer Timer;

    double timer_value;


    //Initialisation of the Output Text File
    std::fstream myfile;
    const char * file_name = "../test/gpu_matrix_vs_gpu_matrix_pitched/Timer Results";
    myfile.open (file_name, std::fstream::out);

    if (!myfile.is_open())
    {
        std::cerr << "File not found: " << file_name << std::endl;
    }

    // Create a vector first on the CPU and transfer it to the GPU.
    std::vector<TType> result_vector_CUBLAS_host;
    std::vector<TType> result_vector_CUDA_host;
    // Create a dense matrix on the CPU. The elements are stored in row-major order.
    std::vector<TType> matrix_host;


    //GPU Matrix A (CUBLAS)
    agile::GPUMatrix<TType> Matrix_CUBLAS;
    //pitched GPU_Matrix B (CUDA)
    agile::GPUMatrixPitched<TType> Matrix_CUDA;

    //GPU Matrix for Result  (CUBLAS)
    agile::GPUMatrix<TType> ResultMatrix_CUBLAS;
    //pitched GPU_Matrix for Result (CUDA)
    agile::GPUMatrixPitched<TType> ResultMatrix_CUDA;

    //Delete Vector Contents and set size back to 0
    matrix_host.clear();
    result_vector_CUDA_host.clear();
    result_vector_CUDA_host.clear();

    TType alpha = 10.123456789;

    unsigned int num_rows;
    unsigned int num_columns;

    //myfile << "\n\tMultiply Matrix Scalar CUBLAS";
    for(unsigned test_ctr = 1; test_ctr <= 1000; test_ctr++)
    {

        num_rows = test_ctr;
        num_columns = test_ctr;

        //create Matrix
        for (unsigned row = 0; row < num_rows; ++row)
            for (unsigned column = 0; column < num_columns; ++column)
            {
                if((column % 2) == 1)
                {
                    matrix_host.push_back((row % 30 + 1)*(column % 30 + 1));
                }
                else
                {
                    matrix_host.push_back((row % 30 + 1)*(column % 30 + 1)*(-1));
                }


            }

        //Transfer the Matrix data from the Host to the GPUMatrix
        Matrix_CUBLAS.assignFromHost(num_rows, num_columns, &matrix_host[0]);
        Matrix_CUDA.assignFromHost(num_rows, num_columns, &matrix_host[0]);

        ResultMatrix_CUBLAS.assignFromHost(num_rows, num_columns, NULL);
        ResultMatrix_CUDA.assignFromHost(num_rows, num_columns, NULL);

        matrix_host.clear();
        result_vector_CUDA_host.clear();
        result_vector_CUDA_host.clear();

        //Multiply Matrix Scalar CUDA
        //start Timer
        Timer.start();
        for(unsigned i=0; i<2000; i++)
        {
            // Now we can use our matrix. Perform the matrix-scalar product
            // \f$ y \leftarrow Ax \f$.
            scale(alpha, Matrix_CUDA, ResultMatrix_CUDA);
        }
        //stop Timer and write Timer Values to std::cout and file
        timer_value = Timer.stop();
        myfile << std::endl << num_rows << "\t" << num_columns << "\t" << std::setprecision(8)<< timer_value;
        std::cout << std::endl << "NumRows: " << num_rows << "   NumColumns: " << num_columns << "   ------>    CUDA: " << std::setprecision(8)<< timer_value << "[ms]";
        //End Multiply Matrix Vector CUDA

        ResultMatrix_CUDA.copyToHost(result_vector_CUDA_host);
        timer_value = 0;

        //Multiply Matrix Scalar CUBLAS
        //start Timer
//.........这里部分代码省略.........
开发者ID:IMTtugraz,项目名称:AGILE,代码行数:101,代码来源:gpu_matrix_vs_gpu_matrix_pitched_stdcomplexfloat_edit.cpp

示例15: actionScale

void MainWindow::actionScale()
{
	ui.glCanvas->setScale(scale());
	actionResolution();
}
开发者ID:dev-life,项目名称:gideros,代码行数:5,代码来源:mainwindow.cpp


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