Exemplo n.º 1
0
DWORD GIO_Init(DWORD dwContext)
{

	DEBUGMSG(ZONE_INIT, (TEXT("[GPIO] GPIO Initialize ...")));

	if (!InitializeAddresses())
		return (FALSE);

	mInitialized = TRUE;
	DEBUGMSG(ZONE_INFO, (TEXT("[GPIO] OK !!!\r\n")));
	return TRUE;
}
Exemplo n.º 2
0
DWORD GIO_Init(DWORD dwContext)
{

	RETAILMSG(DEBUG_GPIO, (TEXT("GPIO Initialize ...")));

	if (!InitializeAddresses())
		return (FALSE);

	mInitialized = TRUE;
	RETAILMSG(DEBUG_GPIO, (TEXT("OK !!!\r\n")));
	return TRUE;
}
Exemplo n.º 3
0
bool UBTreeSplit<BoundType, MatType>::SplitNode(BoundType& bound,
                                                MatType& data,
                                                const size_t begin,
                                                const size_t count,
                                                SplitInfo& splitInfo)
{
  constexpr size_t order = sizeof(AddressElemType) * CHAR_BIT;
  if (begin == 0 && count == data.n_cols)
  {
    // Calculate all addresses.
    InitializeAddresses(data);

    // Probably this is not a good idea. Maybe it is better to get
    // a number of distinct samples and find the median.
    std::sort(addresses.begin(), addresses.end(), ComparePair);

    // Save the vector in order to rearrange the dataset later.
    splitInfo.addresses = &addresses;
  }
  else
  {
    // We have already rearranged the dataset.
    splitInfo.addresses = NULL;
  }

  // The bound shouldn't contain too many subrectangles.
  // In order to minimize the number of hyperrectangles we set last bits
  // of the last address in the node to 1 and last bits of the first  address
  // in the next node to zero in such a way that the ordering is not
  // disturbed.
  if (begin + count < data.n_cols)
  {
    // Omit leading equal bits.
    size_t row = 0;
    arma::Col<AddressElemType>& lo = addresses[begin + count - 1].first;
    const arma::Col<AddressElemType>& hi = addresses[begin + count].first;

    for (; row < data.n_rows; row++)
      if (lo[row] != hi[row])
        break;

    size_t bit = 0;

    for (; bit < order; bit++)
      if ((lo[row] & ((AddressElemType) 1 << (order - 1 - bit))) !=
          (hi[row] & ((AddressElemType) 1 << (order - 1 - bit))))
        break;

    bit++;

    // Replace insignificant bits.
    if (bit == order)
    {
      bit = 0;
      row++;
    }
    else
    {
      for (; bit < order; bit++)
        lo[row] |= ((AddressElemType) 1 << (order - 1 - bit));
      row++;
    }

    for (; row < data.n_rows; row++)
      for (; bit < order; bit++)
        lo[row] |= ((AddressElemType) 1 << (order - 1 - bit));
  }

  // The bound shouldn't contain too many subrectangles.
  // In order to minimize the number of hyperrectangles we set last bits
  // of the first address in the next node to 0 and last bits of the last
  // address in the previous node to 1 in such a way that the ordering is not
  // disturbed.
  if (begin > 0)
  {
    // Omit leading equal bits.
    size_t row = 0;
    const arma::Col<AddressElemType>& lo = addresses[begin - 1].first;
    arma::Col<AddressElemType>& hi = addresses[begin].first;

    for (; row < data.n_rows; row++)
      if (lo[row] != hi[row])
        break;

    size_t bit = 0;

    for (; bit < order; bit++)
      if ((lo[row] & ((AddressElemType) 1 << (order - 1 - bit))) !=
          (hi[row] & ((AddressElemType) 1 << (order - 1 - bit))))
        break;

    bit++;

    // Replace insignificant bits.
    if (bit == order)
    {
      bit = 0;
      row++;
    }
    else
    {
      for (; bit < order; bit++)
        hi[row] &= ~((AddressElemType) 1 << (order - 1 - bit));
      row++;
    }

    for (; row < data.n_rows; row++)
      for (; bit < order; bit++)
        hi[row] &= ~((AddressElemType) 1 << (order - 1 - bit));
  }

  // Set the minimum and the maximum addresses.
  for (size_t k = 0; k < bound.Dim(); k++)
  {
    bound.LoAddress()[k] = addresses[begin].first[k];
    bound.HiAddress()[k] = addresses[begin + count - 1].first[k];
  }
  bound.UpdateAddressBounds(data.cols(begin, begin + count - 1));

  return true;
}