本文整理汇总了C++中Array1D类的典型用法代码示例。如果您正苦于以下问题:C++ Array1D类的具体用法?C++ Array1D怎么用?C++ Array1D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Array1D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SegmentDataByIDX
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;
}
示例2: parentIndex
BayesNetwork::BayesNetwork(Array1D<Discretizer*> &discretizers)
: parentIndex(discretizers.size()),
probTables(discretizers.size()),
discretizers(discretizers)
{
parentIndex.setAllTo(-1);
}
示例3: 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;
}
示例4: 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;
}
示例5: upsample
void upsample(const Array1D<T>& v, int usf, Array1D<T>& u)
{
// it_assert1(usf >= 1, "upsample: upsampling factor must be equal or greater than one" );
u.set_size(v.length()*usf);
u.clear();
for(long i=0;i<v.length();i++)
u(i*usf)=v(i);
}
示例6: apply_function
Array1D<T> apply_function(fT (*f)(fT), const Array1D<T>& data)
{
Array1D<T> out(data.length());
for (int i=0;i<data.length();i++)
out[i]=static_cast<T>(f(static_cast<fT>(data[i])));
return out;
}
示例7: adjust_quant_indices
const Array1D adjust_quant_indices(const Array1D& qIndices, const int qMatrix) {
Array1D aQIndices(qIndices.ranges());
// Adjust all the quantisers in qIndices
std::transform(qIndices.data(), qIndices.data()+qIndices.num_elements(),
aQIndices.data(),
std::bind2nd(std::ptr_fun(adjust_quant_index), qMatrix) );
return aQIndices;
}
示例8: assign_mat_ar1d
void assign_mat_ar1d(Matrix& m, const Array1D< double >& a)
{
m.NewMatrix(1, a.dim());
Matrix::r_iterator p_m(m.begin());
for(long i = 0; i < a.dim(); ++i) {
*p_m = a[i];
++p_m;
}
}
示例9: 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;
}
示例10: zero_pad
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;
}
示例11: repeat
Array1D<T> repeat(const Array1D<T>& v, int norepeats)
{
Array1D<T> temp(v.length()*norepeats);
for(int i=0;i<v.length();i++) {
for(int j=0;j<norepeats;j++)
temp(i*norepeats+j)=v(i);
}
return temp;
}
示例12: lininterp
void lininterp(const Array1D<T>& v, int usf, Array1D<T>& u)
{
// it_assert1(usf >= 1, "lininterp: upsampling factor must be equal or greater than one" );
long L = (v.length()-1)*usf+1;
u.set_size(L);
for (long j = 0; j < L-1; j++) {
//u(j) = (v(j/usf) + (j % usf)/((float)usf)*(v((j+usf)/usf)-v(j/usf)));
u(j) = (v(j/usf) + (j % usf)/((double)usf)*(v((j+usf)/usf)-v(j/usf)));
}
u(L-1) = v(v.length()-1);
}
示例13: 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]);
}
}
示例14: inverse_quantise_transform_np
const Array2D inverse_quantise_transform_np(const Array2D& qCoeffs,
const Array2D& qIndices,
const Array1D& qMatrix) {
// TO DO: Check numberOfSubbands=3n+1 ?
BlockVector aQIndices(qMatrix.ranges());
const int numberOfSubbands = qMatrix.size();
for (char band=0; band<numberOfSubbands; ++band) {
aQIndices[band] = adjust_quant_indices(qIndices, qMatrix[band]);
}
return inverse_quantise_subbands_np(qCoeffs, aQIndices);
}
示例15: 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);
}