本文整理汇总了C++中DoubleVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ DoubleVector::size方法的具体用法?C++ DoubleVector::size怎么用?C++ DoubleVector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleVector
的用法示例。
在下文中一共展示了DoubleVector::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createCombinedMatrix
void TimeWarp::createCombinedMatrix(DoubleMatrix myChromaMatrix, DoubleVector energyVector, DoubleMatrix* chromaEnergyMatrix){
chromaEnergyMatrix->clear();
int sizeRatio = energyVector.size() / myChromaMatrix.size();//
printf("COMBINE: size of my chroma is %i\n", (int) myChromaMatrix.size());// energyVector.size() / myChromaMatrix.size();
printf("COMBINED: size ratio of energy to chroma is %i \n", sizeRatio);
int chromaSize = myChromaMatrix.size();
// printf("index is %i\n", index);
for (int i = 0;i < energyVector.size();i++){
DoubleVector d;
int index = min(chromaSize-1, (int) floor(i/sizeRatio));
for (int y = 0;y < 12;y++){
d.push_back(myChromaMatrix[index][y]);//
}
d.push_back(energyVector[i]);
(*chromaEnergyMatrix).push_back(d);
}
printf("COMBINED: size of chroma energy is %i\n", (int)(*chromaEnergyMatrix).size());
// int x = (int)(*chromaEnergyMatrix).size()/3;
// printf("energy[%i] %f \n", x, energyVector[x]);
/*
for (int y = 0;y < 13;y++){
printf("chroma[%i][%i] %f \n", x, y, myChromaMatrix[x/sizeRatio][y]);
printf("c[%i][%i] %f \n", x, y, (*chromaEnergyMatrix)[x][y]);
}
printf("\n");
*/
}
示例2: classify
int SupportVectorMachine::classify(const DoubleVector& x, DoubleVector& scores, int index_offset) {
#ifdef HAVE_LIBSVM
struct svm_node* toclassify=(struct svm_node*)malloc(sizeof(struct svm_node)*x.size()+1);
for(uint d=0;d<x.size();++d) {
toclassify[d].index=d+index_offset;
toclassify[d].value=x[d];
}
toclassify[x.size()].index=-1;
int C=this->C();
double *s=new double[C];
svm_predict_values(model,toclassify,s);
scores=DoubleVector(C,0.0);
double maxScore=-std::numeric_limits<double>::max();
int argmaxScore=-1;
for(int c=0;c<C;++c) {
scores[c]=s[c];
if(scores[c]>maxScore) {
maxScore=scores[c];
argmaxScore=c;
}
}
free(toclassify); delete(s);
return argmaxScore;
#else
return 0;
#endif
}
示例3: configure
void Pattern::configure(ConfigurationParameters& params, QString prefix) {
//--- get all parameters with the prefix 'cluster:'
QStringList clusterList = params.getParametersWithPrefixList( prefix, "cluster:" );
foreach( QString cluster, clusterList ) {
QString id = cluster.split(':')[1];
if ( id.isNull() || id.isEmpty() ) continue;
//--- now, it check if there is a inputs and outputs parameter and load it
QString str = params.getValue( prefix + "inputs:" + id );
DoubleVector inputs;
if (!str.isNull()) {
QStringList list = str.split(QRegExp("\\s+"), QString::SkipEmptyParts);
for( int i=0; i<list.size(); i++) {
inputs.append( list[i].toDouble() );
}
}
str = params.getValue( prefix + "outputs:" + id );
DoubleVector outputs;
if (!str.isNull()) {
QStringList list = str.split(QRegExp("\\s+"), QString::SkipEmptyParts);
for( int i=0; i<list.size(); i++) {
outputs.append( list[i].toDouble() );
}
}
if ( inputs.size() == 0 && outputs.size() == 0 ) continue;
Cluster* cl = params.getObjectFromParameter<Cluster>( prefix+cluster, false, true );
if ( inputs.size() > 0 ) {
setInputsOf( cl, inputs );
}
if ( outputs.size() > 0 ) {
setOutputsOf( cl, outputs );
}
}
示例4: multiple
void StopRule::multiple (DoubleVector &vec1, DoubleVector &vec2, DoubleMatrix &proMat) {
int row_, col_;
proMat.resize(vec1.size());
for (row_ = 0; row_ < vec1.size(); row_++)
proMat[row_].resize(vec2.size());
for (row_ = 0; row_ < vec1.size(); row_ ++)
for (col_ = 0; col_ < vec2.size(); col_ ++)
proMat[row_][col_] = vec1[row_] * vec2[col_];
}
示例5: smoothData
void LowessSmoothing::smoothData(const DoubleVector& input_x, const DoubleVector& input_y, DoubleVector& smoothed_output)
{
if (input_x.size() != input_y.size())
{
throw Exception::InvalidValue(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION,
"Sizes of x and y values not equal! Aborting... ", String(input_x.size()));
}
// unable to smooth over 2 or less data points (we need at least 3)
if (input_x.size() <= 2)
{
smoothed_output = input_y;
return;
}
Size input_size = input_y.size();
// const Size q = floor( input_size * alpha );
const Size q = (window_size_ < input_size) ? static_cast<Size>(window_size_) : input_size - 1;
DoubleVector distances(input_size, 0.0);
DoubleVector sortedDistances(input_size, 0.0);
for (Size outer_idx = 0; outer_idx < input_size; ++outer_idx)
{
// Compute distances.
// Size inner_idx = 0;
for (Size inner_idx = 0; inner_idx < input_size; ++inner_idx)
{
distances[inner_idx] = std::fabs(input_x[outer_idx] - input_x[inner_idx]);
sortedDistances[inner_idx] = distances[inner_idx];
}
// Sort distances in order from smallest to largest.
std::sort(sortedDistances.begin(), sortedDistances.end());
// Compute weigths.
std::vector<double> weigths(input_size, 0);
for (Size inner_idx = 0; inner_idx < input_size; ++inner_idx)
{
weigths.at(inner_idx) = tricube_(distances[inner_idx], sortedDistances[q]);
}
//calculate regression
Math::QuadraticRegression qr;
std::vector<double>::const_iterator w_begin = weigths.begin();
qr.computeRegressionWeighted(input_x.begin(), input_x.end(), input_y.begin(), w_begin);
//smooth y-values
double rt = input_x[outer_idx];
smoothed_output.push_back(qr.eval(rt));
}
return;
}
示例6: append
void DoubleVector::append(const DoubleVector& v)
{
const size_t old_size = x.size();
std::valarray<double> y(x); // old vector
x.resize(old_size + v.size());
end = start + x.size() - 1;
for (size_t i = 0; i < y.size(); ++i)
x[i] = y[i];
for (size_t i = 0; i < v.size(); ++i)
x[i + old_size] = v(i + v.displayStart());
}
示例7: drawVector
void PlotFunction::drawVector(DoubleVector& energyVec, int minIndex, int maxIndex, const WindowRegion& window, const double& maxNumberOfIndexPoints, const double& maxValue){
float screenHeight = window.height;
float screenWidth = window.width;
double numberOfIndexPoints = min(maxNumberOfIndexPoints, (double) maxIndex - minIndex);
double indicesPerStep = (maxIndex - minIndex) / numberOfIndexPoints;
double pixelsPerStep = window.width / numberOfIndexPoints;
int i, j;
double heightScalar = window.height / (1.1*maxValue);
int lastHeight = window.y + screenHeight - (energyVec[minIndex]*heightScalar);;
int newHeight;
int xPosition;
int lastXposition = window.x;
double exactIndex;
for (exactIndex = minIndex; exactIndex < maxIndex; exactIndex += indicesPerStep){
j = round(exactIndex);
i = j - minIndex;
if (j < energyVec.size()){
xPosition = window.x + i*pixelsPerStep;
newHeight = window.y + screenHeight - (energyVec[j]*heightScalar);
ofLine(lastXposition, lastHeight, xPosition, newHeight);
lastHeight = newHeight;
lastXposition = xPosition;
}
}
}
示例8: printHTML
void CosSimilarityList::printHTML ( ostream& os, const DoubleVector& c, const string& styleID ) const
{
for ( int i = 0 ; i < c.size () ; i++ ) {
if ( c [i] == -100.0 ) tableEmptyCell ( os, styleID );
else tableCellSigFig ( os, c [i], 3, false, styleID );
}
}
示例9: _computeCovarianceMat
void _computeCovarianceMat(const RDGeom::Point3DConstPtrVect &refPoints,
const RDGeom::Point3DConstPtrVect &probePoints,
const DoubleVector &weights, double covMat[3][3]) {
unsigned int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 3; j++) {
covMat[i][j] = 0.0;
}
}
unsigned int npt = refPoints.size();
CHECK_INVARIANT(npt == probePoints.size(), "Number of points mismatch");
CHECK_INVARIANT(npt == weights.size(),
"Number of points and number of weights do not match");
const double *wData = weights.getData();
const RDGeom::Point3D *rpt, *ppt;
double w;
for (i = 0; i < npt; i++) {
rpt = refPoints[i];
ppt = probePoints[i];
w = wData[i];
covMat[0][0] += w * (ppt->x) * (rpt->x);
covMat[0][1] += w * (ppt->x) * (rpt->y);
covMat[0][2] += w * (ppt->x) * (rpt->z);
covMat[1][0] += w * (ppt->y) * (rpt->x);
covMat[1][1] += w * (ppt->y) * (rpt->y);
covMat[1][2] += w * (ppt->y) * (rpt->z);
covMat[2][0] += w * (ppt->z) * (rpt->x);
covMat[2][1] += w * (ppt->z) * (rpt->y);
covMat[2][2] += w * (ppt->z) * (rpt->z);
}
}
示例10: printDelimited
void CosSimilarityList::printDelimited ( ostream& os, const DoubleVector& c ) const
{
for ( int i = 0 ; i < c.size () ; i++ ) {
if ( c [i] == -100.0 ) delimitedEmptyCell ( os );
else delimitedCellSigFig ( os, c [i], 3 );
}
}
示例11: main
int main(int argc, char **argv)
{
std::string cornerString=" 0.1 0.1 0.1 20 20 10";
typedef boost::tokenizer<boost::char_separator<char> > Tokenizer;
typedef std::vector<double> DoubleVector;
typedef boost::tokenizer<boost::char_separator<char> >::iterator TokIterator;
boost::char_separator<char> sep(", ");
Tokenizer tok(cornerString, sep);
DoubleVector corners;
corners.clear();
for (TokIterator it=tok.begin(); it!=tok.end(); ++it ) {
double q;
printf("");
sscanf(it->c_str(), "%lf", &q);
//DPrintf(DebugReaction," %lf ['%s']; ", q, it->c_str());
corners.push_back( q );
}
printf("the corners are:\n ");
printf("%e", corners[0]);
for(int i=1; i<corners.size(); ++i ) {
printf(", %e", corners[i]);
}
printf("\n");
}
示例12: doFrequency
void DataPartitions::doFrequency(DoubleVector dimData){
m_partitions.clear();
PairVector dimOrData;
initPairs(dimOrData, dimData);
pairSort(dimOrData);
int dimsize = dimData.size();
int nBins = this->m_rddtClust->m_rddtOp->m_nBins;
if(nBins == 0 ){
nBins = 1;
}
if(nBins>dimsize){
nBins = dimsize;
}
for(int i = 0; i< nBins; i++){
DataPartition* partition = new DataPartition();
partition->setPartitions(this);
partition->m_partitionIdx = i;
this->m_partitions.push_back(partition);
}
int partitionsize = (int)ceil((double)dimsize/(double)nBins);
for(unsigned i = 0; i< dimOrData.size(); i++){
int p = (int)((double)i/(double)partitionsize);
if(p>(int)m_partitions.size())
p=m_partitions.size();
int first = (dimOrData[i]).first;
(m_partitions[p])->m_parIndices.push_back(first);
}
}
示例13: ws
TEST_F(EnergyPlusFixture,ReverseTranslator_ScheduleDayInterval) {
// ScheduleDayInterval time entries contain the string 'Until: ' that must be
// stripped off before constructing a Time object. We are also more lenient in
// making this optional.
Workspace ws(StrictnessLevel::Draft,IddFileType(IddFileType::EnergyPlus));
OptionalWorkspaceObject owo = ws.addObject(IdfObject(IddObjectType::Schedule_Day_Interval));
ASSERT_TRUE(owo);
WorkspaceObject object = *owo;
object.setName("Heating Setpoint Design Day");
StringVector groupValues(2u);
groupValues[0] = std::string("Until: 12:00");
groupValues[1] = std::string("21.1");
object.pushExtensibleGroup(groupValues);
groupValues[0] = std::string("24:00");
groupValues[1] = std::string("20.5");
object.pushExtensibleGroup(groupValues);
ReverseTranslator translator;
Model model = translator.translateWorkspace(ws);
EXPECT_TRUE(translator.errors().empty());
// There are warnings related to ws being a partial model.
EXPECT_TRUE(translator.untranslatedIdfObjects().empty());
ScheduleDayVector daySchedules = model.getModelObjects<ScheduleDay>();
ASSERT_EQ(1u,daySchedules.size());
ScheduleDay daySchedule = daySchedules[0];
DoubleVector values = daySchedule.values();
ASSERT_EQ(2u,values.size());
EXPECT_DOUBLE_EQ(21.1,values[0]);
EXPECT_DOUBLE_EQ(20.5,values[1]);
TimeVector times = daySchedule.times();
ASSERT_EQ(2u,times.size());
EXPECT_EQ(Time(0,12,0),times[0]);
EXPECT_EQ(Time(0,24,0),times[1]);
}
示例14: _sumOfWeights
double _sumOfWeights(const DoubleVector &weights) {
const double *wData = weights.getData();
double res = 0.0;
for (unsigned int i = 0; i < weights.size(); i++) {
CHECK_INVARIANT(wData[i] > 0.0, "Negative weight specified for a point");
res += wData[i];
}
return res;
}
示例15: derivate
bool StepFunction::derivate( const DoubleVector& inputs, const DoubleVector&, DoubleVector& derivates ) const {
//--- return the same as if it is a sigmoid with lambda = 1
for( unsigned int i=0; i<inputs.size(); i++ ) {
double y;
y = 1.0/( 1.0 + std::exp( -inputs[i] ) );
derivates[i] = y * ( 1.0 - y );
}
return true;
}