本文整理汇总了C++中Segment::back方法的典型用法代码示例。如果您正苦于以下问题:C++ Segment::back方法的具体用法?C++ Segment::back怎么用?C++ Segment::back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segment
的用法示例。
在下文中一共展示了Segment::back方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
/* update the penalty matrix : matrixB_
* @param beta current estimates
* @param segment segment repartition from FusedLassoSolver
*/
void FusedLassoPenalty::update(STK::VectorX const& beta, Segment const& segment)
{
//resize to the current size
offDiagonal_.resize(beta.size()-1);
mainDiagonal_.resize(beta.range());
//we have to multiply lambda1 by the number of element of the segment to keep the tight structure when regrouping variable
if(beta.size() == 1)
mainDiagonal_.front() = segment.front().size() * lambda1_/(std::abs(beta.front()) + eps_);
else
{
// first element
offDiagonal_.front() = -lambda2_/(std::abs(beta[beta.begin()+1]-beta.front()) + eps_);
mainDiagonal_.front() = segment.front().size() * lambda1_/(std::abs(beta.front()) + eps_) - offDiagonal_.front();
// intermediate elements
for(int i = beta.begin()+1; i < beta.lastIdx(); i++)
{
offDiagonal_[i] = -lambda2_/(std::abs(beta[i+1]-beta[i]) + eps_);
mainDiagonal_[i] = segment[i].size() * lambda1_/(std::abs(beta[i]) + eps_) - offDiagonal_[i] - offDiagonal_[i-1];
}
// last element
mainDiagonal_.back() = segment.back().size() * lambda1_/(std::abs(beta.back()) + eps_) - offDiagonal_[beta.lastIdx()-1];
}
}