void _PartialBasisIntoPolynomialContainer(Source & so,Sink & si) { so.shouldBeEnd(); list<Polynomial> aList(run->partialBasis()); GBList<Polynomial> L; const int sz = aList.size(); list<Polynomial>::const_iterator w = aList.begin(); for(int i=1;i<=sz;++i,++w) { L.push_back(*w); }; marker result; result.name("polynomials"); result.num(GBGlobals::s_polynomials().push_back(L)); result.put(si); }; /* _PartialBasisIntoPolynomialContainer */
int main() { std::list<int> aList(5, 0); // 5 Nullen std::cout << "aList.size() = " << aList.size() << std::endl; showSequence(aList); std::list<int> aList2; // leer copyadd(aList.begin(), aList.end(), std::inserter(aList2, aList2.begin())); std::cout << "aList2.size() = " << aList2.size() << std::endl; showSequence(aList2); }
static void tryList0(int listSize){ APool aPool; AList aList(aPool); if(!aPool.setSize(listSize)){ ndbout << "Failed to do aPool.setSize(" << listSize << ")" << endl; return; } int * anArray = new int[listSize]; for(int i = 1; i<listSize; i++){ int arrayElements = 0; for(int j = 0; j<i; j++){ A_Listable_ObjectPtr p; const int ret = aList.seize(p); if(ret == RNIL){ ndbout << "Failed to seize!!" << endl; ndbout << "Have seized " << j << " out of " << listSize << endl; ndbout << "Terminating..." << endl; abort(); } anArray[arrayElements] = ret; arrayElements++; } assert(aList.noOfElements() == i); assert(aPool.noOfFree() == (listSize - i)); assert(arrayElements == i); for(int j = 0; j<i; j++){ aList.release(anArray[j]); } assert(aList.noOfElements() == 0); assert(aPool.noOfFree() == listSize); } }
static void tryList1(int listSize, int iterations){ APool aPool; AList aList(aPool); if(!aPool.setSize(listSize)){ ndbout << "Failed to do aPool.setSize(" << listSize << ")" << endl; return; } ndbout << "Seizing/Releaseing " << iterations << " times over list with " << listSize << " elements" << endl; int * anArray = new int[listSize]; int arrayElements = 0; int noOfSeize = 0; int noFailSeize = 0; int noOfRelease = 0; for(int i = 0; i<iterations; i++){ assert(arrayElements <= listSize); const int r = rand() % (10 * listSize); if(r < (arrayElements - 1)){ /** * Release an element */ noOfRelease++; aList.release(anArray[r]); arrayElements--; for(int j = r; j<arrayElements; j++) anArray[j] = anArray[j+1]; } else { /** * Seize an element */ A_Listable_ObjectPtr p; const int ret = aList.seize(p); if(ret == RNIL && arrayElements != listSize){ ndbout << "Failed to seize!!" << " iteration=" << i << endl; ndbout << "Have seized " << arrayElements << " out of " << listSize << endl; ndbout << "Terminating..." << endl; abort(); } if(arrayElements >= listSize && ret != RNIL){ ndbout << "Seize did not fail when it should have" << " iteration=" << i << endl; ndbout << "Have seized " << arrayElements << " out of " << listSize << endl; ndbout << "Terminating..." << endl; abort(); } if(ret != RNIL){ noOfSeize++; anArray[arrayElements] = ret; arrayElements++; } else { noFailSeize++; } } } delete []anArray; ndbout << "Seized: " << noOfSeize << " Seized with buffer full: " << noFailSeize << " Release: " << noOfRelease << " --- "; ndbout << "(" << noOfSeize << " + " << noFailSeize << " + " << noOfRelease << " = " << (noOfSeize + noFailSeize + noOfRelease) << ")" << endl; }
static void tryList3(int size, int fail){ ndbout << "Failing " << fail << " times " << endl; for(int i = 0; i<fail; i++){ APool aPool; AList aList(aPool); if(!aPool.setSize(size)){ ndbout << "Failed to do aPool.setSize(" << size << ")" << endl; return; } const int noOfElementsInBufferWhenFail = (i + 1) * (size /(fail + 1)); int * anArray = new int[size]; for(int i = 0; i<size; i++) anArray[i] = i; int arrayElements = 0; int noOfSeize = 0; int noFailSeize = 0; int noOfRelease = 0; while(true){ assert(arrayElements <= size); if(arrayElements == noOfElementsInBufferWhenFail){ ndbout << "++ You should get a ErrorReporter::handle... " << endl; aList.release(anArray[arrayElements]); ndbout << "++ Inbetween these lines" << endl << endl; break; } const int r = rand() % (10 * size); if(r < (arrayElements - 1)){ /** * Release an element */ noOfRelease++; aList.release(anArray[r]); arrayElements--; for(int j = r; j<arrayElements; j++) anArray[j] = anArray[j+1]; } else { /** * Seize an element */ A_Listable_ObjectPtr p; const int ret = aList.seize(p); if(ret == RNIL && arrayElements != size){ ndbout << "Failed to seize!!" << endl; ndbout << "Have seized " << arrayElements << " out of " << size << endl; ndbout << "Terminating..." << endl; abort(); } if(arrayElements >= size && ret != RNIL){ ndbout << "Seize did not fail when it should have" << endl; ndbout << "Have seized " << arrayElements << " out of " << size << endl; ndbout << "Terminating..." << endl; abort(); } if(ret != RNIL){ noOfSeize++; anArray[arrayElements] = ret; arrayElements++; } else { noFailSeize++; } } } delete []anArray; } }
static void tryList2(int size, int iter, int fail){ APool aPool; AList aList(aPool); if(!aPool.setSize(size)){ ndbout << "Failed to do aPool.setSize(" << size << ")" << endl; return; } ndbout << "doing getPtr(i) where i > size(" << size << ") " << fail << " times mixed with " << iter << " ordinary seize/release" << endl; int * anArray = new int[size]; int arrayElements = 0; int noOfSeize = 0; int noFailSeize = 0; int noOfRelease = 0; for(int i = 0; i<iter; i++){ assert(arrayElements <= size); const int r = rand() % (10 * size); if((i + 1)%(iter/fail) == 0){ aList.getPtr(size + r); continue; } if(r < (arrayElements - 1)){ /** * Release an element */ noOfRelease++; aList.release(anArray[r]); arrayElements--; for(int j = r; j<arrayElements; j++) anArray[j] = anArray[j+1]; } else { /** * Seize an element */ A_Listable_ObjectPtr p; const int ret = aList.seize(p); if(ret == RNIL && arrayElements != size){ ndbout << "Failed to seize!!" << " iteration=" << i << endl; ndbout << "Have seized " << arrayElements << " out of " << size << endl; ndbout << "Terminating..." << endl; abort(); } if(arrayElements >= size && ret != RNIL){ ndbout << "Seize did not fail when it should have" << " iteration=" << i << endl; ndbout << "Have seized " << arrayElements << " out of " << size << endl; ndbout << "Terminating..." << endl; abort(); } if(ret != RNIL){ noOfSeize++; anArray[arrayElements] = ret; arrayElements++; } else { noFailSeize++; } } } delete []anArray; }
double _hAccCalcAccSurf(OpenBabel::OBAtom* atom) { double radius(H_BOND_DIST); //---(1)-- create sphere with uniformly distributed points std::vector<Coordinate> sphere; std::vector<Coordinate>::iterator itS; const double arclength(1.0 / sqrt(sqrt(3.0) * DENSITY)); double dphi(arclength/radius); int nlayer(ROUND(PI/dphi) + 1); double phi(0.0); for (int i(0); i < nlayer; ++i) { double rsinphi(radius*sin(phi)); double z(radius*cos(phi)); double dtheta((rsinphi==0) ? PI*2 : arclength/rsinphi); int tmpNbrPoints(ROUND(PI*2/dtheta)); if(tmpNbrPoints <= 0) { tmpNbrPoints = 1; } dtheta = PI * 2.0 / tmpNbrPoints; double theta((i % 2) ? 0 : PI); for (int j(0) ; j < tmpNbrPoints ; ++j) { Coordinate coord; coord.x = rsinphi*cos(theta) + atom->x(); coord.y = rsinphi*sin(theta) + atom->y(); coord.z = z + atom->z(); sphere.push_back(coord); theta += dtheta; if(theta > PI*2) { theta -= PI*2; } } phi += dphi; } //---(2)-- define neighbors of atom std::list<OpenBabel::OBAtom*> aList(_hAccGetNeighbors(atom)); std::list<OpenBabel::OBAtom*>::iterator itA; //---(3) -- check for every sphere-point if it is accessible int nbrAccSurfPoints(0); double r; OpenBabel::OBElementTable et; for (itS = sphere.begin(); itS != sphere.end(); ++itS) { bool isAccessible(true); for (itA = aList.begin(); itA != aList.end(); ++itA) { OpenBabel::OBAtom* n(*itA); double distSq(((itS->x - n->x()) * (itS->x - n->x())) + ((itS->y - n->y()) * (itS->y - n->y())) + ((itS->z - n->z()) * (itS->z - n->z()))); radius = et.GetVdwRad(n->GetAtomicNum()); double sumSq((r + H_RADIUS) * (r + H_RADIUS)); if (distSq <= sumSq) { isAccessible = false; break; } } if (isAccessible) { ++nbrAccSurfPoints; } } return (nbrAccSurfPoints/(double)sphere.size()); }
void CAknKeyLockControl::ProcessCommandL(TInt aCommandId) { if ( aCommandId == KKeyLockControlAnyKey ) { if ( !iPhoneQueryOnScreen ) { iPhoneQueryOnScreen = ETrue; // show phone query ShowLockPhoneQueryL(); } } else if (aCommandId == EAknSoftkeyUnlock) { iPhoneQueryOnScreen = EFalse; if ( iAutolockEnabled ) { TApaTaskList aList(iCoeEnv->WsSession()); TApaTask aTask = aList.FindApp(TUid::Uid(0x100059B5)); if ( aTask.Exists() ) { DisableKeylock(); iNotif->NotifyStatusChange(EHideSoftNotifications); TKeyEvent keyEvent; keyEvent.iCode = EKeyBell; aTask.SendKey(keyEvent); SendMessageToSysAp(EEikKeyLockPowerKeyPressed); } // else we do nothing, Autolock application was not ready yet. } else { if ( iFeatureKeypadNoSlider ) { //Show note "Now press *". //Note is shown when user has pressed "Unlock" when keypad is in locked state iConfirmationNoteAsterisk->ShowNote( CAknNoteDialog::EShortTimeout,CAknNoteDialog::EConfirmationTone); } else { iConfirmationNote->ShowNote( CAknNoteDialog::EShortTimeout,CAknNoteDialog::EConfirmationTone); } iUnlockConfirmation = ETrue; } } else if (aCommandId == EAknSoftkeyLock) { // Lock keys DoExitOfferKeylock(); EnableKeylock(); } else if (aCommandId == EAknSoftkeyExit) { // Cancel offer keylock CBA DoExitOfferKeylock(); } else if (aCommandId == EAknSoftkeyEmpty) { if (iKeyLockEnabled) { ShowLockedNote(); } } else if (aCommandId == KNoteCmdFocusLost) { // Locked note has become unfocusd - get rid of it if (iOfferLockEnabled) { DoExitOfferKeylock(); } } }