本文整理汇总了C++中Array1D::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Array1D::size方法的具体用法?C++ Array1D::size怎么用?C++ Array1D::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array1D
的用法示例。
在下文中一共展示了Array1D::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CombinationWithDuplicatedElementsHelper
static void CombinationWithDuplicatedElementsHelper(Array1D &array, int left, int k,
int times, Array1D &temp, Array2D &result)
{
assert(left >= 0);
if (array.size() - left < k) { return; }
if (k == 0) {
result.push_back(temp);
return;
}
if (left == 0 || array[left] != array[left - 1]) {
temp.push_back(array[left]);
CombinationWithDuplicatedElementsHelper(array, left + 1, k - 1, 1, temp, result);
temp.pop_back();
CombinationWithDuplicatedElementsHelper(array, left + 1, k, 1, temp, result);
}
else {
if (temp.size() >= times && temp[temp.size() - times] == array[left]) {
temp.push_back(array[left]);
CombinationWithDuplicatedElementsHelper(array, left + 1, k - 1, times + 1, temp, result);
temp.pop_back();
}
CombinationWithDuplicatedElementsHelper(array, left + 1, k, times + 1, temp, result);
}
}
示例2: parentIndex
BayesNetwork::BayesNetwork(Array1D<Discretizer*> &discretizers)
: parentIndex(discretizers.size()),
probTables(discretizers.size()),
discretizers(discretizers)
{
parentIndex.setAllTo(-1);
}
示例3: temp
vector<Mat> SegmentDataByIDX(const Mat& data, const Mat& idx)
{
assert(data.type() == CV_32F || data.type() == CV_64F);
assert(data.rows > 0 && data.cols > 0 && idx.rows > 0 && idx.cols > 0);
assert(data.cols == idx.cols);
Array2D idx_hash;
if (idx.type() != CV_32S) {
Mat idx_tmp = idx;
Mat_<int> tmp;
idx_tmp.convertTo(tmp, CV_32S);
idx_hash = ComputeIDX(tmp);
} else{
idx_hash = ComputeIDX(idx);
}
if (idx_hash.empty()) { return vector<Mat>(); }
vector<Mat> result(idx_hash.size());
for (int i = 0; i < idx_hash.size(); i++) {
Array1D cur = idx_hash[i];
if (cur.empty()) { return vector<Mat>(); }
Mat temp(data.rows, cur.size(), data.type());
Mat col(data.rows, 1, data.type());
for (int j = 0; j < cur.size(); j++) {
col = temp(Range(0, data.rows), Range(j, j + 1));
data(Range(0, data.rows), Range(cur[j] - 1, cur[j])).copyTo(col);
}
result[i] = temp;
}
return result;
}
示例4:
static void CombinationWithDuplicatedElementsVer2Helper(Array1D &array, int left,
int k, int times,
Array1D &temp,
Array2D &result)
{
if (array.size() - left < k) { return; }
if (k == 0) {
result.push_back(temp);
return;
}
for (int i = left; i <= array.size(); i++) {
if (i == 0 || array[i] != array[i - 1]) {
times = 1;
temp.push_back(array[i]);
CombinationWithDuplicatedElementsVer2Helper(array, i + 1, k - 1, 1, temp, result);
temp.pop_back();
}
else {
times++;
if (temp.size() >= times - 1 && temp[temp.size() - times + 1] == array[i]) {
temp.push_back(array[i]);
CombinationWithDuplicatedElementsVer2Helper(array, i + 1, k - 1, times, temp, result);
temp.pop_back();
}
}
}
}
示例5: CombinationWithDuplicatedElementsByNonRecursion
Array2D CombinationWithDuplicatedElementsByNonRecursion(Array1D array, int K)
{
Array2D result;
if (array.empty() || K <= 0) { return result; }
if (array.size() < K) {
result.push_back(array); /** @warning maybe exclude it */
return result;
}
std::sort(array.begin(), array.end());
result.push_back(Array1D());
int last = array[0], opt_result_num = 1;
for (int i = 0; i < array.size(); i++) {
if (array[i] != last) {
last = array[i];
opt_result_num = result.size();
}
Array2D::size_type result_size = result.size();
for (int j = result_size - 1; j >= result_size - opt_result_num; j--) {
result.push_back(result[j]);
result.back().push_back(array[i]);
}
}
return result;
}
示例6: T
Array1D<T> zero_pad(const Array1D<T>& v, int n)
{
it_assert(n>=v.size(), "zero_pad() cannot shrink the vector!");
Array1D<T> v2(n);
v2.set_subvector(0, v.size()-1, v);
if (n > v.size())
v2.set_subvector(v.size(), n-1, T(0));
return v2;
}
示例7: CombinationByDecrease
Array2D CombinationByDecrease(Array1D array, int K)
{
Array2D result;
if (array.empty() || K <= 0) { return result; }
if (array.size() < K) {
result.push_back(array); /** @warning maybe exclude it */
return result;
}
Array1D temp(K);
CombinationByDecreaseHelper(array, array.size(), K, temp, result);
}
示例8: Combination
Array2D Combination(Array1D array, int K) {
Array2D result;
if (array.empty() || K <= 0) { return result; }
if (array.size() < K) {
result.push_back(array);
return result;
}
Array1D temp;
CombinationHelper(array, 0, array.size() - 1, K, temp, result);
return result;
}
示例9: evaluate
void
CDFBasis<d,dt>::evaluate
(const unsigned int derivative,
const RIndex& lambda,
const Array1D<double>& points, Array1D<double>& values)
{
values.resize(points.size());
for (unsigned int i(0); i < values.size(); i++) {
values[i] = evaluate(derivative, lambda, points[i]);
}
}
示例10: PermutationHelper
static void PermutationHelper(Array1D &array, int index, Array2D &result)
{
if (index == array.size()) {
result.push_back(array);
return;
}
for (int i = index; i < array.size(); ++i) {
std::swap(array[index], array[i]);
PermutationHelper(array, index + 1, result);
std::swap(array[index], array[i]);
}
}
示例11: cross
Array1D<T> cross(const Array1D<T>& v1, const Array1D<T>& v2)
{
it_assert( v1.size() == 3 && v2.size() == 3, "cross: vectors should be of size 3");
Array1D<T> r(3);
r(0) = v1(1) * v2(2) - v1(2) * v2(1);
r(1) = v1(2) * v2(0) - v1(0) * v2(2);
r(2) = v1(0) * v2(1) - v1(1) * v2(0);
return r;
}
示例12: PermutationUniqueHelper
static void PermutationUniqueHelper(Array1D &array, int index, Array2D &result)
{
if (index == array.size()) {
result.push_back(array);
return;
}
for (int i = index; i < array.size(); i++) {
if (HasSameElement(array, index, i, array[i])) {
std::swap(array[index], array[i]);
PermutationUniqueHelper(array, index + 1, result);
std::swap(array[index], array[i]);
}
}
}
示例13: getAlignmentLength
int AlignmentBuilder::getAlignmentLength(
Array1D<Poset<ResidueAddress>::Vertex<ResidueAddress>*> &roots)
{
int n=roots.size(), r=0;
for(int i=0 ; i<n ; ++i)
if(roots[i]->getData().hasLeafDescendents() || wantOrphans) ++r;
return r;
}
示例14: py_glDrawBuffers
static PyObject* py_glDrawBuffers(PyObject *, PyObject *args) {
CHECK_ARG_COUNT(args, 1);
Array1D<Enum> buffers;
if (buffers.fromPy(PyTuple_GetItem(args, 0))) {
glDrawBuffers(buffers.size(), buffers);
}
Py_RETURN_NONE;
}
示例15: py_glShaderSource
static PyObject* py_glShaderSource(PyObject *, PyObject *args) {
CHECK_ARG_COUNT(args, 2);
Uint shader(PyTuple_GetItem(args, 0));
Array1D<String> strings;
if (strings.fromPy(PyTuple_GetItem(args, 1))) {
glShaderSource(shader, strings.size(), strings, 0);
}
Py_RETURN_NONE;
}