当前位置: 首页>>代码示例>>C++>>正文


C++ DataBase::beginOfCycle方法代码示例

本文整理汇总了C++中DataBase::beginOfCycle方法的典型用法代码示例。如果您正苦于以下问题:C++ DataBase::beginOfCycle方法的具体用法?C++ DataBase::beginOfCycle怎么用?C++ DataBase::beginOfCycle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataBase的用法示例。


在下文中一共展示了DataBase::beginOfCycle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: runFeatureExtraction

void runFeatureExtraction(DataBase db,char* cycleBegin,char* cycleEnd){
	
	//Initialization
	vector<vector<double> > singleResult;//Result for a single file
	double* tempResult;//Result for a single attribute(variable)
	vector<double>temp;//All data in a single file for an attribute
	double* temp_array;//Turn temp into array version for computing(actually only pass memory address)
	FileData tempfd;
	db.extractById(db.beginOfCycle(atoi(cycleBegin)),tempfd);
   	attrNum = tempfd.attrSize();


	//enable or disable
	switch (seg){
		case disable:{//no segmentation
			
			//Initialization

			string tempFile;
			tempFile += "Output_noSeg_C";
			tempFile += cycleBegin;
			tempFile +="-C";
			tempFile += cycleEnd;
			tempFile += ".csv";

			FILE* fout = fopen(tempFile.c_str(),"w+");

			fprintf(fout,"%s,%s,%s","Id","Original_ID","Cycle");
			for(unsigned j = 0;j < attrNum;j++){
				for(unsigned i = 0;i < featureNum;i++){
					fprintf(fout,",%s_%s",tempfd.attrTypeVector[j+1].c_str(),featureName[i]);
				}
			}

			
			/*Call FE by file,attribute and data size
			EX: calculate 12 features of first attribute of first file
			while first call FE.
			Result:File_1_Attr_1_firstfeature - File_1_Attr_1_lasttfeature*/
    		for(unsigned id=db.beginOfCycle(atoi(cycleBegin));
				id<db.endOfCycle(atoi(cycleEnd)); id++){
				//Initialization for a new file
				FileData fd;
        		if(db.extractById(id,fd)){
        			//start FE
					rowData = fd.dataVector;
					dataSize = fd.dataVector.size();
					temp.clear();
					temp.resize(dataSize);
					singleResult.clear();
					singleResult.resize(featureNum);
					for(unsigned j = 0;j < attrNum;j++){
						for(unsigned i = 0;i < dataSize;i++)
							temp[i] = rowData[i][j];
	 					temp_array = &temp[0];
						tempResult = FeatureExtraction(dataSize,temp_array);
						for(unsigned i = 0;i < featureNum;i++){
							singleResult[i].push_back(tempResult[i]);
						}
					}
					//output

					fprintf(fout,"\n");

					fprintf(fout,"%d,%d,%d",fd.id,fd.fid,fd.nCycle);
					for(unsigned j = 0;j < attrNum;j++){
						for(unsigned i = 0;i < featureNum;i++){
							fprintf(fout,",%lf",singleResult[i][j]);
						}
					}


					if( (id)!=0 && ((id)%100)==0 )
						cout<<"Computing "<<id<<" files."<<endl;
				}
			}
			cout<<"Computing done."<<endl;
			cout<<"Output processing..."<<endl;
			cout<<"Output done."<<endl;
			fclose(fout);
		}
			break;
			
		case enable:{//segmentation enabled

			//Initialization
			vector<double > originalDP;
			unsigned tempSize = 0;
			unsigned dpID = 0;
			string f1,f2;
			char itoatemp[50] ;
			f1 = "Output_seg";
			itoa(segNum,itoatemp,10);
			f1 += itoatemp;
			f1 += "_";
			f2 = f1;
			f2 += "2_C";
			f1 += "1_C";
			f2 += cycleBegin;
			f2 += "-C";
//.........这里部分代码省略.........
开发者ID:Po-haoHuang,项目名称:LED_FE_FS,代码行数:101,代码来源:run_FE.cpp


注:本文中的DataBase::beginOfCycle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。