示例#1
0
void TwoParticleGF::prepare(int BosonicMin, int BosonicMax, int FermionicMin, int FermionicMax)
{
    if(Status>=Prepared) return;

    // Find out non-trivial blocks of CX4.
    FieldOperator::BlocksBimap const& CX4NontrivialBlocks = CX4.getBlockMapping();
    for(FieldOperator::BlocksBimap::right_const_iterator outer_iter = CX4NontrivialBlocks.right.begin();
        outer_iter != CX4NontrivialBlocks.right.end(); outer_iter++){ // Iterate over the outermost index.
            for(size_t p=0; p<6; ++p){ // Choose a permutation
                  BlockNumber LeftIndices[4];
                  LeftIndices[0] = outer_iter->first;
                  LeftIndices[3] = outer_iter->second;
                  LeftIndices[2] = getLeftIndex(p,2,LeftIndices[3]);
                  LeftIndices[1] = getRightIndex(p,0,LeftIndices[0]);
                  // < LeftIndices[0] | O_1 | LeftIndices[1] >
                  // < LeftIndices[1] | O_2 | getRightIndex(p,1,LeftIndices[1]) >
                  // < LeftIndices[2]| O_3 | LeftIndices[3] >
                  // < LeftIndices[3] | CX4 | LeftIndices[0] >
                  // Select a relevant 'world stripe' (sequence of blocks).
                  if(getRightIndex(p,1,LeftIndices[1]) == LeftIndices[2] && LeftIndices[1].isCorrect() && LeftIndices[2].isCorrect()){
                      // DEBUG
                      /*DEBUG("new part: "  << S.getBlockInfo(LeftIndices[0]) << " " 
                                          << S.getBlockInfo(LeftIndices[1]) << " "
                                          << S.getBlockInfo(LeftIndices[2]) << " "
                                          << S.getBlockInfo(LeftIndices[3]) << " "
                      <<"BlockNumbers part: "  << LeftIndices[0] << " " << LeftIndices[1] << " " << LeftIndices[2] << " " << LeftIndices[3]);
                      */
                      parts.push_back(new TwoParticleGFPart(
                            OperatorPartAtPosition(p,0,LeftIndices[0]),
                            OperatorPartAtPosition(p,1,LeftIndices[1]),
                            OperatorPartAtPosition(p,2,LeftIndices[2]),
                            (CreationOperatorPart&)CX4.getPartFromLeftIndex(LeftIndices[3]),
                            H.getPart(LeftIndices[0]), H.getPart(LeftIndices[1]), H.getPart(LeftIndices[2]), H.getPart(LeftIndices[3]),
                            DM.getPart(LeftIndices[0]), DM.getPart(LeftIndices[1]), DM.getPart(LeftIndices[2]), DM.getPart(LeftIndices[3]),
                      permutations3[p]));

                      (*parts.rbegin())->KroneckerSymbolTolerance = KroneckerSymbolTolerance;
                      (*parts.rbegin())->ReduceResonanceTolerance = ReduceResonanceTolerance;
                      (*parts.rbegin())->CoefficientTolerance = CoefficientTolerance;
                      (*parts.rbegin())->ReduceInvocationThreshold = ReduceInvocationThreshold;
                      (*parts.rbegin())->MultiTermCoefficientTolerance = MultiTermCoefficientTolerance;
                      }
            }
    } 
    if ( parts.size() > 0 ) { 
        Vanishing = false;
        m_data_.prepare(BosonicMin, BosonicMax, FermionicMin, FermionicMax);
        INFO("TwoParticleGF(" << getIndex(0) << getIndex(1) << getIndex(2) << getIndex(3) << "): " << parts.size() << " parts will be calculated");
        }
    Status = Prepared;
}
示例#2
0
void Heap::bubbleDown(int pos) {
	int min = pos;
	if (getLeftIndex(pos) <= lastPosition && arr[getLeftIndex(pos)]->priority < arr[min]->priority) {
		min = getLeftIndex(pos);
	}
	if (getRightIndex(pos) <= lastPosition && arr[getRightIndex(pos)]->priority < arr[min]->priority) {
		min = getRightIndex(pos);
	}
	if (min != pos) {
		Node *temp = arr[pos];
		arr[pos] = arr[min];
		arr[min] = temp;
		bubbleDown(min);
	}
}
示例#3
0
void Photon::serialize(Stream *stream) const {
	position.serialize(stream);
	if (!leftBalancedLayout)
		stream->writeUInt(getRightIndex(0));
	#if defined(SINGLE_PRECISION) && SPECTRUM_SAMPLES == 3
		stream->write(data.power, 8);
	#else
		data.power.serialize(stream);
		stream->writeUChar(data.phi);
		stream->writeUChar(data.theta);
		stream->writeUChar(data.phiN);
		stream->writeUChar(data.thetaN);
	#endif
	stream->writeUShort(data.depth);
	stream->writeUChar(flags);
}
示例#4
0
bool wyPageControl::touchesEnded(wyMotionEvent& e) {
	if(m_scrolling) {
		m_scrolling = false;

		if(!m_flinging) {
			int curIndex = getBestIndex();
			float start = m_vertical ? m_container->getPositionY() : m_container->getPositionX();
			wyPoint loc = wyp(e.x[0], e.y[0]);
			
			// if move is small, check page clicking
			// if move is not small, check fling
			bool clicked = false;
			if(!m_largeMove) {
				int firstIndex = getVisibleFirstIndex();
				int lastIndex = getVisibleLastIndex();
				for(int i = firstIndex; i <= lastIndex; i++) {
					wyNode* page = (wyNode*)wyArrayGet(m_pages, i);
					if(page) {
						wyRect bound = page->getBoundingBoxRelativeToWorld();
						if(wyrContains(bound, loc)) {							
							// normal center of this page
							float center = m_vertical ? (m_height / 2 - getPageCenterY(i)) : (m_width / 2 - getPageCenterX(i));
							
							// if it is current page, check whether it is clicked
							if(curIndex == i) {
								if(fabs(center - start) < DP(10)) {
									clicked = true;
									notifyOnPageClicked(i);
								}
							} 
							
							// if not 
							if(!clicked) {
								m_flinging = true;
								if(m_vertical)
									m_scroller->startScroll(0, start, 0, center - start, 1000);
								else
									m_scroller->startScroll(start, 0, center - start, 0, 1000);	
							}
							
							break;
						}
					}
				}
			} 
			
			// if not clicked, fling
			if(!clicked && !m_flinging) {
				m_flinging = true;
				if(!m_largeMove) {
					int best = getBestIndex();
					float center = m_vertical ? (m_height / 2 - getPageCenterY(best)) : (m_width / 2 - getPageCenterX(best));
					if(m_vertical)
						m_scroller->startScroll(0, start, 0, center - start, 1000);
					else
						m_scroller->startScroll(start, 0, center - start, 0, 1000);	
				} else {
					float start = m_vertical ? m_container->getPositionY() : m_container->getPositionX();
					float end = m_vertical ? (m_height / 2 - getPageCenterY(e.y[0] < m_beginY ? getRightIndex() : getLeftIndex()))
						: (m_width / 2 - getPageCenterX(e.x[0] < m_beginX ? getRightIndex() : getLeftIndex()));
					if(m_vertical)
						m_scroller->startScroll(0, start, 0, end - start, 1000);
					else
						m_scroller->startScroll(start, 0, end - start, 0, 1000);	
				}
				
				return true;	
			}
		}

		return true;
	}

	return false;
}