本文整理汇总了C++中Measure函数的典型用法代码示例。如果您正苦于以下问题:C++ Measure函数的具体用法?C++ Measure怎么用?C++ Measure使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Measure函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Report
void Report(CHAIN **Chain, int NChain, HBOND **HBond, COMMAND *Cmd)
{
FILE *Out;
if( !strlen(Cmd->OutFile) )
Out = stdout;
else
if( !(Out = fopen(Cmd->OutFile,"w")) )
die("Can not open output file %s\n",Cmd->OutFile);
if( !Cmd->ReportSummaryOnly )
ReportGeneral(Chain,Out);
ReportSummary(Chain,NChain,Out,Cmd);
ReportShort(Chain,NChain,Out,Cmd);
ReportTurnTypes(Chain,NChain,Out,Cmd);
ReportSSBonds(Chain,Out);
if( !Cmd->ReportSummaryOnly )
ReportDetailed(Chain,NChain,Out,Cmd);
if( Cmd->ReportBonds )
ReportHydrBonds(Chain,NChain,HBond,Out,Cmd);
if( Cmd->Measure ) {
Measure(Chain,NChain,0,Cmd,Out);
Measure(Chain,NChain,1,Cmd,Out);
}
if( Out != stdout )
fclose(Out);
}
示例2: Pipeline1
//TSP -> NN -> Generations( g, ForkJoin ( n, SA -> 2-OPT ) ) -> TSP'
void Pipeline1(tsp_class& tsp_instance, unsigned int number_of_tasks, unsigned int number_of_generations)
{
#pragma region "PipelineConfiguration"
auto a = Args<General_args_type>(make_General_args(number_of_generations, number_of_tasks));
auto sa = Args<SA_args_type>(make_SA_args(1000.0, 0.00001, 0.999, 400));
auto aco = Args<ACO_args_type>();
auto ga = Args<GA_args_type>();
const char* pipeline_description = "TSP -> NN -> Generations( g, ForkJoin ( n, SA -> 2-OPT ) ) -> TSP'";
display_args(pipeline_description, a, sa, aco, ga);
auto g = a[0].number_of_iterations_or_generations;
auto n = a[0].number_of_tasks_in_parallel;
auto _TSP = TSP(just(tsp_instance));
auto _DisplayInput = Display("TSP INPUT", DisplayFlags::All);
auto _NN = Measure(NN(), Display("NEAREST NEIGHBOUR", DisplayFlags::EmitMathematicaGraphPlot));
auto _SA_2OPT = Chain(SA(sa[0].initial_temperature, sa[0].stopping_criteria_temperature,
sa[0].decreasing_factor, sa[0].monte_carlo_steps), _2OPT());
auto _ForkJoin = [](unsigned int n, TSP::transformer_type map_fun){ return Measure(ForkJoin(n, map_fun)); };
auto _DisplayOutput = Display("TSP OUTPUT", DisplayFlags::EmitMathematicaGraphPlot);
#pragma endregion
//TSP -> NN -> Generations( g, ForkJoin ( n, SA -> 2-OPT ) ) -> TSP'
auto result = _TSP
.map(_DisplayInput)
.map(_NN)
.map(Generations(g, _ForkJoin(n, _SA_2OPT)))
.map(_DisplayOutput);
}
示例3: Pipeline2
//TSP -> NN -> Generations( g, ForkJoin ( n, GA -> 2-OPT ) ) -> TSP'
void Pipeline2(tsp_class& tsp_instance, unsigned int number_of_tasks,
unsigned int number_of_generations)
{
#pragma region "PipelineConfiguration"
auto a = Args<General_args_type>(make_General_args(number_of_generations, number_of_tasks));
auto sa = Args<SA_args_type>();
auto aco = Args<ACO_args_type>();
auto ga = Args<GA_args_type>(make_GA_args(1000, 10, 5, 50000, 10, 0.9));
const char* pipeline_description = "TSP -> NN -> Generations( g, ForkJoin ( n, GA -> 2-OPT ) ) -> TSP'";
display_args(pipeline_description, a, sa, aco, ga);
auto g = a[0].number_of_iterations_or_generations;
auto n = a[0].number_of_tasks_in_parallel;
auto _TSP = TSP(just(tsp_instance));
auto _DisplayInput = Display("TSP INPUT", DisplayFlags::All);
auto _NN = Measure(NN(), Display("NEAREST NEIGHBOUR", DisplayFlags::EmitMathematicaGraphPlot));
auto _GA_2OPT = Chain(GA(ga[0].population_size, ga[0].mutation_percentage, ga[0].group_size,
ga[0].number_of_generations, ga[0].nearby_cities, ga[0].nearby_cities_percentage), _2OPT());
auto _ForkJoin = [](unsigned int n, TSP::transformer_type map_fun){ return Measure(ForkJoin(n, map_fun)); };
auto _DisplayOutput = Display("TSP OUTPUT", DisplayFlags::EmitMathematicaGraphPlot);
#pragma endregion
//TSP -> NN -> Generations( g, ForkJoin ( n, GA -> 2-OPT ) ) -> TSP'
auto result = _TSP
.map(_DisplayInput)
.map(_NN)
.map(Generations(g, _ForkJoin(n, _GA_2OPT)))
.map(_DisplayOutput);
}
示例4: Measure
// raise a measure to a power, like c in e=mc^2
Measure Measure::power (int power)
{
double d = quantity;
int i;
int powTmp = (power > 0) ? power : -power;
if (power == 0) return Measure (1, &Unit::UNITLESS);
if (power == 1) return *this;
for (i = 1; i < powTmp; i++) d *= quantity;
if (power < 0) d = 1.0 / d;
return Measure (d, unit->power (power));
}
示例5: main
int main (int argc, char * argv[])
{
Measure height = Measure (&METER);
Measure time = Measure (&SECOND);
ParseArgs (argc, argv, &time);
height = G * 0.5 * time.power (2); // d = 1/2 a t^2
cout << "At " << G.GetQuantity();
cout << " meters per second per second," << endl << "an object will fall ";
cout << height.GetQuantity() << " meters in ";
cout << time.GetQuantity() << " seconds." << endl;
exit (0);
}
示例6: FindCharacterIndexAtOffset
int32 FSlateFontMeasure::FindFirstWholeCharacterIndexAfterOffset( const FString& Text, int32 StartIndex, int32 EndIndex, const FSlateFontInfo& InFontInfo, const int32 HorizontalOffset, bool IncludeKerningWithPrecedingChar, float FontScale ) const
{
int32 FoundLastCharacterIndex = FindCharacterIndexAtOffset( Text, StartIndex, EndIndex, InFontInfo, HorizontalOffset, IncludeKerningWithPrecedingChar, FontScale );
float TextWidth = Measure( Text, StartIndex, EndIndex, InFontInfo, IncludeKerningWithPrecedingChar, FontScale ).X;
float AvailableWidth = TextWidth - HorizontalOffset;
float RightStringWidth = Measure( Text, FoundLastCharacterIndex, EndIndex, InFontInfo, IncludeKerningWithPrecedingChar, FontScale ).X;
if ( AvailableWidth < RightStringWidth )
{
++FoundLastCharacterIndex;
}
return FoundLastCharacterIndex;
}
示例7: main
int main(int argc, char **argv)
{
/* The command line argument: -d is used to determine if the test is being run
in debug mode. The regress tool requires only one line output:PASS or FAIL.
All of the printfs associated with this test has been handled with a if (debug_mode)
test.
Usage: test_name -d
*/
PLOptStatus os;
PLOptState *opt = PL_CreateOptState(argc, argv, "d:");
while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
{
if (PL_OPT_BAD == os) continue;
switch (opt->option)
{
case 'd': /* debug mode */
debug_mode = 1;
break;
default:
break;
}
}
PL_DestroyOptState(opt);
/* main test */
PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
PR_STDIO_INIT();
if (argc > 2) {
count = atoi(argv[2]);
} else {
count = DEFAULT_COUNT;
}
#if defined(XP_UNIX)
Measure(NativeSelectTest, "time to call 1 element select()");
#endif
Measure(EmptyPRSelect, "time to call Empty PR_select()");
Measure(EmptyNativeSelect, "time to call Empty select()");
Measure(PRSelectTest, "time to call 1 element PR_select()");
if (!debug_mode) Test_Result (NOSTATUS);
PR_Cleanup();
}
示例8: WXUNUSED
void Lyrics::OnPaint(wxPaintEvent & WXUNUSED(event))
{
if (!this->GetParent()->IsShown())
return;
if (mLyricsStyle == kBouncingBallLyrics)
{
wxPaintDC dc(this);
if (!mMeasurementsDone)
Measure(&dc);
#ifdef __WXMAC__
// Mac OS X automatically double-buffers the screen for you,
// so our bitmap is unneccessary
HandlePaint(dc);
#else
wxBitmap bitmap(mWidth, mKaraokeHeight);
wxMemoryDC memDC;
memDC.SelectObject(bitmap);
HandlePaint(memDC);
dc.Blit(0, 0, mWidth, mKaraokeHeight, &memDC, 0, 0, wxCOPY, FALSE);
#endif
}
else // (mLyricsStyle == kHighlightLyrics)
{
//v causes flicker in ported version
// this->SetHighlightFont();
}
}
示例9: PrintStatus
static uint8_t PrintStatus(const CLS1_StdIOType *io) {
uint8_t buf[64], buf2[16];
QuadTime_t timing;
int i;
CLS1_SendStatusStr((unsigned char*)"quadcalib", (unsigned char*)"\r\n", io->stdOut);
for(i=0; i<NOF_SIGNALS; i++) {
if (Measure(i, &timing)==ERR_OK) {
buf[0] = '\0';
UTIL1_strcatNum8u(buf, sizeof(buf), timing.lowPercent);
UTIL1_strcat(buf, sizeof(buf), (uint8_t*)"% to ");
UTIL1_strcatNum8u(buf, sizeof(buf), timing.highPercent);
UTIL1_strcat(buf, sizeof(buf), (uint8_t*)"%, ");
UTIL1_strcat(buf, sizeof(buf), (uint8_t*)"high: ");
UTIL1_strcatNum32u(buf, sizeof(buf), timing.highTicks);
UTIL1_strcat(buf, sizeof(buf), (uint8_t*)" ticks, low: ");
UTIL1_strcatNum32u(buf, sizeof(buf), timing.lowTicks);
UTIL1_strcat(buf, sizeof(buf), (uint8_t*)" ticks\r\n");
} else {
UTIL1_strcpy(buf, sizeof(buf), (uint8_t*)"TIMEOUT\r\n");
}
if (i==0) {
UTIL1_strcpy(buf2, sizeof(buf2), (uint8_t*)" Right A,C0");
} else if (i==1) {
UTIL1_strcpy(buf2, sizeof(buf2), (uint8_t*)" Right B,C1");
} else if (i==2) {
UTIL1_strcpy(buf2, sizeof(buf2), (uint8_t*)" Left C,C2");
} else {
UTIL1_strcpy(buf2, sizeof(buf2), (uint8_t*)" Left D,C3");
}
CLS1_SendStatusStr(buf2, buf, io->stdOut);
}
return ERR_OK;
}
示例10: if
Boolean CComposingView::MoveCursor(
/* [in] */ Int32 keyCode)
{
if (keyCode != IKeyEvent::KEYCODE_DPAD_LEFT
&& keyCode != IKeyEvent::KEYCODE_DPAD_RIGHT) {
return FALSE;
}
if (EDIT_PINYIN == mComposingStatus) {
Int32 offset = 0;
if (keyCode == IKeyEvent::KEYCODE_DPAD_LEFT) {
offset = -1;
}
else if (keyCode == IKeyEvent::KEYCODE_DPAD_RIGHT) offset = 1;
mDecInfo->MoveCursor(offset);
}
else if (SHOW_STRING_LOWERCASE == mComposingStatus) {
if (keyCode == IKeyEvent::KEYCODE_DPAD_LEFT
|| keyCode == IKeyEvent::KEYCODE_DPAD_RIGHT) {
mComposingStatus = EDIT_PINYIN;
Measure(IViewGroupLayoutParams::WRAP_CONTENT, IViewGroupLayoutParams::WRAP_CONTENT);
RequestLayout();
}
}
Invalidate();
return TRUE;
}
示例11: Tune
static uint8_t Tune(const CLS1_StdIOType *io, uint8_t channel, MOT_MotorDevice *motorHandle) {
#define TUNE_MOTOR_PERCENT 20
uint16_t dac;
int i;
QuadTime_t timing;
uint8_t buf[48];
uint8_t res;
//#if PL_HAS_DRIVE
// DRV_SetMode(DRV_MODE_NONE); /* turn off drive mode */
//#endif
MOT_SetSpeedPercent(motorHandle, TUNE_MOTOR_PERCENT);
CLS1_SendStr((uint8_t*)"Tuning channel...\r\n", io->stdOut);
res = ERR_FAILED;
for(i=0,dac=0;dac<=MCP4728_MAX_DAC_VAL;i++) {
UTIL1_strcpy(buf, sizeof(buf), (uint8_t*)"Channel: ");
UTIL1_chcat(buf, sizeof(buf), (uint8_t)('A'+channel)); /* 0:A, 1:B, 2:C, 3:D */
UTIL1_strcat(buf, sizeof(buf), (uint8_t*)" DAC: 0x");
UTIL1_strcatNum16Hex(buf, sizeof(buf), dac);
UTIL1_chcat(buf, sizeof(buf), ' ');
CLS1_SendStr(buf, io->stdOut);
if (MCP4728_FastWriteDAC(channel, dac)!=ERR_OK) { /* writes single channel DAC value, not updating EEPROM */
CLS1_SendStr((uint8_t*)"ERROR writing DAC channel!\r\n", io->stdErr);
res = ERR_FAILED;
break;
}
WAIT1_WaitOSms(100); /* wait some time to allow DAC and OP-Amp change */
if (Measure(channel, &timing)==ERR_OK) {
buf[0] = '\0';
UTIL1_strcatNum8u(buf, sizeof(buf), timing.highPercent);
UTIL1_strcat(buf, sizeof(buf), (uint8_t*)"% high, low ");
UTIL1_strcatNum8u(buf, sizeof(buf), timing.lowPercent);
UTIL1_strcat(buf, sizeof(buf), (uint8_t*)"%\r\n");
CLS1_SendStr(buf, io->stdOut);
if (timing.highPercent==50 || timing.lowPercent==50) {
CLS1_SendStr((uint8_t*)"Set!\r\n", io->stdErr);
CLS1_SendStr((uint8_t*)"Writing to EEPROM...\r\n", io->stdOut);
if (MCP4728_WriteDACandEE(channel, dac)!=ERR_OK) {
CLS1_SendStr((uint8_t*)"ERROR writing DAC/EEPROM\r\n", io->stdErr);
res = ERR_FAILED;
break;
}
CLS1_SendStr((uint8_t*)"...done!\r\n", io->stdOut);
res = ERR_OK;
break; /* go to next channel */
}
dac += 0x1; /* smaller increase */
} else {
CLS1_SendStr((uint8_t*)"No signal\r\n", io->stdErr);
dac += 0x10; /* larger increase */
}
} /* for finding DAC value */
MOT_SetSpeedPercent(motorHandle, 0); /* turn off again */
if (res!=ERR_OK) {
CLS1_SendStr((uint8_t*)"ERROR!\r\n", io->stdErr);
}
CLS1_SendStr((uint8_t*)"Tuning finished!\r\n", io->stdOut);
return res;
}
示例12: dc
void CXTPMarkupUIElement::Arrange(CRect rcFinalRect)
{
if (GetVisibility() == xtpMarkupVisibilityCollapsed)
{
m_rcFinalRect = rcFinalRect;
m_bArrangeDirty = FALSE;
m_bNeverArranged = FALSE;
return;
}
if (m_bNeverMeasured)
{
CXTPMarkupDrawingContext dc(GetMarkupContext());
Measure(&dc, rcFinalRect.Size());
}
if ((m_bArrangeDirty || m_bNeverArranged) || (rcFinalRect != m_rcFinalRect))
{
m_bNeverArranged = FALSE;
m_bArrangeInProgress = TRUE;
ArrangeCore(rcFinalRect);
m_bArrangeInProgress = FALSE;
UpdateBoundRect();
}
m_rcFinalRect = rcFinalRect;
m_bArrangeDirty = FALSE;
}
示例13: GetDesiredSize
void CXTPMarkupUIElement::InvalidateMeasureOverride(CXTPMarkupDrawingContext* pDC)
{
if (!m_bMeasureInProgress && !m_bNeverMeasured)
{
m_bMeasureDirty = TRUE;
m_bArrangeDirty = TRUE;
CSize sz = GetDesiredSize();
Measure(pDC, m_szPreviousAvailableSize);
if (sz != GetDesiredSize())
{
m_bMeasureDirty = TRUE;
m_bArrangeDirty = TRUE;
CXTPMarkupUIElement* pParent = MARKUP_DYNAMICCAST(CXTPMarkupUIElement, GetVisualParent());
if (pParent)
{
pParent->InvalidateMeasureOverride(pDC);
}
else if (m_pMarkupContext)
{
m_pMarkupContext->OnInvalidateArrange(this);
}
}
else
{
Arrange(m_rcFinalRect);
InvalidateVisual();
}
}
}
示例14: main
void main(int argc, char **argv)
{
PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
PR_STDIO_INIT();
if (argc > 1) {
count = atoi(argv[1]);
} else {
count = DEFAULT_COUNT;
}
Measure(statPRStat, "time to call PR_GetFileInfo()");
Measure(statStat, "time to call stat()");
PR_Cleanup();
}
示例15: Measure
// ================================== Battery ==================================
void Battery_t::Task() {
if(!Delay.Elapsed(&Timer, 999)) return;
Measure();
// Discharging slope
if ((State == bsFull) && (IValue < BATTERY_HALF)) {
State = bsHalf;
return;
}
if ((State == bsHalf) && (IValue < BATTERY_EMPTY)) {
State = bsEmpty;
return;
}
// Charging slope
if ((State == bsHalf) && (IValue > (BATTERY_HALF+60))) {
State = bsFull;
return;
}
if ((State == bsEmpty) && (IValue > (BATTERY_EMPTY+60))) {
State = bsHalf;
return;
}
// Indicate discharged battery
if ((State == bsEmpty) && (Door.State == dsClosed) && (Leds.Led[0].Mode != lmBlink)) {
Leds.Led[0].Blink(Settings.ColorDoorClosed, Settings.BlinkDelay);
Leds.Led[2].Blink(Settings.ColorDoorClosed, Settings.BlinkDelay);
}
}