本文整理汇总了C++中linalg::Matrix::removeColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::removeColumn方法的具体用法?C++ Matrix::removeColumn怎么用?C++ Matrix::removeColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linalg::Matrix
的用法示例。
在下文中一共展示了Matrix::removeColumn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void restrictedOptimizationHandler::activeSet<Type>::activeSetMethod(const LinAlg::Matrix<Type> &P,
const LinAlg::Matrix<Type> &q,
const LinAlg::Matrix<Type> &A0,
const LinAlg::Matrix<Type> &b0,
Type tol)
{
LinAlg::Matrix<Type> S = this->activeRestrictions(A0,b0,tol);
if(S.getNumberOfColumns() > P.getNumberOfRows())
S = S(1,from(1)-->P.getNumberOfRows());
if(S.getNumberOfColumns() == 0 || S.getNumberOfRows() == 0)
S = LinAlg::Matrix<Type>(1);
unsigned contS = 0;
for(unsigned terminate = 1; terminate <= 100; ++terminate)
{
LinAlg::Matrix<Type> A = A0(S,from(1)-->A0.getNumberOfColumns());
LinAlg::Matrix<Type> b = b0(S,1);
LinAlg::Matrix<Type> Xeqp,v,t(b0.getNumberOfRows(),1);
this->KKT(A,b,Xeqp,v);
if(LinAlg::sumOfColumnsElements(A0*Xeqp - b0 <= tol)(1,1) == b0.getNumberOfRows())
{
if(v.getNumberOfRows() == 0)
{
this->x = Xeqp;
break;
}
else if((LinAlg::sumOfColumnsElements<Type>(v >= 0.0)(1,1) == v.getNumberOfRows()))
{
this->x = Xeqp;
break;
}
else
{
for (unsigned i = 1; i <= v.getNumberOfRows(); ++i)
{
if(v(i,1)< 0)
{
S.removeColumn(i);
contS = S.getNumberOfColumns();
break;
}
}
}
this->x = Xeqp;
}
else
{
LinAlg::Matrix<Type> pos;
A = LinAlg::Matrix<Type>();
b = LinAlg::Matrix<Type>();
t = LinAlg::Zeros<Type>(b0.getNumberOfRows(),1);
for (unsigned i = 1; i<= A0.getNumberOfRows(); ++i)
{
if((A0(i,from(1)-->A0.getNumberOfColumns())*Xeqp)(1,1) > b0(i,1))
{
A = A || A0(i,from(1)-->A0.getNumberOfColumns());
b = b || LinAlg::Matrix<Type>(b0(i,1));
LinAlg::Matrix<Type> tTemp = (b0(i,1) - (A0(i,from(1)-->A0.getNumberOfColumns())*this->x)(1,1)/((A0(i,from(1)-->A0.getNumberOfColumns())*(Xeqp-this->x))(1,1)));
LinAlg::Matrix<Type> xTemp = this->x + tTemp*(Xeqp - this->x);
if(LinAlg::sumOfColumnsElements<Type>((A0*xTemp - b0) <= tol)(1,1) == b0.getNumberOfRows())
{
t = t|tTemp;
pos = pos | i;
}
}
}
Type MaxT = LinAlg::MaxValue(t);
unsigned posMax = LinAlg::lineOfMaxValue(t);
this->x = this->x + MaxT*(Xeqp - this->x);
if(S.getNumberOfColumns() < this->QuadMat.getNumberOfRows() && pos.getNumberOfColumns() != 0 && pos.getNumberOfRows() != 0)
{
// contS = contS+1;
// S(1,contS) = pos(1,posMax);
S = S | pos(1,posMax);
}
// else
// {
// contS = 0;
// }5
}
}
}