本文整理汇总了C++中VectorXd::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ VectorXd::remove方法的具体用法?C++ VectorXd::remove怎么用?C++ VectorXd::remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VectorXd
的用法示例。
在下文中一共展示了VectorXd::remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fastLasso
//.........这里部分代码省略.........
// lower triangular matrix, sometimes upper
// hence we define quadratic matrix and use
// triangularView() to interpret matrix the
// correct way
L.conservativeResize(k+1, k+1);
for(int j = 0; j < k; j++) {
L(k, j) = l(j);
L(j, k) = l(j);
}
L(k,k) = lkk;
}
}
// add new variable to active set or drop it for good
// in case of singularity
if(rank == k) {
// singularity: drop variable for good
ignores.append(newJ, s);
s++; // increase number of ignored variables
p--; // decrease number of variables
if(p < maxActive) {
// adjust maximum number of active variables
maxActive = p;
}
} else {
// no singularity: add variable to active set
active.append(newJ, k);
// keep track of sign of correlation for new active variable
signs.append(sign(corY(newJ)), k);
k++; // increase number of active variables
}
}
// remove new active or ignored variables from inactive variables
// and corresponding vector of current correlations
inactive.remove(newActive);
corInactiveY.remove(newActive);
m = inactive.size(); // update number of inactive variables
}
// prepare for computation of step size
// here double precision of signs is necessary
VectorXd b = L.triangularView<Lower>().solve(signs);
VectorXd G = L.triangularView<Upper>().solve(b);
// correlations of active variables with equiangular vector
double corActiveU = 1/sqrt(G.dot(signs));
// coefficients of active variables in linear combination forming the
// equiangular vector
VectorXd w = G * corActiveU; // note that this has the right signs
// equiangular vector
VectorXd u;
if(!useGram) {
// we only need equiangular vector if we don't use the precomputed
// Gram matrix, otherwise we can compute the correlations directly
// from the Gram matrix
u = VectorXd::Zero(n);
for(int i = 0; i < n; i++) {
for(int j = 0; j < k; j++) {
u(i) += xs(i, active(j)) * w(j);
}
}
}
// compute step size in equiangular direction
double step;
if(k < maxActive) {
// correlations of inactive variables with equiangular vector
VectorXd corInactiveU(m);
if(useGram) {
for(int j = 0; j < m; j++) {