コード例 #1
0
ファイル: GPolynomial.cpp プロジェクト: lgatto/proteowizard
void GPolynomialSingleLabel::integrate()
{
	if(m_featureDims == 0)
		ThrowError("init has not been called");
	GTEMPBUF(size_t, pCoords, m_featureDims);
	double d;
	for(size_t n = 0; n < m_featureDims; n++)
	{
		// Iterate over the entire lattice of coefficients (except in dimension n)
		GPolynomialLatticeIterator iter(pCoords, m_featureDims, m_nControlPoints, n);
		while(true)
		{
			// Integrate in the n'th dimension
			pCoords[n] = 0;
			m_pCoefficients[calcIndex(pCoords)] = 0;
			for(size_t j = m_nControlPoints - 1; j > 0; j--)
			{
				pCoords[n] = j - 1;
				d = m_pCoefficients[calcIndex(pCoords)];
				pCoords[n] = j;
				size_t index = calcIndex(pCoords);
				GAssert(j < m_nControlPoints - 1 || m_pCoefficients[index] == 0); // There's a non-zero value in a highest-order coefficient. This polynomial, therefore, isn't big enough to hold the integral
				m_pCoefficients[index] = d / j;
			}
			if(!iter.Advance())
				break;
		}
	}
}
コード例 #2
0
ファイル: GPolynomial.cpp プロジェクト: lgatto/proteowizard
void GPolynomialSingleLabel::differentiate()
{
	if(m_featureDims == 0)
		ThrowError("init has not been called");
	GTEMPBUF(size_t, pCoords, m_featureDims);
	double d;
	for(size_t n = 0; n < m_featureDims; n++)
	{
		// Iterate over the entire lattice of coefficients (except in dimension n)
		GPolynomialLatticeIterator iter(pCoords, m_featureDims, m_nControlPoints, n);
		while(true)
		{
			// Differentiate with respect to the n'th dimension
			for(size_t j = 1; j < m_nControlPoints; j++)
			{
				pCoords[n] = j;
				d = m_pCoefficients[calcIndex(pCoords)];
				pCoords[n] = j - 1;
				m_pCoefficients[calcIndex(pCoords)] = d * j;
			}
			pCoords[n] = m_nControlPoints - 1;
			m_pCoefficients[calcIndex(pCoords)] = 0;
			if(!iter.Advance())
				break;
		}
	}
}
コード例 #3
0
ファイル: GPolynomial.cpp プロジェクト: lgatto/proteowizard
void GPolynomialSingleLabel::toBezierCoefficients()
{
	if(m_featureDims == 0)
		ThrowError("init has not been called");
	// Make Pascal's triangle
	GTEMPBUF(size_t, pCoords, m_featureDims);
	GTEMPBUF(size_t, pPascalsTriangle, m_nControlPoints);

	// In each dimensional direction...
	GMath::pascalsTriangle(pPascalsTriangle, m_nControlPoints - 1);
	for(size_t n = 0; n < m_featureDims; n++)
	{
		// Across that dimension...
		for(size_t j = 0; j < m_nControlPoints; j++)
		{
			// Iterate over the entire lattice of coefficients (except in dimension n)
			GPolynomialLatticeIterator iter(pCoords, m_featureDims, m_nControlPoints, n);
			while(true)
			{
				// Divide by the corresponding row of Pascal's triangle
				pCoords[n] = j;
				m_pCoefficients[calcIndex(pCoords)] /= pPascalsTriangle[j];
				if(!iter.Advance())
					break;
			}
		}
	}

	// Forward sum the coefficients
	double d;
	for(size_t i = m_nControlPoints - 1; i >= 1; i--)
	{
		// In each dimensional direction...
		for(size_t n = 0; n < m_featureDims; n++)
		{
			// Subtract the neighbor of lesser-significance from each coefficient
			for(size_t j = i; j < m_nControlPoints; j++)
			{
				// Iterate over the entire lattice of coefficients (except in dimension n)
				GPolynomialLatticeIterator iter(pCoords, m_featureDims, m_nControlPoints, n);
				while(true)
				{
					// Subtract the neighbor of lesser-significance from this coefficient
					pCoords[n] = j - 1;
					d = m_pCoefficients[calcIndex(pCoords)];
					pCoords[n] = j;
					m_pCoefficients[calcIndex(pCoords)] += d;
					if(!iter.Advance())
						break;
				}
			}
		}
	}
}
コード例 #4
0
void ParticleContainerLC::add(Particle& p) {
	particles.push_back(p);
	resetIterator();

	// define index of cell for particle
#if 1==DIM
	int particleIndex[]= {p.getX()[0]/radius, p.getX()[1]/radius, p.getX()[2] / radius};
#elif 2==DIM
	int particleIndex[]= {p.getX()[0]/radius, p.getX()[1]/radius, p.getX()[2] / radius};
#elif 3==DIM
	int particleIndex[] = { p.getX()[0] / cellsSize[0], p.getX()[1] / cellsSize[1],
			p.getX()[2] / cellsSize[2] };
#endif

	// skip particles that don't suite into the domain
	bool outofbound = false;
	for (int d = 0; d < 3; d++) {
		if (particleIndex[d] >= cellNums[d] || particleIndex[d] < 0
				|| p.getX()[d] < 0.0 || p.getX()[d] > domainSize[d])
			outofbound = true;
	}
	if (outofbound)
		return;

	ParticleList* pl = new ParticleList;;
	pl->p = &p;
	pl->next = NULL;
	insertList((ParticleList**)&(cells[calcIndex(particleIndex, cellNums)].root), pl);
}
コード例 #5
0
void ParticleContainerLC::selectCell(int celli[]) {
	for (int i = 0; i < DIM; i++) {
		beginningOtherCellIndex[i] = celli[i]; // incl. additional +1 for allCells instead of cells (beginningOtherCellIndex in allCells coords.)
		if (beginningOtherCellIndex[i] < 0) {
			beginningOtherCellIndex[i] = 0;
		}
		otherCellIndex[i] = beginningOtherCellIndex[i];
	}
	otherCurrentCell = allCells[calcIndex(beginningOtherCellIndex, allCellNums)];
	otherParticleIteratorInCell = otherCurrentCell->root;
	//LOG4CXX_DEBUG(particlelog, "select cell before, root:" << cells[calcIndex(celli, cellNums)].root);
	centralCell = &cells[calcIndex(celli, cellNums)];
	particleIteratorInCell = centralCell->root;
	returnedParticleIteratorInCell = particleIteratorInCell;

	//LOG4CXX_DEBUG(particlelog, "select cell after:" << celli[0]+1 << "," << celli[1]+1 << "," << celli[2]+1);
}
コード例 #6
0
Particle& ParticleContainerLC::next() { //nextInDomain
	while (!hasNextInCell()) {	// switch to next cell if no particles left in centralCell
		int idx = calcIndex(centralCellIndex, cellNums) + 1;	// 1D index of next cell
		numToIndex(idx, centralCellIndex, cellNums);	// convert 1D to 3D index
		neighborCells = 0;
		selectCell(centralCellIndex);
	}
	return nextInCell();
}
コード例 #7
0
void TriangleMatrix::Write2D( CpptrajFile& outfile, int xIn, int yIn ) {
  size_t x = (size_t)xIn;
  size_t y = (size_t)yIn;
  if ( xIn==yIn || xIn < 0 || yIn < 0 || x >= nrows_ || y >= nrows_ ) 
    outfile.Printf(data_format_, 0.0);
  else {
    size_t index = calcIndex(x, y);
    outfile.Printf(data_format_, elements_[index]);
  }
}
コード例 #8
0
void PartialAddressFilter::addEntry(Address a, bool dirty){
  int index = calcIndex(a);
  m_readBit[index] = true;
  if (dirty){
    m_writeBit[index] = true;
  }
  cout << "  " << m_chip_ptr->getID() << " adding entry: " << a << " (" 
       << m_readBit[index] << ", " << m_writeBit[index]
       << ")." << endl;
}
コード例 #9
0
void ParticleContainerLC::moveParticles_LC(Cell** cell_arr, int *nc,
		double *l) {
	int dim = DIM;
	int ic[dim], kc[dim];
	for (ic[0] = 1; ic[0] < nc[0]-1; ic[0]++)
		for (ic[1] = 1; ic[1] < nc[1]-1; ic[1]++)
#if 3==DIM
			for (ic[2] = 1; ic[2] < nc[2]-1; ic[2]++)
#endif
					{
				//LOG4CXX_DEBUG(particlelog, "move() index: " << calcIndex(ic, nc) << " of " << numcell(allCellNums));
				ParticleList **q = &cell_arr[calcIndex(ic, nc)]->root;	// get cell/ first ParticleList at index ic
				ParticleList *i = *q;
				//LOG4CXX_DEBUG(particlelog, "got i in move():" << q);
				while (NULL != i) {
					Particle& p = *i->p;
					// kc: 3d index of cell which has to store i->p according to the X vector of p
					//LOG4CXX_DEBUG(particlelog, "next p in move():" << i->p->getX().toString());
					utils::Vector<double, 3> X = p.getX();
					for (int d = 0; d < DIM; d++) {
						int coord = ((int) floor(X[d] / cellsSize[d])) + 1;	// +1 for transformation from cells[] to allCells[] coords.
						kc[d] = coord < nc[d] ? (coord < 0 ? 0.0 : coord) : nc[d]-1;	// indices must fit into cell_arr[]
					}
					if ((ic[0] != kc[0]) || (ic[1] != kc[1])
#if 3==DIM
							|| (ic[2] != kc[2])
#endif
							) {
						//LOG4CXX_DEBUG(particlelog, "moving from "<<ic[0]<<","<<ic[1]<<","<<ic[2] << " to " <<kc[0]<<","<<kc[1]<<","<<kc[2]);
						// move particle into cell kc
						deleteList(q);

						//LOG4CXX_DEBUG(particlelog, "deleted from old cell; old index:" << calcIndex(ic, nc) << "; new index:" << calcIndex(kc, nc));
						insertList(&cell_arr[calcIndex(kc, nc)]->root, i);
						//LOG4CXX_DEBUG(particlelog, "inserted in new cell");
					} else {//LOG4CXX_DEBUG(particlelog, "next p in move()");
						q = &i->next;
					}
					i = *q;
				}
			}
}
コード例 #10
0
ファイル: GPolynomial.cpp プロジェクト: lgatto/proteowizard
void GPolynomialSingleLabel::copy(GPolynomialSingleLabel* pOther)
{
	m_featureDims = pOther->m_featureDims;
	if(controlPointCount() >= pOther->controlPointCount())
		ThrowError("this polynomial must have at least as many control points as pOther");
	if(controlPointCount() > pOther->controlPointCount())
		GVec::setAll(m_pCoefficients, 0.0, m_nCoefficients);
	GTEMPBUF(size_t, pCoords, m_featureDims);
	GPolynomialLatticeIterator iter(pCoords, m_featureDims, pOther->m_nControlPoints, (size_t)-1);
	while(true)
	{
		m_pCoefficients[calcIndex(pCoords)] = pOther->m_pCoefficients[pOther->calcIndex(pCoords)];
		if(!iter.Advance())
			break;
	}
}
コード例 #11
0
ファイル: Dungeon.cpp プロジェクト: zerksud/projectz-ndk
bool Dungeon::floorCellImpl(int x, int y) const {
    bool floor = false;
    int index = calcIndex(x, y);
    switch (mTerrain[index]) {
    case WALL:
        floor = false;
        break;
    case FLOOR:
        floor = true;
        break;
    default:
        LOGE("Unknown terrain type %d", mTerrain[index]);
        floor = false;
        break;
    }

    return floor;
}
コード例 #12
0
bool ParticleContainerLC::hasNext() {
	// test for next particle in same cell
	if (hasNextInCell()) {
		/*LOG4CXX_DEBUG(particlelog, "next in cell:" << particleIteratorInCell->p->getX().toString() <<
		", current:"  << returnedParticleIteratorInCell->p->getX().toString() << ", cell:" <<
				centralCellIndex[0] << "," << centralCellIndex[1] << "," << centralCellIndex[2]);*/
		return true;
	}

	// test following cells for particles
	int idx = calcIndex(centralCellIndex, cellNums)+1;	// index of next cell in cells[]
	while (idx < numcell(cellNums)) {
		if (cells[idx].root != NULL)
			return true;
		idx++;
	}

	return false;
}
コード例 #13
0
void ParticleContainerLC::emptyHaloSide(int fixedDim, int fixedVal) {
	int idx[DIM];
	idx[fixedDim] = fixedVal;
#if 1<DIM
	const int nextDim = (fixedDim+1) % DIM;
#endif
#if 3==DIM
	const int lastDim = (fixedDim+2) % DIM;
#endif
	// iterate over wall cells
#if 1<DIM
	for (idx[nextDim] = 0; idx[nextDim] < allCellNums[nextDim]; idx[nextDim]++)
#endif
#if 3==DIM
		for (idx[lastDim] = 0; idx[lastDim] < allCellNums[lastDim]; idx[lastDim]++)
#endif
		{
			allCells[calcIndex(idx, allCellNums)]->root = NULL;
		}
	LOG4CXX_DEBUG(particlelog, "end empty halo");
}
コード例 #14
0
void ParticleContainerLC::applyToBoundaryWall(int fixedDim, int fixedVal, PCApply *fnc) {
	int idx[DIM];
	idx[fixedDim] = fixedVal;
#if 1<DIM
	const int nextDim = (fixedDim+1) % DIM;
#endif
#if 3==DIM
	const int lastDim = (fixedDim+2) % DIM;
#endif

	// iterate over wall cells
#if 1<DIM
	for (idx[nextDim] = 0; idx[nextDim] < cellNums[nextDim]; idx[nextDim]++)
#endif
#if 3==DIM
		for (idx[lastDim] = 0; idx[lastDim] < cellNums[lastDim]; idx[lastDim]++)
#endif
		{
			ParticleList *pl = cells[calcIndex(idx, cellNums)].root;
			while (pl != NULL) {	// iterate over all particles in the cell
				Particle& p = *pl->p;
				utils::Vector<double, 3>& x = p.getX();
				if (fixedVal == 0) {
					if (x[fixedDim] < sim->sigmas[p.getType()]*pow(2, 1/6)/*distance*/) {
						Particle ghost = p;
						utils::Vector<double, 3>& x2 = ghost.getX();
						x2[fixedDim] = 0.0;
						fnc->iteratePairFunc(p, ghost);
					}
				}
				else if (domainSize[fixedDim]/*radius*cellNums[fixedDim]*/ - x[fixedDim] < sim->sigmas[p.getType()]*pow(2, 1/6)/*distance*/) {
					Particle ghost = p;
					utils::Vector<double, 3>& x2 = ghost.getX();
					x2[fixedDim] = /*radius*cellNums[fixedDim];*/domainSize[fixedDim];
					fnc->iteratePairFunc(p, ghost);
				}
				pl = pl->next;
			}
		}
}
コード例 #15
0
//looks like it works by debugging, not by running the whole programm, to remove if another version exists
void ParticleContainerLC::bindOppositeWalls(int fixedDim, int fixedVal) {
	//LOG4CXX_DEBUG(particlelog, "start periodic");
	int idx[DIM];
	idx[fixedDim] = fixedVal;
#if 1<DIM
	const int nextDim = (fixedDim+1) % DIM;
#endif
#if 3==DIM
	const int lastDim = (fixedDim+2) % DIM;
#endif
	// iterate over wall cells
#if 1<DIM
	for (idx[nextDim] = 0; idx[nextDim] < allCellNums[nextDim]; idx[nextDim]++)
#endif
#if 3==DIM
		for (idx[lastDim] = 0; idx[lastDim] < allCellNums[lastDim]; idx[lastDim]++)
#endif
		{
			int index = calcIndex(idx, allCellNums);
			ParticleList *pl = allCells[index]->root;

			// set index of opposite boundary wall
			int idx_n[DIM];
			for (int i = 0; i < DIM; i++)
				idx_n[i] = idx[i];
			if (fixedVal == 0)
				idx_n[fixedDim] = allCellNums[fixedDim]-2;
			else
				idx_n[fixedDim] = 1;
			int oppositeIndex = calcIndex(idx_n, allCellNums);

			while (pl != NULL) {	// iterate over all particles in the cell
				// update p for move to opposite boundary
				Particle& p = *pl->p;
				utils::Vector<double, 3>& x = p.getX();
				ParticleList *cpy = pl->next;
				if (fixedVal == 0) {
					//LOG4CXX_DEBUG(particlelog, "x before (fixedVal=0)  " <<allCells[calcIndex(idx, allCellNums)]->root->p->getX().toString());
					x[fixedDim] += domainSize[fixedDim];
					//LOG4CXX_DEBUG(particlelog, "x after (fixedVal=0)  " <<allCells[calcIndex(idx, allCellNums)]->root->p->getX().toString());
					//cout<<"x value:"<<cells[calcIndex(idx, cellNums)].root->p->toString()<<endl;
				}
				else {
					//LOG4CXX_DEBUG(particlelog, "x before (fixedVal=cellNums)  " << p.getX().toString());
					x[fixedDim] -= domainSize[fixedDim];
					//LOG4CXX_DEBUG(particlelog, "x after (fixedVal=cellNums)  " << p.getX().toString());
				}

				// insert p into opposite boundary
				insertList(&allCells[oppositeIndex]->root, pl);
				pl = cpy;
			}

			// set own content to copy of opposite boundary cell's content
			//allCells[index]->root = allCells[oppositeIndex]->root;

			//LOG4CXX_DEBUG(particlelog, "cell finished");
			//LOG4CXX_DEBUG(particlelog, "index:" << idx[0] << "," << idx[1] << "," << idx[2]);
			//LOG4CXX_DEBUG(particlelog, "index_n:" << idx_n[0] << "," << idx_n[1] << "," << idx_n[2]);


			// should also work, but quite memory consuming
			allCells[index]->root = NULL;	// remove existing ParticleList
			ParticleList *pl2 = allCells[oppositeIndex]->root;
			while (pl2 != NULL) {
				Particle& p = *pl2->p;
				Particle *ghost = new Particle;
				utils::Vector<double, 3>& x = ghost->getX();
				x = p.getX();
				if (fixedVal == 0)
					x[fixedDim] -= domainSize[fixedDim];
				else
					x[fixedDim] += domainSize[fixedDim];
				ParticleList *pl_n = new ParticleList;
				pl_n->next = NULL;
				pl_n->p = ghost;
				insertList(&allCells[index]->root, pl_n);
				pl2 = pl2->next;
			}
		}
	//LOG4CXX_DEBUG(particlelog, "end periodic");
}
コード例 #16
0
void ParticleContainerLC::iteratePair(PCApply *fnc) {
	//LOG4CXX_DEBUG(particlelog, "iterate pair");
#ifdef _OPENMP
	if (omp_get_max_threads() == 1)
		omp_set_num_threads(4);
	int chunk = numcell(cellNums) / omp_get_max_threads();
	chunk = chunk > 100 ? 100 : chunk/2;
	if (chunk == 0)
		chunk = 1;
#endif
	#pragma omp parallel for schedule(dynamic, chunk)
	for (int i = 0; i < numcell(cellNums); i++) {
		//LOG4CXX_DEBUG(particlelog, "cell " << i << " of " << numcell(cellNums));
		ParticleList *pl = cells[i].root;
		int idx[DIM];
		numToIndex(i, idx, cellNums);
		//LOG4CXX_DEBUG(particlelog, "idx: " << idx[0] << "," << idx[1] << "," << idx[2]);

		// set start neighbor cell
		int neighborCellIndex[DIM];
		for (int j = 0; j < DIM; j++) {
			neighborCellIndex[j] = idx[j] > 0 ? idx[j] : 0;// incl. additional +1 for allCells instead of cells (beginningOtherCellIndex in allCells coords.)
		}
		while (pl != NULL) {
			Particle& p1 = *pl->p;
			utils::Vector<double, 3>& x1 = p1.getX();
			int tmp[DIM];
			for (tmp[0] = neighborCellIndex[0]; tmp[0] < idx[0]+3; tmp[0]++)	// incl. +1 for centralCellIndex to allCells coords.
#if 1<DIM
				for (tmp[1] = neighborCellIndex[1]; tmp[1] < idx[1]+3; tmp[1]++)
#endif
#if 3==DIM
					for (tmp[2] = neighborCellIndex[2]; tmp[2] < idx[2]+3; tmp[2]++)
#endif
					{
						ParticleList *pl2 = allCells[calcIndex(tmp, allCellNums)]->root;
						while (pl2 != NULL) {
							if (pl != pl2) {
								Particle p2 = *pl2->p;
								/*if (tmp[0] == 0 || tmp[1] == 0 || tmp[2] == 0
										|| tmp[0] == cellNums[0] || tmp[1] == cellNums[1] || tmp[2] == cellNums[2]) {
									utils::Vector<double, 3>& x2 = p2.getX();
									// correct position of halo particles for periodic boundaries
									for (int d = 0; d < DIM; d++) {
										if (x2[d] - x1[d] > cellsSize[d]+cellsSize[d])
											x2[d] -= domainSize[d];
										else if (x1[d] - x2[d] > cellsSize[d]+cellsSize[d])
											x2[d] += domainSize[d];
									}
								}*/
								/*if (sim->membrane) {
									// exclude direct neighbor particles
									bool isNeighbor = false;
									for (int n = 0; n < 8; n++) {
										if (p1.Neighbour[n] != NULL && p1.Neighbour[n]->getX() == p2.getX()) {
											isNeighbor = true;
											//LOG4CXX_DEBUG(particlelog, "p1:" << p1.toString());
											//LOG4CXX_DEBUG(particlelog, "p2:" << p2.toString());
											break;
										}
									}
									if (!isNeighbor)
										fnc->iteratePairFunc(p1, p2);
								}
								else*/
									fnc->iteratePairFunc(p1, p2);
								//LOG4CXX_DEBUG(particlelog, "f after:" << p1.getF().toString());
							}
							pl2 = pl2->next;
						}
					}
			pl = pl->next;
		}
	}
}
コード例 #17
0
ParticleContainerLC::ParticleContainerLC(ParticleContainer* pc, Simulation *sim) {
	for (int i = 0; i < 3; i++) {
		domainSize[i] = sim->domainSize[i];
	}
	radius = sim->cutoff;
	distance = sim->meshWidth;
	this->sim = sim;
	for (int i = 0; i < 6; i++) {
		domainBoundary[i] = sim->boundaries->getBoundary((BoundaryConds::Side)i);
	}

	for (int d = 0; d < DIM; d++) {
		int expansion = domainSize[d] / radius;
		cellNums[d] = expansion > 0 ? expansion : 1;	// expansion in dimension d must be at least 1 for correct numcell()
		cellsSize[d] = domainSize[d] / cellNums[d];
		sim->cellsSize[d] = cellsSize[d];
		allCellNums[d] = cellNums[d] + 2;
	}

#if 1==DIM
	allCellNums[0] = cellNums[0] + 2;
#elif 2==DIM
	haloAllCellNums= (cellNums[0] + 2) * (cellNums[1] + 2) - cellNums[0]*cellNums[1];
#elif 3==DIM
	haloAllCellNums = (cellNums[0] + 2) * (cellNums[1] + 2) * (cellNums[2] + 2) - cellNums[0]*cellNums[1]*cellNums[2];
#endif
	cells = new Cell[numcell(cellNums)];
	haloCells = new Cell[haloAllCellNums];
	allCells = new Cell*[numcell(allCellNums)];

	// connect allCells to cells and haloCells
	int i = 0;
	int ic[DIM], kc[DIM];
	for (ic[0] = 0; ic[0] < allCellNums[0]; ic[0]++)
#if 1<DIM
		for (ic[1] = 0; ic[1] < allCellNums[1]; ic[1]++)
#endif
#if 3==DIM
			for (ic[2] = 0; ic[2] < allCellNums[2]; ic[2]++)
#endif
			{
				bool isHalo = false;
				for (int d = 0; d < DIM; d++) {
					isHalo = isHalo || ic[d] == 0 || ic[d] == allCellNums[d]-1;
				}
				if (isHalo) {
					haloCells[i].root = NULL;
					allCells[calcIndex(ic, allCellNums)] = &haloCells[i];
					i++;
					//LOG4CXX_DEBUG(particlelog, "halo " << i << "of " << haloAllCellNums << " all:" << numcell(allCellNums) << " inner:" << numcell(cellNums));
				}
				else {
#if 1==DIM
					int tmp[DIM] = {ic[0]-1};
#elif 2==DIM
					int tmp[DIM] = {ic[0]-1, ic[1]-1};

#elif 3==DIM
					int tmp[DIM] = {ic[0]-1, ic[1]-1, ic[2]-1};
#endif
					cells[calcIndex(tmp, cellNums)].root = NULL;
					allCells[calcIndex(ic, allCellNums)] = &cells[calcIndex(tmp, cellNums)];
				}
			}
	int count = 0;
	//LOG4CXX_DEBUG(particlelog, "before insert");

	if (pc != NULL) {
		particles = pc->particles;
		iterator = pc->iterator;
		othersIterator = pc->othersIterator;

		pc->resetIterator();
		while (pc->hasNext()) {
			Particle& p = pc->next();
#if 1==DIM
			int particleIndex[]= {p.getX()[0] / radius, 0, 0};
#elif 2==DIM
			int particleIndex[]= {p.getX()[0] / radius, p.getX()[1] / radius, p.getX()[2] / radius};
#elif 3==DIM
			int particleIndex[] = { p.getX()[0] / cellsSize[0], p.getX()[1] / cellsSize[1],
					p.getX()[2] / cellsSize[2] };
#endif
			// skip particles that don't suite into the domain
			//LOG4CXX_DEBUG(particlelog, "add p: " << p.getX().toString() << ", domain:" << domainSize[0] << "," << domainSize[1] << "," << domainSize[2]);
			bool outofbound = false;
			for (int d = 0; d < 3; d++) {
				if (particleIndex[d] >= cellNums[d] || particleIndex[d] < 0
						|| p.getX()[d] < 0.0 || p.getX()[d] > domainSize[d])
					outofbound = true;
			}
			if (outofbound)
				continue;

			count++;
			ParticleList* pl = new ParticleList;
			pl->p = &p;
			pl->next = NULL;
			insertList((ParticleList**)&(cells[calcIndex(particleIndex, cellNums)].root), pl);
			//LOG4CXX_DEBUG(particlelog, "add p: " << p.getX().toString() << " to index " << particleIndex[0] << "," << particleIndex[1] << "," << particleIndex[2]);
			//LOG4CXX_DEBUG(particlelog, "root: " << cells[calcIndex(particleIndex, cellNums)].root->p->getX().toString());
		}
	}
	LOG4CXX_DEBUG(particlelog, "grid: " << cellNums[0] << " x " << cellNums[1] <<
		#if 3==DIM
			" x " << cellNums[2] <<
		#endif
			", inserted count:" << count << ", size() delivers:" << size());
}
コード例 #18
0
ファイル: terminal.cpp プロジェクト: njd5475/dego-os
const char Terminal::get(size_t row, size_t col) {
  return get(calcIndex(row, col));
}
コード例 #19
0
ファイル: GPolynomial.cpp プロジェクト: lgatto/proteowizard
double GPolynomialSingleLabel::coefficient(size_t* pCoords)
{
	if(m_featureDims == 0)
		ThrowError("init has not been called");
	return m_pCoefficients[calcIndex(pCoords)];
}
コード例 #20
0
ファイル: ClothGL.cpp プロジェクト: Atayyab/pbd
void ClothGL::setup() {
	tex.loadImage("ecoline.png");
	
	glBindVertexArrayAPPLE(vao_id); eglGetError();
	glBindBuffer(GL_ARRAY_BUFFER, vbo_data); eglGetError();
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_indices); eglGetError();
	
	shader.load("cloth");
	shader.enable();
	shader.addAttribute("pos").enableVertexAttribArray("pos");
	shader.addAttribute("tex").enableVertexAttribArray("tex");
	shader.addAttribute("norm").enableVertexAttribArray("norm");
	shader.addUniform("tex_diffuse");
	shader.uniform1i("tex_diffuse", 0); // bind to texture_unit 0;	
			
	vertices = new VertexPNTTB[num_vertices];
	
	glBufferData(
		GL_ARRAY_BUFFER
		,num_vertices * sizeof(VertexPNTTB)
		,vertices
		,GL_STREAM_DRAW
	); eglGetError();

	glVertexAttribPointer(
		shader.getAttribute("pos")
		,3
		,GL_FLOAT
		,GL_FALSE
		,sizeof(VertexPNTTB)
		,(GLvoid*)offsetof(VertexPNTTB,pos)
	); eglGetError();

	glVertexAttribPointer(
		shader.getAttribute("tex")
		,2
		,GL_FLOAT
		,GL_FALSE
		,sizeof(VertexPNTTB)
		,(GLvoid*)offsetof(VertexPNTTB,tex)
	); eglGetError();
	
	glVertexAttribPointer(
		shader.getAttribute("norm")
		,3
		,GL_FLOAT
		,GL_FALSE
		,sizeof(VertexPNTTB)
		,(GLvoid*)offsetof(VertexPNTTB,norm)
	); eglGetError();


	indices = new GLuint[num_indices];
	for(int i = 0; i < cloth.cols-1; ++i) {
		for(int j = 0; j < cloth.rows-1; ++j) {
			int dx = ((cloth.cols-1) * j * 4) + i * 4;
			indices[dx] = calcIndex(i,j);
			indices[dx+1] = calcIndex(i+1, j);
			indices[dx+2] = calcIndex(i+1, j+1);
			indices[dx+3] = calcIndex(i,j+1);
		}
	}
	for(int i = 0; i < num_indices; ++i) {
	//	cout << indices[i] << ", ";
	}
	
	glBufferData(
		GL_ELEMENT_ARRAY_BUFFER
		,num_indices * sizeof(GLuint)
		,indices
		,GL_STATIC_DRAW
	); eglGetError();
	

	shader.disable();
}
コード例 #21
0
ファイル: terminal.cpp プロジェクト: njd5475/dego-os
void Terminal::putWord(const char *c, size_t row, size_t col) {
  putWord(c, calcIndex(row, col));
}
コード例 #22
0
bool PartialAddressFilter::isWrite(Address a){
  return m_writeBit[calcIndex(a)];
}
コード例 #23
0
/** Get the element at specified row and column. */
float TriangleMatrix::GetElementF(int iIn, int jIn) const {
  if (iIn == jIn) return 0;
  size_t idx = calcIndex((size_t)iIn, (size_t)jIn);
  return elements_[idx];
}
コード例 #24
0
/** Set element at specified row and column. */
void TriangleMatrix::SetElementF(int iIn, int jIn, float elementIn) {
  if (iIn == jIn) return;
  size_t idx = calcIndex((size_t)iIn, (size_t)jIn);
  elements_[idx] = elementIn;
}
コード例 #25
0
bool PartialAddressFilter::isRead(Address a){
  return m_readBit[calcIndex(a)];
}
コード例 #26
0
ファイル: GPolynomial.cpp プロジェクト: lgatto/proteowizard
void GPolynomialSingleLabel::setCoefficient(size_t* pCoords, double dVal)
{
	if(m_featureDims == 0)
		ThrowError("init has not been called");
	m_pCoefficients[calcIndex(pCoords)] = dVal;
}
コード例 #27
0
ファイル: splineShape.cpp プロジェクト: srodrb/shapeMorphing
void splineShape::updateControlPoints()
{
    /*
     * El metodo actualiza los puntos de control para poder efectuar modificaciones
     * sobre ellos en la siguiente iteracion.
     *
     * Tengo que calcular los puntos en base a la cuerda porque se desplazan en 
     * sucesivas iteraciones... vamos con ello.
     *
     * Ayudaria tambien hacer una distribucion lineal de los puntos, pero eso solo 
     * importa para la primera aproximacion y esa funciona bastante bien, asi que
     * no es tan importante
     */


        pts[0].x = out_pts[0].x;                             pts[0].y=out_pts[0].y;                            pts[0].z=0.0;
        pts[1].x = out_pts[calcIndex(0.95,"upper")].x;       pts[1].y=out_pts[calcIndex(0.95,"upper")].y;      pts[1].z=0.0;
        pts[2].x = out_pts[calcIndex(0.80,"upper")].x;       pts[2].y=out_pts[calcIndex(0.80,"upper")].y;      pts[2].z=0.0;
        pts[3].x = out_pts[calcIndex(0.50,"upper")].x;       pts[3].y=out_pts[calcIndex(0.50,"upper")].y;      pts[3].z=0.0;
        pts[4].x = out_pts[calcIndex(0.20,"upper")].x;       pts[4].y=out_pts[calcIndex(0.20,"upper")].y;      pts[4].z=0.0;
        pts[5].x = out_pts[calcIndex(0.05,"upper")].x;       pts[5].y=out_pts[calcIndex(0.05,"upper")].y;      pts[5].z=0.0;
        pts[6].x = out_pts[calcIndex(0.005,"upper")].x;      pts[6].y=out_pts[calcIndex(0.005,"upper")].y;     pts[6].z=0.0;

        pts[7].x = 0.0;                                      pts[7].y=0.0;                                     pts[7].z=0.0;
        
        pts[8].x =  out_pts[calcIndex(0.005,"lower")].x;     pts[8 ].y=out_pts[calcIndex(0.005,"lower")].y;    pts[8].z=0.0;
        pts[9].x =  out_pts[calcIndex(0.05,"lower")].x;      pts[9 ].y=out_pts[calcIndex(0.05,"lower")].y;     pts[9].z=0.0;
        pts[10].x = out_pts[calcIndex(0.20,"lower")].x;      pts[10].y=out_pts[calcIndex(0.20,"lower")].y;     pts[10].z=0.0;
        pts[11].x = out_pts[calcIndex(0.50,"lower")].x;      pts[11].y=out_pts[calcIndex(0.50,"lower")].y;     pts[11].z=0.0;
        pts[12].x = out_pts[calcIndex(0.80,"lower")].x;      pts[12].y=out_pts[calcIndex(0.80,"lower")].y;     pts[12].z=0.0;
        pts[13].x = out_pts[calcIndex(0.95,"lower")].x;      pts[13].y=out_pts[calcIndex(0.95,"lower")].y;     pts[13].z=0.0;

        //ahora actualizamos los valores de los vectores xu,zu,xl,zl..
        for (int i = 0; i < Ni; i++) {
            //printf("xu[%d] = %f\n", i,out_pts[Ni-i].x);
            xu[i] = out_pts[Ni-i].x;
            zu[i] = out_pts[Ni-i].y;
        }
        xu[0] = 0.0; zu[0] = 0.0;
        for (int i = 0; i < Ni; i++) {
            //printf("xl[%d] = %f\n", i,out_pts[Ni+i].x);
            xl[i] = out_pts[Ni+i].x;
            zl[i] = out_pts[Ni+i].y;
        }
}
コード例 #28
0
ファイル: terminal.cpp プロジェクト: njd5475/dego-os
void Terminal::putChar(uint16_t c, size_t row, size_t col) {
  putChar(c, calcIndex(row, col));
}