本文整理汇总了C++中BitMatrix::Height方法的典型用法代码示例。如果您正苦于以下问题:C++ BitMatrix::Height方法的具体用法?C++ BitMatrix::Height怎么用?C++ BitMatrix::Height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitMatrix
的用法示例。
在下文中一共展示了BitMatrix::Height方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BppUpdateSets
void BppUpdateSets(BitMatrix& nonopt_set,
BitMatrix& infeas_set,
const BitMatrix& not_opt_mask,
const DenseMatrix<T>& X,
const DenseMatrix<T>& Y,
const BitMatrix& passive_set)
{
// This function performs the equivalent of these operations:
//
// nonopt_set = not_opt_mask & (Y < T(0)) & ~passive_set;
// infeas_set = not_opt_mask & (X < T(0)) & passive_set;
const unsigned int height = not_opt_mask.Height();
const unsigned int width = not_opt_mask.Width();
if ( (static_cast<unsigned int>(X.Height()) != height) ||
(static_cast<unsigned int>(Y.Height()) != height) ||
(passive_set.Height() != height))
throw std::logic_error("BppUpdateSets: height mismatch");
if ( (static_cast<unsigned int>(X.Width()) != width) ||
(static_cast<unsigned int>(Y.Width()) != width) ||
(passive_set.Width() != width))
throw std::logic_error("BppUpdateSets: width mismatch");
nonopt_set.Resize(height, width);
infeas_set.Resize(height, width);
const unsigned int BITS = BitMatrix::BITS_PER_WORD;
const unsigned int MASK = nonopt_set.Mask();
assert(infeas_set.Mask() == MASK);
unsigned int* buf_r = nonopt_set.Buffer();
const unsigned int ldim_r = nonopt_set.LDim();
unsigned int* buf_i = infeas_set.Buffer();
const unsigned int ldim_i = infeas_set.LDim();
const unsigned int* buf_m = not_opt_mask.LockedBuffer();
const unsigned int ldim_m = not_opt_mask.LDim();
const T* buf_x = X.LockedBuffer();
const unsigned int ldim_x = X.LDim();
const T* buf_y = Y.LockedBuffer();
const unsigned int ldim_y = Y.LDim();
const unsigned int* buf_p = passive_set.LockedBuffer();
const unsigned int ldim_p = passive_set.LDim();
const unsigned int full_wds = height / BITS;
const unsigned int extra = height - BITS*full_wds;
assert(ldim_r >= ldim_m);
assert(ldim_r >= ldim_p);
OPENMP_PRAGMA(omp parallel for)
for (unsigned int c=0; c<width; ++c)
{
unsigned int offset_r = c*ldim_r;
unsigned int offset_i = c*ldim_i;
unsigned int offset_m = c*ldim_m;
unsigned int offset_x = c*ldim_x;
unsigned int offset_y = c*ldim_y;
unsigned int offset_p = c*ldim_p;
unsigned int r_wd = 0, r=0;
for (; r_wd<full_wds; ++r_wd)
{
unsigned int x_wd = 0, y_wd = 0;
for (unsigned int q=0; q<BITS; ++q, ++r)
{
if (buf_x[offset_x + r] < T(0))
x_wd |= (1 << q);
if (buf_y[offset_y + r] < T(0))
y_wd |= (1 << q);
}
buf_r[offset_r + r_wd] = buf_m[offset_m + r_wd] & y_wd & ~buf_p[offset_p + r_wd];
buf_i[offset_i + r_wd] = buf_m[offset_m + r_wd] & x_wd & buf_p[offset_p + r_wd];
}
if (extra > 0)
{
unsigned int x_wd = 0, y_wd = 0;
for (unsigned int q=0; q<extra; ++q, ++r)
{
if (buf_x[offset_x + r] < T(0))
x_wd |= (1 << q);
if (buf_y[offset_y + r] < T(0))
y_wd |= (1 << q);
}
buf_r[offset_r + r_wd] = MASK & buf_m[offset_m + r_wd] & y_wd & ~buf_p[offset_p + r_wd];
buf_i[offset_i + r_wd] = MASK & buf_m[offset_m + r_wd] & x_wd & buf_p[offset_p + r_wd];
}
}
}