本文整理汇总了C++中ArrayInfo::isVector方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayInfo::isVector方法的具体用法?C++ ArrayInfo::isVector怎么用?C++ ArrayInfo::isVector使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayInfo
的用法示例。
在下文中一共展示了ArrayInfo::isVector方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rdims
fg::Plot3* setup_plot3(const af_array P, fg::PlotType ptype, fg::MarkerType mtype)
{
Array<T> pIn = getArray<T>(P);
ArrayInfo Pinfo = getInfo(P);
af::dim4 P_dims = Pinfo.dims();
DIM_ASSERT(0, Pinfo.ndims() == 1 || Pinfo.ndims() == 2);
DIM_ASSERT(0, (P_dims[0] == 3 || P_dims[1] == 3) ||
(Pinfo.isVector() && P_dims[0]%3 == 0));
if(Pinfo.isVector()){
dim4 rdims(P_dims.elements()/3, 3, 1, 1);
pIn.modDims(rdims);
P_dims = pIn.dims();
}
if(P_dims[1] == 3){
pIn = transpose(pIn, false);
}
T max[3], min[3];
copyData(max, reduce<af_max_t, T, T>(pIn, 1));
copyData(min, reduce<af_min_t, T, T>(pIn, 1));
ForgeManager& fgMngr = ForgeManager::getInstance();
fg::Plot3* plot3 = fgMngr.getPlot3(P_dims.elements()/3, getGLType<T>(), ptype, mtype);
plot3->setColor(1.0, 0.0, 0.0);
plot3->setAxesLimits(max[0], min[0],
max[1], min[1],
max[2], min[2]);
plot3->setAxesTitles("X Axis", "Y Axis", "Z Axis");
copy_plot3<T>(pIn, plot3);
return plot3;
}
示例2: af_draw_hist
af_err af_draw_hist(const af_window wind, const af_array X, const double minval, const double maxval,
const af_cell* const props)
{
#if defined(WITH_GRAPHICS)
if(wind==0) {
std::cerr<<"Not a valid window"<<std::endl;
return AF_SUCCESS;
}
try {
ArrayInfo Xinfo = getInfo(X);
af_dtype Xtype = Xinfo.getType();
ARG_ASSERT(0, Xinfo.isVector());
fg::Window* window = reinterpret_cast<fg::Window*>(wind);
window->makeCurrent();
fg::Histogram* hist = NULL;
switch(Xtype) {
case f32: hist = setup_histogram<float >(X, minval, maxval); break;
case s32: hist = setup_histogram<int >(X, minval, maxval); break;
case u32: hist = setup_histogram<uint >(X, minval, maxval); break;
case s16: hist = setup_histogram<short >(X, minval, maxval); break;
case u16: hist = setup_histogram<ushort >(X, minval, maxval); break;
case u8 : hist = setup_histogram<uchar >(X, minval, maxval); break;
default: TYPE_ERROR(1, Xtype);
}
if (props->col>-1 && props->row>-1)
window->draw(props->col, props->row, *hist, props->title);
else
window->draw(*hist);
}
CATCHALL;
return AF_SUCCESS;
#else
return AF_ERR_NO_GFX;
#endif
}
示例3: af_assign_gen
af_err af_assign_gen(af_array *out,
const af_array lhs,
const dim_t ndims, const af_index_t* indexs,
const af_array rhs_)
{
af_array output = 0;
af_array rhs = rhs_;
// spanner is sequence index used for indexing along the
// dimensions after ndims
af_index_t spanner;
spanner.idx.seq = af_span;
spanner.isSeq = true;
try {
ARG_ASSERT(2, (ndims>0));
ARG_ASSERT(3, (indexs!=NULL));
int track = 0;
vector<af_seq> seqs(4, af_span);
for (dim_t i = 0; i < ndims; i++) {
if (indexs[i].isSeq) {
track++;
seqs[i] = indexs[i].idx.seq;
}
}
if (track==(int)ndims) {
// all indexs are sequences, redirecting to af_assign
return af_assign_seq(out, lhs, ndims, &(seqs.front()), rhs);
}
ARG_ASSERT(1, (lhs!=0));
ARG_ASSERT(4, (rhs!=0));
ArrayInfo lInfo = getInfo(lhs);
ArrayInfo rInfo = getInfo(rhs);
dim4 lhsDims = lInfo.dims();
dim4 rhsDims = rInfo.dims();
af_dtype lhsType= lInfo.getType();
af_dtype rhsType= rInfo.getType();
ARG_ASSERT(2, (ndims == 1) || (ndims == (dim_t)lInfo.ndims()));
if (ndims == 1 && ndims != (dim_t)lInfo.ndims()) {
af_array tmp_in = 0, tmp_out = 0;
AF_CHECK(af_flat(&tmp_in, lhs));
AF_CHECK(af_assign_gen(&tmp_out, tmp_in, ndims, indexs, rhs_));
AF_CHECK(af_moddims(out, tmp_out, lInfo.ndims(), lInfo.dims().get()));
AF_CHECK(af_release_array(tmp_in));
AF_CHECK(af_release_array(tmp_out));
return AF_SUCCESS;
}
ARG_ASSERT(1, (lhsType==rhsType));
ARG_ASSERT(3, (rhsDims.ndims()>0));
ARG_ASSERT(1, (lhsDims.ndims()>=rhsDims.ndims()));
ARG_ASSERT(2, (lhsDims.ndims()>=ndims));
if (*out != lhs) {
int count = 0;
AF_CHECK(af_get_data_ref_count(&count, lhs));
if (count > 1) {
AF_CHECK(af_copy_array(&output, lhs));
} else {
AF_CHECK(af_retain_array(&output, lhs));
}
} else {
output = lhs;
}
dim4 oDims = toDims(seqs, lhsDims);
// if af_array are indexs along any
// particular dimension, set the length of
// that dimension accordingly before any checks
for (dim_t i=0; i<ndims; i++) {
if (!indexs[i].isSeq) {
oDims[i] = getInfo(indexs[i].idx.arr).elements();
}
}
for (dim_t i = ndims; i < (dim_t)lInfo.ndims(); i++) {
oDims[i] = 1;
}
bool is_vector = true;
for (int i = 0; is_vector && i < oDims.ndims() - 1; i++) {
is_vector &= oDims[i] == 1;
}
//TODO: Move logic out of this
is_vector &= rInfo.isVector() || rInfo.isScalar();
if (is_vector) {
if (oDims.elements() != (dim_t)rInfo.elements() &&
rInfo.elements() != 1) {
AF_ERROR("Size mismatch between input and output", AF_ERR_SIZE);
}
if (rInfo.elements() == 1) {
AF_CHECK(af_tile(&rhs, rhs_, oDims[0], oDims[1], oDims[2], oDims[3]));
} else {
//.........这里部分代码省略.........