本文整理汇总了C++中arma::Col::elem方法的典型用法代码示例。如果您正苦于以下问题:C++ Col::elem方法的具体用法?C++ Col::elem怎么用?C++ Col::elem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arma::Col
的用法示例。
在下文中一共展示了Col::elem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
arma::Col<T> OptimisationProblem<T>::getDiversifiedParameter(
const arma::Col<T>& parameter) const noexcept {
assert(parameter.n_elem == numberOfDimensions_);
return parameterRotation_ * (parameterScaling_ % parameter.elem(parameterPermutation_) - parameterTranslation_);
}
示例2: polynomial
arma::Col<double> polynomial(
const arma::Col<double>& parameter,
const arma::uword polynomialOrder) {
arma::Col<double> polynomial(polynomialSize(parameter.n_elem, polynomialOrder));
// For any polynomial, all constant terms are 1.
switch (polynomialOrder) {
case 0: { // Constant polynomials
// Constant term
polynomial(0) = 1.0;
}
break;
case 1: { // Linear polynomials
// Linear term
polynomial.head(parameter.n_elem) = parameter;
// Constant term
polynomial(parameter.n_elem) = 1;
}
break;
case 2: { // Quadratic polynomials
// Quadratic term
arma::uword n = 0;
for (arma::uword k = 0; k < parameter.n_elem; ++k) {
for (arma::uword l = k; l < parameter.n_elem; ++l) {
polynomial(n++) = parameter(k) * parameter(l);
}
}
// Linear term
polynomial.subvec(n, n + parameter.n_elem - 1) = parameter;
// Constant term
polynomial(polynomial.n_elem - 1) = 1;
}
break;
case 3: { // Cubic polynomials
// Cubic term
arma::uword n = 0;
for (arma::uword k = 0; k < parameter.n_elem; ++k) {
for (arma::uword l = k; l < parameter.n_elem; ++l) {
for (arma::uword m = l; m < parameter.n_elem; ++m) {
polynomial(n++) = parameter(k) * parameter(l) * parameter(m);
}
}
}
// Quadratic term
for (arma::uword k = 0; k < parameter.n_elem; ++k) {
for (arma::uword l = k; l < parameter.n_elem; ++l) {
polynomial(n++) = parameter(k) * parameter(l);
}
}
// Linear term
polynomial.subvec(n, n + parameter.n_elem - 1) = parameter;
// Constant term
polynomial(polynomial.n_elem - 1) = 1;
}
break;
default: { // Polynomials of degree >= 4
// All terms, expect the linear and constant one.
arma::uword n = 0;
// Generates the term for all degrees > 1
for (arma::uword d = 2; d <= polynomialOrder; ++d) {
for (const auto& multicombination : multicombinations(parameter.n_elem, d)) {
polynomial(n++) = arma::prod(parameter.elem(multicombination));
}
}
// Linear term
polynomial.subvec(n, n + parameter.n_elem - 1) = parameter;
// Constant term
polynomial(polynomial.n_elem - 1) = 1;
}
break;
}
return polynomial;
}