本文整理汇总了C++中var::atype方法的典型用法代码示例。如果您正苦于以下问题:C++ var::atype方法的具体用法?C++ var::atype怎么用?C++ var::atype使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类var
的用法示例。
在下文中一共展示了var::atype方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scalar
void DFTBase::scalar(const var& iVar, var& oVar) const
{
// Check the arrays are OK
if (iVar.type() != TYPE_ARRAY)
throw error("DFTBase::scalar: DFTBase input must be vector");
if (oVar.type() != TYPE_ARRAY)
throw error("DFTBase::scalar: DFTBase output must be vector");
if (iVar.atype() != (mImpl->inverse
? mImpl->inverseType.type()
: mImpl->forwardType.type()
))
throw error("DFTBase::scalar: wrong input type");
if (oVar.atype() != (mImpl->inverse
? mImpl->forwardType.type()
: mImpl->inverseType.type()
))
throw error("DFTBase::scalar: wrong output type");
// DFTBase always broadcasts to vector()
broadcast(iVar, oVar);
// MKL does not include the divide by N on the inverse
if (mImpl->inverse)
oVar /= mImpl->oSize;
}
示例2: vector
void Transpose::vector(var iVar, ind iOffsetI, var& oVar, ind iOffsetO) const
{
assert(oVar);
int dim = iVar.dim();
ind rows = iVar.shape(dim-2);
ind cols = iVar.shape(dim-1);
if (iVar.is(oVar))
// In place transpose
switch (iVar.atype())
{
case TYPE_FLOAT:
inPlace<float>(oVar.ptr<float>(iOffsetO), rows, cols);
break;
case TYPE_DOUBLE:
inPlace<double>(oVar.ptr<double>(iOffsetO), rows, cols);
break;
default:
throw error("Transpose::vector(): unknown type");
}
else
// Transpose to new location
switch (iVar.atype())
{
case TYPE_FLOAT:
outOfPlace<float>(iVar.ptr<float>(iOffsetI), rows, cols,
oVar.ptr<float>(iOffsetO));
break;
case TYPE_DOUBLE:
outOfPlace<double>(iVar.ptr<double>(iOffsetI), rows, cols,
oVar.ptr<double>(iOffsetO));
break;
default:
throw error("Transpose::vector(): unknown type");
}
}