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


C++ MixedData::print方法代码示例

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


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

示例1: calculateFeedbackSignalsFromFirstAndSecondSideband

bool MathematicaPeakFinder::calculateFeedbackSignalsFromFirstAndSecondSideband(const MixedData& peaks, MixedData& feedback)
{
	WolframLibraryData libData = 0;
	WolframRTL_initialize(WolframLibraryVersion);
	libData = WolframLibraryData_new(WolframLibraryVersion);

	//Setup arguments

	//Initialize peak tensor
	MTensor peakTensor;
	int err;
	mint type = MType_Real;
	mint rank = 2;
	mint dims[2];
	dims[0] = 4;
	dims[1] = 2;
	err = libData->MTensor_new(type, rank, dims, &peakTensor);

	if(err != 0)
		return false;

	mint peakPos[2];

	for(int i = 1; i <= dims[0]; i++) {
		peakPos[0] = i;
		for(int j = 1; j <= dims[1]; j++) {
			peakPos[1] = j;
			err = libData->MTensor_setReal(peakTensor, peakPos, 
				peaks.getVector().at(i-1).getVector().at(j-1).getDouble());
		}
	}

	if(err != 0)
		return false;

	//Initialize result tensor
	MTensor feedbackResults;
	type = MType_Real;
	rank = 1;
	mint dimsRes[1];
	dimsRes[0] = 2;
	err = libData->MTensor_new(type, rank, dimsRes, &feedbackResults);

	if(err != 0)
		return false;

	Initialize_getFeedbackSignalsFromFirstAndSecondSidebands(libData);			//Begin call to Mathematica code

	err = getFeedbackSignalsFromFirstAndSecondSidebands(libData, peakTensor, &feedbackResults);

	Uninitialize_getFeedbackSignalsFromFirstAndSecondSidebands(libData);		//End call to Mathematica code

		
	if( err == 0) {
		//Copy results of the feedback function

		double value = 0;
		mint pos[1];
		feedback.clear();
		
		for(int j = 1; j <= 2; j++) {
			pos[0] = j;
			err = libData->MTensor_getReal(feedbackResults, pos, &value);
			feedback.addValue(value);
		}
	}
	
	cout << "Feedback results:" << endl;
	cout << feedback.print() << endl;

	libData->MTensor_free(peakTensor);
	libData->MTensor_free(feedbackResults);

	return (err == 0);
}
开发者ID:jasonhogan,项目名称:sti-deprecated,代码行数:75,代码来源:MathematicaPeakFinder.cpp

示例2: findFirstAndSecondOrderSidebandPeaks

bool MathematicaPeakFinder::findFirstAndSecondOrderSidebandPeaks(const STI::Types::TDataMixedSeq& rawSidebandData, 
														const CalibrationResults_ptr& calibration, 
														double firstOrderSidebandSpacing, 
														double secondOrderSidebandSpacing, 
														double minimumX,
														double targetRange,
														MixedData& peaks,
														double carrierOffset)
{
	WolframLibraryData libData = 0;
	WolframRTL_initialize(WolframLibraryVersion);
	libData = WolframLibraryData_new(WolframLibraryVersion);

	//Setup arguments

	MTensor formatedSidebandData;		//List of {x,y} pairs, with gaps when y is below threshold

	if(!convertRawScopeData(libData, rawSidebandData, formatedSidebandData)) {
		return false;
	}

	//Initialize calibration tensor
	MTensor calTensor;
	int err;
	mint type = MType_Real;
	mint rank = 2;
	mint dims[2];
	dims[0] = 2;
	dims[1] = 2;
	err = libData->MTensor_new(type, rank, dims, &calTensor);

	if(err != 0)
		return false;

	if(!calibration->getPeaks(libData, &calTensor))
		return false;

	//Initialize results tensor
	MTensor peakResults;
	type = MType_Real;
	rank = 2;
	dims[2];
	dims[0] = 4;	//First and second order sidebands: { {+1, -1}, {+2, -2} }
	dims[1] = 2;	//{time, peak height}
	err = libData->MTensor_new(type, rank, dims, &peakResults);

	mreal firstOrderSidebandSpacingArg = firstOrderSidebandSpacing;
	mreal secondOrderSidebandSpacingArg = secondOrderSidebandSpacing;
	mreal minX = minimumX;
	mreal targetRangeArg = targetRange;
	mreal carrierOffsetArg = carrierOffset;

	if(err == 0) {
		Initialize_findFirstAndSecondOrderSidebands(libData);		//Begin call to Mathematica code

		err = findFirstAndSecondOrderSidebands(libData, formatedSidebandData, calTensor, firstOrderSidebandSpacingArg, secondOrderSidebandSpacingArg, minX, targetRangeArg, carrierOffsetArg, &peakResults);

		Uninitialize_findFirstAndSecondOrderSidebands(libData);		//End call to Mathematica code
	}
	
	if( err == 0) {
		//Copy results of peak search

		double value = 0;
		mint pos[2];
		peaks.clear();
		MixedData peak;
		for(int i = 1; i <= 4; i++) {
			pos[0] = i;
			peak.clear();
			for(int j = 1; j <= 2; j++) {
				pos[1] = j;
				err = libData->MTensor_getReal(peakResults, pos, &value);
				peak.addValue(value);
			}
			peaks.addValue(peak);
		}
	}

	cout << "Peak find results:" << endl;
	cout << peaks.print() << endl;
	

	libData->MTensor_free(formatedSidebandData);
	libData->MTensor_free(calTensor);
	libData->MTensor_free(peakResults);

	return (err == 0);

}
开发者ID:jasonhogan,项目名称:sti-deprecated,代码行数:90,代码来源:MathematicaPeakFinder.cpp


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