本文整理汇总了C++中NDArray::getWorkspace方法的典型用法代码示例。如果您正苦于以下问题:C++ NDArray::getWorkspace方法的具体用法?C++ NDArray::getWorkspace怎么用?C++ NDArray::getWorkspace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NDArray
的用法示例。
在下文中一共展示了NDArray::getWorkspace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: w
NDArray<T> Householder<T>::evalHHmatrix(const NDArray<T>& x) {
// input validation
if(!x.isVector() && !x.isScalar())
throw "ops::helpers::Householder::evalHHmatrix method: input array must be vector or scalar!";
NDArray<T> w((int)x.lengthOf(), 1, x.ordering(), x.getWorkspace()); // column-vector
NDArray<T> wT(1, (int)x.lengthOf(), x.ordering(), x.getWorkspace()); // row-vector (transposed w)
T coeff;
T normX = x.template reduceNumber<simdOps::Norm2<T>>();
const T min = DataTypeUtils::min<T>();
if(normX*normX - x(0)*x(0) <= min) {
normX = x(0);
coeff = (T)0.;
w = (T)0.;
}
else {
if(x(0) >= (T)0.)
normX = -normX; // choose opposite sign to lessen roundoff error
T u0 = x(0) - normX;
coeff = -u0 / normX;
w.assign(x / u0);
}
w(0) = (T)1.;
wT.assign(&w);
NDArray<T> identity((int)x.lengthOf(), (int)x.lengthOf(), x.ordering(), x.getWorkspace());
identity.setIdentity(); // identity matrix
return identity - mmul(w, wT) * coeff;
}
示例2: tail
void Householder<T>::evalHHmatrixDataI(const NDArray<T>& x, T& coeff, T& normX) {
int rows = (int)x.lengthOf()-1;
int num = 1;
if(rows == 0) {
rows = 1;
num = 0;
}
NDArray<T> tail(rows, 1, x.ordering(), x.getWorkspace());
evalHHmatrixData(x, tail, coeff, normX);
if(x.isRowVector()) {
NDArray<T>* temp = x.subarray({{}, {num, x.sizeAt(1)}});
temp->assign(tail);
delete temp;
}
else {
NDArray<T>* temp = x.subarray({{num, x.sizeAt(0)}, {}});
temp->assign(tail);
delete temp;
}
}