Vector Vector::operator-(const Vector& v) const { Vector tempV(mSize); for (unsigned long i = 0; i < mSize; ++i) { tempV[i] = mVector[i] - v[i]; } return tempV; }
Vector Vector::operator*(const double d) const { Vector tempV(mSize); for (unsigned long i = 0; i < mSize; ++i) { tempV[i] = mVector[i] * d; } return tempV; }
Vector<ValueType> Vector<ValueType>::operator-(const Vector& v) const { assert(mSize <= static_cast<unsigned long>(std::numeric_limits<int>::max())); Vector tempV(static_cast<int>(mSize)); for (unsigned int i = 0; i < mSize; ++i) { tempV[i] = mVector[i] - v[i]; } return tempV; }
FVector FVector::addAndNormalize(const FVector &v) const { FVector tempV(_x + v._x, _y + v._y, _z + v._z); float unusedScale = 0.0; if (!tempV.normalize(unusedScale)) { // Do the normalization, put the scale amount in unusedScale, // but if it is unsuccessful, crash assert(unusedScale); } return tempV; }
void Camera::Reset() { Point tempP(0, 0, DEFAULT_FOCUS_LENGTH); Vector tempP2(0, 0, 0); Vector tempV(0, 1, 0); Orient(tempP, tempP2 , tempV); SetViewAngle(VIEW_ANGLE); SetNearPlane(NEAR_PLANE); SetFarPlane(FAR_PLANE); m_screenWidthRatio = 1.0f; }
void RegularVectorRun() { // Test number 2 - regular vector, slow initialize, quick variable approch for (int numTest = 0 ; numTest < NUM_TESTS ; ++numTest) { std::vector<NonPrem> tempV(ARR_SIZE); tempV[5] = NonPrem(999); tempV[3007] = tempV[5] + tempV[5]; tempV[5209] = tempV[5] + tempV[3007]; for (int tempi = 306 ; tempi < 608 ; tempi += 6) { tempV[tempi] = tempV[5]; } } }
CA::CA(){ w = 10; int cellNoX = ofGetWidth()/w; int temp[cellNoX]; for (int i =0; i<cellNoX; i++) { temp[i] = 0; } vector<int>tempV(temp, temp+cellNoX); cells = tempV; // We arbitrarily start with just the middle cell having a state of "1" cells[cells.size()/2] = 1; generation = 0; }
quater Wingbeats::getShoulder(int frame, float weight, bool isLeft) { quater resQ; int dofIndex; float sign; if(isLeft) { dofIndex = CaptureMotion::d_lshoulder1; sign = 1.0f; } else { dofIndex = CaptureMotion::d_rshoulder1; sign = -1.0f; } vector3 tempV(getInterpolation(frame, weight, dofIndex), sign*getInterpolation(frame, weight, dofIndex+1), sign*getInterpolation(frame, weight, dofIndex+2)); resQ = exp(tempV); //resQ.Identity(); return resQ; }
void CCE::job_distribution() {/*{{{*/ uvec clstLength; vector<umat> clstMat; if(_my_rank == 0) { _spin_clusters.MPI_partition(_worker_num); clstLength = _spin_clusters.getMPI_ClusterLength(0); clstMat = _spin_clusters.getMPI_Cluster(0); for(int i=1; i<_worker_num; ++i) { uvec clstNum = _spin_clusters.getMPI_ClusterLength(i); MPI_Send(clstNum.memptr(), _max_order, MPI_UNSIGNED, i, 0, MPI_COMM_WORLD); vector<umat> clstMatList = _spin_clusters.getMPI_Cluster(i); for(int j=0; j<_max_order; ++j) { umat clstMat_j = clstMatList[j]; MPI_Send(clstMat_j.memptr(), (j+1)*clstNum(j), MPI_UNSIGNED, i, j+1, MPI_COMM_WORLD); } } } else { unsigned int * clstLengthData = new unsigned int [_max_order]; MPI_Recv(clstLengthData, _max_order, MPI_UNSIGNED, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE); uvec tempV(clstLengthData, _max_order); clstLength = tempV; delete [] clstLengthData; for(int j=0; j<_max_order;++j) { unsigned int * clstMatData = new unsigned int [(j+1)*clstLength(j)]; MPI_Recv(clstMatData, (j+1)*clstLength(j), MPI_UNSIGNED, 0, j+1, MPI_COMM_WORLD, MPI_STATUS_IGNORE); umat tempM(clstMatData, clstLength(j), j+1); clstMat.push_back(tempM); delete [] clstMatData; } } _my_clusters = cSpinCluster(_bath_spins, clstLength, clstMat); }/*}}}*/
void SerialLink::update() { // first we listen to what the arduino is saying if(serial.available()) { // read chunks of 4 bytes while( serial.available() > BUFF_lENGTH ){ serial.readBytes( buffer, BUFF_lENGTH); process(buffer, BUFF_lENGTH); }; // read remaining bytes int rmb = serial.available(); if(rmb<=0) return; unsigned char* tmpBuff = new unsigned char [rmb]; serial.readBytes( tmpBuff, rmb); process(tmpBuff, rmb); delete tmpBuff; } // then we send 1 command at a time if(cmdBuffer.size() && !bLock) { lock(); string cmd = cmdBuffer[0].command +" "+ cmdBuffer[0].arguments; if(bLog) ofLog() << "> " << cmd; cmd += "\n"; std::vector<unsigned char> tempV(cmd.begin(), cmd.end()); serial.writeBytes(&tempV[0], tempV.size()); lastCmdSentTime = ofGetElapsedTimeMillis(); } else if(bLock && lastCmdSentTime - ofGetElapsedTimeMillis() > cmdTimeToLive) { unlock(); } }
void SerialLink::sendCommand(string command, string args) { string cmd = cmdBuffer[0].command +" "+ cmdBuffer[0].arguments + "\n"; std::vector<unsigned char> tempV(cmd.begin(), cmd.end()); serial.writeBytes(&tempV[0], tempV.size()); }