コード例 #1
0
 void QLDSolver::updateObjectiveEquations()
 {
   for (size_t i=0; i<_objectives.size(); ++i)
   {
     QuadraticFunction& obj = _objectives[i]->getFunction();
     utils::addCompressed2d(obj.getPi(), _C, findMapping(obj.getVariable()), _objectives[i]->getWeight());
     utils::addCompressedByRow(obj.getqi(), _d, findMapping(obj.getVariable()), _objectives[i]->getWeight());
   }
 }
コード例 #2
0
ファイル: vidmem.c プロジェクト: L3oV1nc3/VMGL
void
xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
	VidMapPtr vp;
	MappingPtr mp;

	if (!vidMemInfo.initialised || !vidMemInfo.unmapMem) {
		xf86DrvMsg(ScreenNum, X_WARNING,
		  "xf86UnMapVidMem() called before xf86MapVidMem()\n");
		return;
	}

	vp = getVidMapRec(ScreenNum);
	mp = findMapping(vp, Base, Size);
	if (!mp) {
		xf86DrvMsg(ScreenNum, X_WARNING,
		  "xf86UnMapVidMem: cannot find region for [%p,0x%lx]\n",
		  Base, Size);
		return;
	}
	if (vp->mtrrEnabled && vidMemInfo.undoWC && mp)
		vidMemInfo.undoWC(ScreenNum, mp->mtrrInfo);

	vidMemInfo.unmapMem(ScreenNum, Base, Size);
	removeMapping(vp, mp);
}
コード例 #3
0
ファイル: mem.cpp プロジェクト: achurch/decaf-emu
/**
 * Manually uncommit a memory region, must match a known mapping in gMemoryMap.
 */
bool
uncommit(ppcaddr_t address,
         ppcaddr_t size)
{
   auto mapping = findMapping(address, size);

   if (!mapping) {
      decaf_abort("Invalid mem::commit attempt, must exactly match a know mapping");
      return false;
   }

   if (mapping->flags & MapFlags::AutoCommit) {
      decaf_abort("Attempted to manually uncommit an autocommit mapping");
      return false;
   }

   if (!mapping->address) {
      // Already uncommitted
      return true;
   }

   if (!platform::uncommitMemory(mapping->address, size)) {
      // Failed to uncommit? Really?
      return false;
   }

   mapping->address = 0;
   return true;
}
コード例 #4
0
 void QLDSolver::updateBounds()
 {
   for (size_t i=0; i<_bounds.size(); ++i)
   {
     DiagonalLinearConstraint* cstr = _bounds[i];
     const std::vector<int>& mapping = findMapping(cstr->getVariable());
     
     utils::intersectBounds(*cstr, mapping, _xl, _xu);
   }
 }
コード例 #5
0
CGEventRef remapEvent(CGEventRef event) {
	CGKeyCode keycode = (CGKeyCode) CGEventGetIntegerValueField(event, kCGKeyboardEventKeycode);
	
	int newcode = findMapping(keycode);
	
	if (newcode != keycode) {
		CGEventSetIntegerValueField(event, kCGKeyboardEventKeycode, newcode);
		
	} else {
		printf("Debug: rewrite requested, but no rewrite for this event. Passing as-is!\n");
	}
	
	return event;
}
コード例 #6
0
  void QLDSolver::updateEqualityEquations()
  {
    int m = 0;
    for (size_t i=0; i<_equalityConstraints.size(); ++i)
    {
      LinearConstraint* cstr = _equalityConstraints[i];
      int dim = cstr->getDimension();
      
      // XXX http://eigen.tuxfamily.org/api/TopicFunctionTakingEigenTypes.html#TopicPlainFunctionsFailing
      Eigen::Block<MatrixMap> _A_block = _A.block(m, 0, dim, n());
      Eigen::DenseBase<VectorMap>::SegmentReturnType _b_segment = _b.segment(m, dim);
      Eigen::VectorXd v;
      utils::convert(*cstr, findMapping(cstr->getVariable()), CSTR_PLUS_EQUAL, _A_block, _b_segment, v);

      m += dim;
    }
  }
コード例 #7
0
  void QLDSolver::updateInequalityEquations()
  {
    int p = static_cast<int>(_m);
    for (size_t i=0; i<_inequalityConstraints.size(); ++i)
    {
      LinearConstraint* cstr = _inequalityConstraints[i];
      int dim = cstr->getDimension();

      if(cstr->getType() == CSTR_LOWER_AND_GREATER)
        dim *= 2;

      // XXX http://eigen.tuxfamily.org/api/TopicFunctionTakingEigenTypes.html#TopicPlainFunctionsFailing
      Eigen::Block<Eigen::Map<Eigen::MatrixXd> > _A_block = _A.block(p, 0, dim, n());
      Eigen::VectorBlock<Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, 1> > > _b_segment = _b.segment(p, dim);
      Eigen::VectorXd v;
      utils::convert(*cstr, findMapping(cstr->getVariable()), CSTR_PLUS_GREATER, _A_block, _b_segment, v);

      p += dim;
    }
  }
コード例 #8
0
ファイル: wansd.c プロジェクト: stolf/WAND
/* Returns NULL if you have to send an update to everyone,
 * or the mapping to send it to. :)
 */
struct tMapping *dopacket(char *buffer,int length,struct sockaddr_in address)
{
  struct tMapping *entry = findMapping(buffer);
  int update = 0;
  
  if (!entry) {
    update = 1;
    entry = malloc(sizeof(struct tMapping));
    entry->next = userList;
    userList=entry;
    entry->mac=strndup(buffer,6*2+5);
  }
  if (addrcmp(entry->address,address)!=0) {
    entry->address = address;
    update = 1;
  }
  entry->lastseen = time(NULL);
  entry->version = 1;
  syslog(LOG_DEBUG,"Recieved update from '%s' (%s)",
	 entry->mac,
	 inet_ntoa(entry->address.sin_addr)
	 );
  return (!update) ? entry : NULL;
}