本文整理汇总了C++中arma::Col::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ Col::resize方法的具体用法?C++ Col::resize怎么用?C++ Col::resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arma::Col
的用法示例。
在下文中一共展示了Col::resize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNextFrame
//ReadHTKHeader();
bool CmpParser::getNextFrame(arma::Col<double> &frame, int derivate){
if (file.is_open()==false)
return false;
if (hdr.sampKind&1024){//compressed mode. TODO to be implemented
std::cerr<<"HTK compressed mode is not yet supported"<<std::endl;
return false;
}
else{
unsigned int dim=hdr.sampSize/4;
arma::Col<double> data;
if (!this->readData(data)){
return false;
}
if (prev1.n_rows!=data.n_rows){
prev2=data;
if (!this->readData(prev1)){
return false;
}
if (!this->readData(data)){
return false;
}
}
if (derivate==2){
frame.resize(3*dim);
frame.subvec(0, dim-1)=prev1;
frame.subvec(dim, 2*dim-1)=(data-prev2)/2;
frame.subvec(2*dim, 3*dim-1)=prev2-2*prev1+data;
}
else if (derivate==1){
frame.resize(2*dim);
frame.subvec(0, dim-1)=prev1;
frame.subvec(dim, 2*dim-1)=(data-prev2)/2;
}
else{
frame.resize(dim);
frame=data;
}
prev2=prev1;
prev1=data;
//std::cout<<"data:"<<std::endl;
//std::cout<<frame<<std::endl;
return true;
}
}
示例2: readData
bool CmpParser::readData(arma::Col<double> &data,short code){
unsigned int dim=hdr.sampSize/4;
data.resize(dim);
if (code==0){
float *p=new float;
for (int i=0;i<dim;i++){
if (file.read((char*)p,sizeof(float))==0)
return false;
SwapInt32((int*)p);
data[i]=*p;
}
delete p;
}
return true;
}
示例3: projections
bool SpillTree<MetricType, StatisticType, MatType, HyperplaneType, SplitType>::
SplitPoints(const double tau,
const double rho,
const arma::Col<size_t>& points,
arma::Col<size_t>& leftPoints,
arma::Col<size_t>& rightPoints)
{
arma::vec projections(points.n_elem);
size_t left = 0, right = 0, leftFrontier = 0, rightFrontier = 0;
// Count the number of points to the left/right of the splitting hyperplane.
for (size_t i = 0; i < points.n_elem; i++)
{
// Store projection value for future use.
projections[i] = hyperplane.Project(dataset->col(points[i]));
if (projections[i] <= 0)
{
left++;
if (projections[i] > -tau)
leftFrontier++;
}
else
{
right++;
if (projections[i] < tau)
rightFrontier++;
}
}
const double p1 = double (left + rightFrontier) / points.n_elem;
const double p2 = double (right + leftFrontier) / points.n_elem;
if ((p1 <= rho || rightFrontier == 0) &&
(p2 <= rho || leftFrontier == 0))
{
// Perform the actual splitting considering the overlapping buffer. Points
// with projection value in the range (-tau, tau) are included in both,
// leftPoints and rightPoints.
leftPoints.resize(left + rightFrontier);
rightPoints.resize(right + leftFrontier);
for (size_t i = 0, rc = 0, lc = 0; i < points.n_elem; i++)
{
if (projections[i] < tau || projections[i] <= 0)
leftPoints[lc++] = points[i];
if (projections[i] > -tau)
rightPoints[rc++] = points[i];
}
// Return true, because it is a overlapping node.
return true;
}
// Perform the actual splitting ignoring the overlapping buffer. Points
// with projection value less than or equal to zero are included in leftPoints
// and points with projection value greater than zero are included in
// rightPoints.
leftPoints.resize(left);
rightPoints.resize(right);
for (size_t i = 0, rc = 0, lc = 0; i < points.n_elem; i++)
{
if (projections[i] <= 0)
leftPoints[lc++] = points[i];
else
rightPoints[rc++] = points[i];
}
// Return false, because it isn't a overlapping node.
return false;
}