本文整理汇总了C++中realvec::normObsMinMax方法的典型用法代码示例。如果您正苦于以下问题:C++ realvec::normObsMinMax方法的具体用法?C++ realvec::normObsMinMax怎么用?C++ realvec::normObsMinMax使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类realvec
的用法示例。
在下文中一共展示了realvec::normObsMinMax方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
SelfSimilarityMatrix::myProcess(realvec& in, realvec& out)
{
if(this->getctrl("mrs_natural/mode")->to<mrs_natural>() == SelfSimilarityMatrix::outputDistanceMatrix)
{
//check if there are any elements to process at the input
//(in some cases, they may not exist!) - otherwise, do nothing
//(i.e. output will be zeroed out)
if(inSamples_ > 0)
{
unsigned int child_count = marsystems_.size();
if(child_count == 1)
{
mrs_natural nfeats = in.getRows();
//normalize input features if necessary
if(ctrl_normalize_->to<mrs_string>() == "MinMax")
in.normObsMinMax(); // (x - min)/(max - min)
else if(ctrl_normalize_->to<mrs_string>() == "MeanStd")
in.normObs(); // (x - mean)/std
//calculate the Covariance Matrix from the input, if defined
if(ctrl_calcCovMatrix_->to<mrs_natural>() & SelfSimilarityMatrix::fixedStdDev)
{
//fill covMatrix diagonal with fixed value (remaining values are zero)
MarControlAccessor acc(ctrl_covMatrix_);
realvec& covMatrix = acc.to<mrs_realvec>();
covMatrix.create(inObservations_, inObservations_);
mrs_real var = ctrl_stdDev_->to<mrs_real>();
var *= var;
for(mrs_natural i=0; i< inObservations_; ++i)
{
covMatrix(i,i) = var;
}
}
else if(ctrl_calcCovMatrix_->to<mrs_natural>() & SelfSimilarityMatrix::diagCovMatrix)
{
in.varObs(vars_); //FASTER -> only get the vars for each feature
mrs_natural dim = vars_.getSize();
//fill covMatrix diagonal with var values (remaining values are zero)
MarControlAccessor acc(ctrl_covMatrix_);
realvec& covMatrix = acc.to<mrs_realvec>();
covMatrix.create(dim, dim);
for(mrs_natural i=0; i< dim; ++i)
{
covMatrix(i,i) = vars_(i);
}
}
else if(ctrl_calcCovMatrix_->to<mrs_natural>() & SelfSimilarityMatrix::fullCovMatrix)
{
MarControlAccessor acc(ctrl_covMatrix_);
realvec& covMatrix = acc.to<mrs_realvec>();
in.covariance(covMatrix); //SLOWER -> estimate the full cov matrix
}
else if(ctrl_calcCovMatrix_->to<mrs_natural>() == SelfSimilarityMatrix::noCovMatrix)
{
ctrl_covMatrix_->setValue(realvec());
}
for(mrs_natural i=0; i < in.getCols(); ++i)
{
in.getCol(i, i_featVec_);
for(mrs_natural j=0; j <= i; ++j)
{
in.getCol(j, j_featVec_);
//stack i and j feat vecs
for(mrs_natural r=0; r < nfeats; ++r)
{
stackedFeatVecs_(r, 0) = i_featVec_(r);
stackedFeatVecs_(r+nfeats, 0) = j_featVec_(r);
}
//do the metric calculation for these two feat vectors
//and store it in the similarity matrix (which is symmetric)
marsystems_[0]->process(stackedFeatVecs_, metricResult_);
out(i,j) = metricResult_(0,0);
//metric should be symmetric!
out(j, i) = out(i, j);
}
}
}
else
{
out.setval(0.0);
if(child_count == 0)
{
MRSWARN("SelfSimilarityMatrix::myProcess - no Child Metric MarSystem added - outputting zero similarity matrix!");
}
else
{
MRSWARN("SelfSimilarityMatrix::myProcess - more than one Child MarSystem exists (i.e. invalid metric) - outputting zero similarity matrix!");
}
}
}
//MATLAB_PUT(out, "simMatrix");
//MATLAB_EVAL("figure(1);imagesc(simMatrix);");
//MATLAB_PUT(out, "simMat");
//MATLAB_EVAL(name_+"=["+name_+",simMat(:)'];");
//.........这里部分代码省略.........