void simulate_MainWindow::simulate() { currInstr=instrList[PC/4]; currBin=binList[PC/4]; vector<string> result; string temp=currInstr.toStdString(); string_split(temp,result); coutString=""; RD=RS=RT=immediate=address=0; v0=v1=v2=v3="None"; v0=result[0]; v1=result[1]; printf("v0=%s\nv1=%s\n",v0.c_str(),v1.c_str()); if(v0=="jr"||v0=="j"||v0=="jal") // 2 parametes { if(v0=="jr") { jr(); } else if(v0=="j") j(); else if(v0=="jal") jal(); } else if(v0=="lui") // 3 parameters { v2=result[2]; lui(); } else // 4 parameters { v2=result[2]; v3=result[3]; if(v0=="add") add(); else if(v0=="addu") addu(); else if(v0=="sub") sub(); else if(v0=="subu") subu(); else if(v0=="and") and_funct(); else if(v0=="or") or_funct(); else if(v0=="xor") xor_funct(); else if(v0=="nor") nor(); else if(v0=="slt") slt(); else if(v0=="sltu") sltu(); else if(v0=="sll") sll(); else if(v0=="srl") srl(); else if(v0=="sllv") sllv(); else if(v0=="srlv") srlv(); else if(v0=="srav") srav(); else if(v0=="addi") addi(); else if(v0=="addiu") addiu(); else if(v0=="andi") andi(); else if(v0=="ori") ori(); else if(v0=="xori") xori(); else if(v0=="sw") sw(); else if(v0=="lw") lw(); else if(v0=="beq") beq(); else if(v0=="bne") bne(); else if(v0=="slti") slti(); else if(v0=="sltiu") sltiu(); } display_all(); }
/// blur[par.Scales+1] is not used in order to look for extrema /// while these could be computed using avalaible blur and dogs void FindMaxMin( flimage* dogs, flimage* blur, float octSize, keypointslist& keys,siftPar &par) { int width = dogs[0].nwidth(), height = dogs[0].nheight(); /* Create an image map in which locations that have a keypoint are marked with value 1.0, to prevent two keypoints being located at same position. This may seem an inefficient data structure, but does not add significant overhead. */ flimage map(width,height,0.0f); flimage grad(width,height,0.0f); flimage ori(width,height,0.0f); /* Search through each scale, leaving 1 scale below and 1 above. There are par.Scales+2 dog images. */ for (int s = 1; s < par.Scales+1; s++) { if (DEBUG) printf("************************scale: %d\n", s); //getchar(); /* For each intermediate image, compute gradient and orientation images to be used for keypoint description. */ compute_gradient_orientation(blur[s].getPlane(), grad.getPlane(), ori.getPlane(), blur[s].nwidth(), blur[s].nheight()); /* Only find peaks at least par.BorderDist samples from image border, as peaks centered close to the border will lack stability. */ assert(par.BorderDist >= 2); float val; int partialcounter = 0; for (int r = par.BorderDist; r < height - par.BorderDist; r++) for (int c = par.BorderDist; c < width - par.BorderDist; c++) { /* Pixel value at (c,r) position. */ val = dogs[s](c,r); /* DOG magnitude must be above 0.8 * par.PeakThresh threshold (precise threshold check will be done once peak interpolation is performed). Then check whether this point is a peak in 3x3 region at each level, and is not on an elongated edge. */ if (fabs(val) > 0.8 * par.PeakThresh) { /* // If local maxima if (LocalMax(val, dogs[s-1], r, c,par) && LocalMax(val, dogs[s], r, c, par) && LocalMax(val, dogs[s+1], r, c,par) && NotOnEdge(dogs[s], r, c, octSize,par)) { if (DEBUG) printf("Maximum Keypoint found (%d,%d,%d) val: %f\n",s,r,c,val); InterpKeyPoint( dogs, s, r, c, grad, ori, map, octSize, keys, 5,par); } else if (LocalMin(val, dogs[s-1], r, c,par) && LocalMin(val, dogs[s], r, c,par) && LocalMin(val, dogs[s+1], r, c,par) && NotOnEdge(dogs[s], r, c, octSize,par)) { if (DEBUG) printf("Minimum Keypoint found (%d,%d,%d) val: %f\n",s,r,c,val); InterpKeyPoint( dogs, s, r, c, grad, ori, map, octSize, keys, 5,par); } */ if (LocalMaxMin(val, dogs[s-1], r, c) && LocalMaxMin(val, dogs[s], r, c) && LocalMaxMin(val, dogs[s+1], r, c) && NotOnEdge(dogs[s], r, c, octSize,par)) { partialcounter++; if (DEBUG) printf("%d: (%d,%d,%d) val: %f\n",partialcounter, s,r,c,val); InterpKeyPoint( dogs, s, r, c, grad, ori, map, octSize, keys, 5,par); //getchar(); } } } } }
Line2d line() { V2d o=ori()*width(); return Line2d(centroid-o,centroid+o); }
void ovm_q_hypot(oregister_t *l, oregister_t *r) { switch (r->t) { case t_void: if (!cfg_float_format) { l->t = t_float; l->v.d = fabs(mpq_get_d(oqr(l))); } else { mpfr_set_ui(orr(r), 0, thr_rnd); goto mpr; } break; case t_word: if (!cfg_float_format) { l->t = t_float; l->v.d = hypot(mpq_get_d(oqr(l)), r->v.w); } else { mpfr_set_si(orr(r), r->v.w, thr_rnd); goto mpr; } break; case t_float: l->t = t_float; l->v.d = hypot(mpq_get_d(oqr(l)), r->v.d); break; case t_mpz: if (!cfg_float_format) { l->t = t_float; l->v.d = hypot(mpq_get_d(oqr(l)), mpz_get_d(ozr(r))); } else { mpfr_set_z(orr(r), ozr(r), thr_rnd); goto mpr; } break; case t_rat: if (!cfg_float_format) { l->t = t_float; l->v.d = hypot(mpq_get_d(oqr(l)), rat_get_d(r->v.r)); } else { mpq_set_si(oqr(r), rat_num(r->v.r), rat_den(r->v.r)); mpfr_set_q(orr(r), oqr(r), thr_rnd); goto mpr; } break; case t_mpq: if (!cfg_float_format) { l->t = t_float; l->v.d = hypot(mpq_get_d(oqr(l)), mpq_get_d(oqr(r))); } else { mpfr_set_q(orr(r), oqr(r), thr_rnd); goto mpr; } break; case t_mpr: mpr: l->t = t_mpr; mpfr_set_q(orr(l), oqr(l), thr_rnd); mpfr_hypot(orr(l), orr(l), orr(r), thr_rnd); break; case t_cdd: cdd: l->t = t_float; l->v.d = hypot(mpq_get_d(oqr(l)), hypot(real(r->v.dd), imag(r->v.dd))); break; case t_cqq: if (!cfg_float_format) { real(r->v.dd) = mpq_get_d(oqr(r)); imag(r->v.dd) = mpq_get_d(oqi(r)); goto cdd; } mpc_set_q_q(occ(r), oqr(r), oqi(r), thr_rndc); case t_mpc: l->t = t_mpr; mpc_set_q(occ(l), oqr(l), thr_rndc); mpfr_hypot(ori(l), orr(l), ori(l), thr_rnd); mpfr_hypot(orr(l), orr(r), ori(r), thr_rnd); mpfr_hypot(orr(l), ori(l), orr(l), thr_rnd); break; default: ovm_raise(except_not_a_number); } }
void CameraAnimator::initCameraMoveToLight( const dp::sg::core::LightSourceWeakPtr & targetLight ) // should be a dp::sg::core::LightSourceWeakPtr { DP_ASSERT( m_viewState->getCamera().isPtrTo<dp::sg::core::FrustumCamera>() ); m_cameraMoveStart = m_viewState->getCamera().clone().staticCast<dp::sg::core::FrustumCamera>(); m_cameraMoveTarget = m_cameraMoveStart.clone(); dp::sg::core::LightSourceSharedPtr lsh( targetLight->getSharedPtr<dp::sg::core::LightSource>() ); { DP_ASSERT( lsh->getLightEffect() ); dp::sg::core::EffectDataSharedPtr const& le = lsh->getLightEffect(); const dp::fx::SmartEffectSpec & es = le->getEffectSpec(); for ( dp::fx::EffectSpec::iterator it = es->beginParameterGroupSpecs() ; it != es->endParameterGroupSpecs() ; ++it ) { const dp::sg::core::ParameterGroupDataSharedPtr & parameterGroupData = le->getParameterGroupData( it ); if ( parameterGroupData ) { std::string name = (*it)->getName(); if ( ( name == "standardDirectedLightParameters" ) || ( name == "standardPointLightParameters" ) || ( name == "standardSpotLightParameters" ) ) { const dp::fx::SmartParameterGroupSpec & pgs = parameterGroupData->getParameterGroupSpec(); if ( name == "standardDirectedLightParameters" ) { m_cameraMoveTarget->setDirection( parameterGroupData->getParameter<dp::math::Vec3f>( pgs->findParameterSpec( "direction" ) ) ); } else if ( name == "standardPointLightParameters" ) { dp::math::Vec3f position = parameterGroupData->getParameter<dp::math::Vec3f>( pgs->findParameterSpec( "position" ) ); m_cameraMoveTarget->setPosition( position ); // point us in the direction of the scene center.. if ( m_viewState->getScene()->getRootNode() ) { dp::math::Vec3f forward = m_viewState->getScene()->getRootNode()->getBoundingSphere().getCenter() - position; dp::math::Vec3f worldup( 0.f, 1.f, 0.f ); //pc->getUpVector(); dp::math::Vec3f right = forward ^ worldup; dp::math::Vec3f up = right ^ forward; normalize( forward ); normalize( right ); normalize( up ); // X east, Y up, -Z north dp::math::Mat33f lookat( dp::util::makeArray( right[0], right[1], right[2], up[0], up[1], up[2], -forward[0], -forward[1], -forward[2] ) ); dp::math::Quatf ori( lookat ); m_cameraMoveTarget->setOrientation( ori ); } } else { m_cameraMoveTarget->setPosition( parameterGroupData->getParameter<dp::math::Vec3f>( pgs->findParameterSpec( "position" ) ) ); m_cameraMoveTarget->setDirection( parameterGroupData->getParameter<dp::math::Vec3f>( pgs->findParameterSpec( "direction" ) ) ); } break; } } } } cameraMoveDurationFactor( determineDurationFactor() ); }
void BulletConstraintSolver() { btPgsSolver pgs; btContactSolverInfo info; rbs.resize(0); for (int i=0;i<numRigidBodies;i++) { btRigidBody& rb = rbs.expandNonInitializing(); rb.m_companionId=-1; rb.m_angularFactor.setValue(1,1,1); rb.m_anisotropicFriction.setValue(1,1,1); rb.m_invMass = bodies[i].getMassInv(); rb.m_linearFactor.setValue(1,1,1); btVector3 pos(states[i].getPosition().getX(),states[i].getPosition().getY(),states[i].getPosition().getZ()); rb.m_worldTransform.setIdentity(); btQuaternion orn(states[i].getOrientation().getX(),states[i].getOrientation().getY(),states[i].getOrientation().getZ(),states[i].getOrientation().getW()); rb.m_worldTransform.setRotation(orn); rb.m_worldTransform.setOrigin(pos); PfxMatrix3 ori(states[i].getOrientation()); rb.m_worldTransform.setRotation(orn); PfxMatrix3 inertiaInvWorld = ori * bodies[i].getInertiaInv() * transpose(ori); rb.m_invInertiaWorld.setIdentity(); if (rb.m_invMass) { for (int row=0;row<3;row++) { for (int col=0;col<3;col++) { rb.m_invInertiaWorld[col][row] = inertiaInvWorld.getElem(col,row); } } } else { rb.m_invInertiaWorld = btMatrix3x3(0,0,0,0,0,0,0,0,0); } rb.m_linearVelocity.setValue(states[i].getLinearVelocity().getX(),states[i].getLinearVelocity().getY(),states[i].getLinearVelocity().getZ()); rb.m_angularVelocity.setValue(states[i].getAngularVelocity().getX(),states[i].getAngularVelocity().getY(),states[i].getAngularVelocity().getZ()); // printf("body added\n"); } btAlignedObjectArray<btCollisionObject*> bodyPtrs; bodyPtrs.resize(rbs.size()); for (int i=0;i<rbs.size();i++) { bodyPtrs[i] = &rbs[i]; } unsigned int numCurrentPairs = numPairs[pairSwap]; PfxBroadphasePair *currentPairs = pairsBuff[pairSwap]; PfxSetupContactConstraintsParam param; param.contactPairs = currentPairs; param.numContactPairs = numCurrentPairs; param.offsetContactManifolds = contacts; param.offsetRigidStates = states; param.offsetRigidBodies = bodies; param.offsetSolverBodies = solverBodies; param.numRigidBodies = numRigidBodies; param.timeStep = timeStep; param.separateBias = separateBias; BulletSetupContactConstraints(param); btAlignedObjectArray<btPersistentManifold*> manifoldPtrs; manifoldPtrs.resize(manifolds.size()); for (int i=0;i<manifolds.size();i++) { manifoldPtrs[i] = &manifolds[i]; } if (bodyPtrs.size() && manifoldPtrs.size()) { pgs.solveGroup(&bodyPtrs[0],bodyPtrs.size(),&manifoldPtrs[0],manifoldPtrs.size(),0,0,info,0,0,0); for (int i=0;i<numRigidBodies;i++) { btVector3 linvel = rbs[i].getLinearVelocity(); btVector3 angvel = rbs[i].getAngularVelocity(); states[i].setLinearVelocity(PfxVector3(linvel.getX(),linvel.getY(),linvel.getZ())); states[i].setAngularVelocity(PfxVector3(angvel.getX(),angvel.getY(),angvel.getZ())); } } BulletWriteWarmstartContactConstraints(param); }
void MaskWidget::paintEvent(QPaintEvent* e) { if (!m_desktopPixmap.isNull()) { m_curPos = QCursor::pos(); QPainter painter(this); painter.drawPixmap(0, 0, m_desktopPixmap); if (!m_bScreenShotDone) { if (!m_bDragging) { m_curRc.setRect(-9999, -9999, 19999, 19999); for (std::vector<RECT>::iterator it = g_winRects.begin(); it != g_winRects.end(); ++it) { QRect rect; rect.setRect(it->left, it->top, it->right - it->left, it->bottom - it->top); if (rect.contains(QCursor::pos()) && m_curRc.contains(rect)/* && rect.height() > 5 && rect.width() > 5*/) { m_curRc = rect; //break; } } } else { m_curRc = QRect(m_startPoint, QCursor::pos()); } } painter.save(); painter.setPen(Qt::NoPen); painter.setBrush(QColor(0, 0, 0, 120)); QPolygon p1(QRect(0, 0, width(), height())); QPolygon p2(m_curRc, true); p1 = p1.subtracted(p2); painter.drawPolygon(p1); painter.restore(); painter.save(); QPen pen = painter.pen(); if (m_bScreenShotDone || m_bMousePressing) { pen.setWidth(2); pen.setColor(QColor(6, 157, 213)); pen.setStyle(Qt::DashDotDotLine); } else { pen.setWidth(4); pen.setColor(QColor(0, 255, 0)); pen.setStyle(Qt::SolidLine); } painter.setPen(pen); painter.drawRect(m_curRc); painter.restore(); painter.save(); QRect ori(m_curPos.x() - 15, m_curPos.y() - 11, 30, 22); QPixmap magnifier(126, 122); QPainter painter2(&magnifier); painter2.save(); painter2.fillRect(0, 0, 126, 122, QBrush(QColor(51, 51, 51, 200))); painter2.restore(); QPen p = painter2.pen(); p.setWidth(1); p.setColor(QColor(51, 51, 51)); painter2.setPen(p); painter2.drawRect(0, 0, 125, 93); p.setWidth(2); p.setColor(QColor(255, 255, 255)); painter2.setPen(p); painter2.drawRect(2, 2, 122, 90); painter2.drawPixmap(3, 3, m_desktopPixmap.copy(ori).scaled(120, 88)); p.setWidth(4); p.setColor(QColor(0, 122, 179, 128)); painter2.setPen(p); painter2.drawLine(5, 45, 121, 45); painter2.drawLine(61, 5, 61, 89); p.setWidth(1); p.setColor(QColor(255, 255, 255)); painter2.setPen(p); painter2.drawText(6, 105, QString("%1 x %2").arg(m_curRc.width()).arg(m_curRc.height())); QImage image = m_desktopPixmap.toImage(); QRgb rgb = image.pixel(m_curPos.x()-1, m_curPos.y()-1); painter2.drawText(6, 118, QString("rgb(%1,%2,%3").arg(qRed(rgb)).arg(qGreen(rgb)).arg(qBlue(rgb))); QPoint showPoint(m_curPos.x() + 10, m_curPos.y() + 10); if (m_curPos.y() + 130 > this->height()) showPoint.setY(m_curPos.y() - 130); if (m_curPos.x() + 130 > this->width()) showPoint.setX(m_curPos.x() - 130); painter.drawPixmap(showPoint, magnifier); } }
static block_t *Mix( filter_t *p_filter, block_t *p_buf ) { filter_sys_t *p_sys = p_filter->p_sys; const size_t i_prevSize = p_sys->inputSamples.size(); p_sys->inputSamples.resize(i_prevSize + p_buf->i_nb_samples * p_sys->i_inputNb); memcpy((char*)(p_sys->inputSamples.data() + i_prevSize), (char*)p_buf->p_buffer, p_buf->i_buffer); const size_t i_inputBlockSize = sizeof(float) * p_sys->i_inputNb * AMB_BLOCK_TIME_LEN; const size_t i_outputBlockSize = sizeof(float) * p_sys->i_outputNb * AMB_BLOCK_TIME_LEN; const size_t i_nbBlocks = p_sys->inputSamples.size() * sizeof(float) / i_inputBlockSize; block_t *p_out_buf = block_Alloc(i_outputBlockSize * i_nbBlocks); if (unlikely(p_out_buf == NULL)) { block_Release(p_buf); return NULL; } p_out_buf->i_nb_samples = i_nbBlocks * AMB_BLOCK_TIME_LEN; if (p_sys->i_inputPTS == 0) p_out_buf->i_pts = p_buf->i_pts; else p_out_buf->i_pts = p_sys->i_inputPTS; p_out_buf->i_dts = p_out_buf->i_pts; p_out_buf->i_length = p_out_buf->i_nb_samples * 1000000 / p_sys->i_rate; float *p_dest = (float *)p_out_buf->p_buffer; const float *p_src = (float *)p_sys->inputSamples.data(); for (unsigned b = 0; b < i_nbBlocks; ++b) { for (unsigned i = 0; i < p_sys->i_inputNb; ++i) { for (unsigned j = 0; j < AMB_BLOCK_TIME_LEN; ++j) { float val = p_src[(b * AMB_BLOCK_TIME_LEN + j) * p_sys->i_inputNb + i]; p_sys->inBuf[i][j] = val; } } // Compute switch (p_sys->mode) { case filter_sys_t::BINAURALIZER: p_sys->binauralizer.Process(p_sys->inBuf, p_sys->outBuf); break; case filter_sys_t::AMBISONICS_DECODER: case filter_sys_t::AMBISONICS_BINAURAL_DECODER: { CBFormat inData; inData.Configure(p_sys->i_order, true, AMB_BLOCK_TIME_LEN); for (unsigned i = 0; i < p_sys->i_inputNb; ++i) inData.InsertStream(p_sys->inBuf[i], i, AMB_BLOCK_TIME_LEN); Orientation ori(p_sys->f_teta, p_sys->f_phi, p_sys->f_roll); p_sys->processor.SetOrientation(ori); p_sys->processor.Refresh(); p_sys->processor.Process(&inData, inData.GetSampleCount()); p_sys->zoomer.SetZoom(p_sys->f_zoom); p_sys->zoomer.Refresh(); p_sys->zoomer.Process(&inData, inData.GetSampleCount()); if (p_sys->mode == filter_sys_t::AMBISONICS_DECODER) p_sys->speakerDecoder.Process(&inData, inData.GetSampleCount(), p_sys->outBuf); else p_sys->binauralDecoder.Process(&inData, p_sys->outBuf); break; } default: vlc_assert_unreachable(); } // Interleave the results. for (unsigned i = 0; i < p_sys->i_outputNb; ++i) for (unsigned j = 0; j < AMB_BLOCK_TIME_LEN; ++j) p_dest[(b * AMB_BLOCK_TIME_LEN + j) * p_sys->i_outputNb + i] = p_sys->outBuf[i][j]; } p_sys->inputSamples.erase(p_sys->inputSamples.begin(), p_sys->inputSamples.begin() + i_inputBlockSize * i_nbBlocks / sizeof(float)); assert(p_sys->inputSamples.size() < i_inputBlockSize); p_sys->i_inputPTS = p_out_buf->i_pts + p_out_buf->i_length; block_Release(p_buf); return p_out_buf; }
int main(int argc, char *argv[]) { FILE *afile; //Not necessary but naming the files is convenient FILE *bfile; afile = fopen(argv[1],"r"); //We first try opening the first file if (afile == NULL) //Making sure it is something valid { puts("error this is not a valid file"); //Then exiting out with an error if it isn't return 1; } bfile = fopen(argv[2],"w"); //For b file we just just check if we can create it if (bfile == NULL) { puts("error when attempting to make a new file"); //Not sure when it would actually occur that you couldn't... return 1; //But just in case we check } char str[100]; //First we create a string... generally long enough to handle a big integer float first; //We create two floats... could have been ints but I got confused early on... float second; //...as to what type of numbers we could be getting if (fgets(str, 100, afile) == NULL) //I used fgets to put the contents of one line into the string { puts("error in reading file"); //Display an error if we can't read the file correctly return 1; } sscanf(str,"%f",&first); //Then we try putting the float number into the first if (fgets(str, 100, afile) == NULL) //We call fgets to get another float { puts("error in reading file"); return 1; } sscanf(str,"%f",&second); //Sscanf to put that float into the variable printf("%f\t",first); //Throughout the program I print to stdout just to make my life easier printf("%f\n",second); //So I don't need to check the output file all the time fprintf(bfile, "input numbers in decimal: %f\t%f\n",first,second); //Here is where I actually output the line to the file double firstb; //next we create two doubles to hold the binary patterns double secondb; //looking back choosing strings would have been much better firstb = conv2bin(first); //but I'm all for challenges... here we set the double equal to the output printf("%016.0f\t",firstb); //of the conv2bin function and output the double with no decimals and 16 places secondb = conv2bin(second); //then we do the same with the second binary printf("%016.0f\n",secondb); fprintf(bfile, "16-bit binary numbers: %016.0f\t%016.0f\n",firstb,secondb); //output to the file char * luiArray; //here we make an array of chars aka a string luiArray = (char*) calloc(32, sizeof(char)); //we use calloc cause you told us too to make space for 32 chars (32 bits) luiArray = lui(firstb, luiArray); //then we use the lui function to store the first integer in the upper 16 printf("%s\n",luiArray); //and print it fprintf(bfile, "\"lui\" of num_1: %s\n",luiArray); luiArray = ori(secondb, luiArray); //and use ori to put the second in the lower 16 printf("%s\n",luiArray); //and print it fprintf(bfile, "\"lui\" and \"ori\": %s\n",luiArray); int product; //we create an int for the product product = multiply(first, second); //call the product function printf("%d\n", product); //print it fprintf(bfile, "Multiplication: %f * %f = %d\n", first, second, product); int quotient; //same sort of deal with the quotient int * ptr; //I used a pointer to get the remainder ptr = (int*) malloc(sizeof(int)); //allocated the size of one int for it quotient = divide(first, second, ptr); printf("%d (%d)\n", quotient, *ptr); //then we print the quotient fprintf(bfile, "Division: %f / %f = %d (%d)\n",second,first,quotient,*ptr); char * andb = (char*) calloc (16, sizeof(char)); ////////////////////////////////////////////////////// char * orb = (char*) calloc (16, sizeof(char)); //HERE I MOVED THE POINTERS INTO THE MAIN FUNCTION // char * xorb = (char*) calloc (16, sizeof(char)); //**************************************************// char * notb = (char*) calloc (16, sizeof(char)); ////////////////////////////////////////////////////// logicops(firstb, secondb, andb, orb, xorb, notb); ////////CHANGED FUNCTION CALL////////////////// char * andh = (char*) calloc (4, sizeof(char)); //then we get crazy, I put all the logical operator calculations into one function char * orh = (char*) calloc (4, sizeof(char)); char * xorh = (char*) calloc (4, sizeof(char)); //then we allocate some hexadecimal string pointers char * noth = (char*) calloc (4, sizeof(char)); andh = tohex(andb); //and use the tohex function to convert the binary strings to hex orh = tohex(orb); //*note that the binary strings were declared global earlier so that is xorh = tohex(xorb); //why you don't see them declared here noth = tohex(notb); printf("%s\t%s\n",andb,andh); //then lots of printing printf("%s\t%s\n",orb,orh); printf("%s\t%s\n",xorb,xorh); printf("%s\t%s\n",notb,noth); fprintf(bfile, "num_1 & num_2: %s\t%s\n",andb,andh); fprintf(bfile, "num_1 | num_2: %s\t%s\n",orb,orh); fprintf(bfile, "num_1 ^ num_2: %s\t%s\n",xorb,xorh); fprintf(bfile, "~num_2: %s\t%s\n",notb,noth); fclose(afile); //then close the files fclose(bfile); free(andb); //free up memory for a gazillion things free(orb); free(xorb); free(notb); free(andh); free(orh); free(xorh); free(noth); free(ptr); free(luiArray); return 0; //and we are done! }
void TreeViewWidget::mousePressEvent(QMouseEvent *e) { mousedown = true; mousepos[0] = e->x(); mousepos[1] = e->y(); QVector3D ori(0,0,0); double x = e->x() - width/2; double y = height/2 - e->y(); QVector3D dir(kx*x, ky*y, -1); QMap<QString, Object*>::const_iterator it; Object *most_front = NULL; for(it = objectFactory.Factory()->begin(); it != objectFactory.Factory()->end(); ++it) { if(it.value()->Bounding()->Intersect(it.value()->ModelViewMatrix(), ori, dir)) { if(most_front == NULL || most_front->GetPosition().z() < it.value()->GetPosition().z()) most_front = it.value(); } else { if(!groupSelecting && it.value()->isSelected()) { for(int i=0;i<selectedList.size();i++) if(selectedList[i] == it.value()) selectedList.removeAt(i); it.value()->ToggleSelected(false); } } } if(most_front != NULL) { if(!most_front->isSelected()) { if(groupSelecting) { emit GiveMsg(most_front->GetPosition(), most_front->GetEulerAngles(), QVector2D(most_front->GetScale().x(), most_front->GetScale().y()), most_front->GetModelName()); most_front->ToggleSelected(true); selectedList.append(most_front); } else { for(int i=0;i<selectedList.size();i++) { selectedList[i]->ToggleSelected(false); } selectedList.clear(); selectedList.append(most_front); emit GiveMsg(most_front->GetPosition(), most_front->GetEulerAngles(), QVector2D(most_front->GetScale().x(), most_front->GetScale().y()), most_front->GetModelName()); most_front->ToggleSelected(true); } } else { if(groupSelecting) { for(int i=0;i<selectedList.size();i++) { if(selectedList[i] == most_front) selectedList.removeAt(i); } most_front->ToggleSelected(false); } } } update(); }
int main(int argc, char *argv[]) { srand(time(0)); int m = atoi(argv[1]); int n = atoi(argv[2]); int i, j; float *x; float *y; float *A; float *t; int incx = 1; int incy = 1; float alpha; int lda = m; alpha = rand()/1.0/RAND_MAX - 0.5; x = (float*)malloc(sizeof(float)*m); y = (float*)malloc(sizeof(float)*n); t = (float*)malloc(sizeof(float)*m*n); A = (float*)malloc(sizeof(float)*m*n); for (i = 0; i < m; i++) x[i] = rand()/1.0/RAND_MAX - 0.5; for (i = 0; i < n; i++) y[i] = rand()/1.0/RAND_MAX - 0.5; for (i = 0; i < m*n; i++) t[i] = rand()/1.0/RAND_MAX - 0.5; unsigned long long int t1,t2,t3,t4,t5,t6; printf("acm\n");//ACML version memcpy(A,t,sizeof(float)*m*n); clock_gettime(CLOCK_MONOTONIC, &begin); sger(m, n, alpha, x, incx, y, incy, A, lda); clock_gettime(CLOCK_MONOTONIC, &end); t1 = 1000000000L*(end.tv_sec - begin.tv_sec) + end.tv_nsec - begin.tv_nsec; printf("ori\n");//Native version memcpy(A,t,sizeof(float)*m*n); clock_gettime(CLOCK_MONOTONIC, &begin); ori(m, n, alpha, x, incx, y, incy, A, lda); clock_gettime(CLOCK_MONOTONIC, &end); t2 = 1000000000L*(end.tv_sec - begin.tv_sec) + end.tv_nsec - begin.tv_nsec; printf("one\n");//Native version with checksum memcpy(A,t,sizeof(float)*m*n); clock_gettime(CLOCK_MONOTONIC, &begin); one(m, n, alpha, x, incx, y, incy, A, lda); clock_gettime(CLOCK_MONOTONIC, &end); t3 = 1000000000L*(end.tv_sec - begin.tv_sec) + end.tv_nsec - begin.tv_nsec; printf("exx\n");//Native version with checksum (optimized) memcpy(A,t,sizeof(float)*m*n); clock_gettime(CLOCK_MONOTONIC, &begin); exx(m, n, alpha, x, incx, y, incy, A, lda); clock_gettime(CLOCK_MONOTONIC, &end); t4 = 1000000000L*(end.tv_sec - begin.tv_sec) + end.tv_nsec - begin.tv_nsec; printf("dou\n");//Native version with recalculation memcpy(A,t,sizeof(float)*m*n); clock_gettime(CLOCK_MONOTONIC, &begin); dou(m, n, alpha, x, incx, y, incy, A, lda); clock_gettime(CLOCK_MONOTONIC, &end); t5 = 1000000000L*(end.tv_sec - begin.tv_sec) + end.tv_nsec - begin.tv_nsec; printf("exd\n");//Native version with recalculation (optimized) memcpy(A,t,sizeof(float)*m*n); clock_gettime(CLOCK_MONOTONIC, &begin); exd(m, n, alpha, x, incx, y, incy, A, lda); clock_gettime(CLOCK_MONOTONIC, &end); t6 = 1000000000L*(end.tv_sec - begin.tv_sec) + end.tv_nsec - begin.tv_nsec; printf("acm%16lld\n",t1); printf("ori%16lld\n",t2); printf("one%16lld\n",t3); printf("exx%16lld\n",t4); printf("dou%16lld\n",t5); printf("exd%16lld\n",t6); return 0; }
Line2d Correlator::line() { V2d c=centroid(); V2d o=ori(); return Line2d(c,c+o); }