• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Timing类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Timing的典型用法代码示例。如果您正苦于以下问题:C++ Timing类的具体用法?C++ Timing怎么用?C++ Timing使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: ovr_GetTimeInSeconds

FrameTimeManager::Timing FrameTimeManager::GetFrameTiming(unsigned frameIndex)
{
    Timing frameTiming = LocklessTiming.GetState();

    if (frameTiming.ThisFrameTime != 0.0)
    {
        // If timing hasn't been initialized, starting based on "now" is the best guess.
        frameTiming.InitTimingFromInputs(frameTiming.Inputs, RenderInfo.Shutter.Type,
                                         ovr_GetTimeInSeconds(), frameIndex);
    }
    
    else if (frameIndex > frameTiming.FrameIndex)
    {
        unsigned frameDelta    = frameIndex - frameTiming.FrameIndex;
        double   thisFrameTime = frameTiming.NextFrameTime +
                                 double(frameDelta-1) * frameTiming.Inputs.FrameDelta;
        // Don't run away too far into the future beyond rendering.
        OVR_ASSERT(frameDelta < 6);

        frameTiming.InitTimingFromInputs(frameTiming.Inputs, RenderInfo.Shutter.Type,
                                         thisFrameTime, frameIndex);
    }    
     
    return frameTiming;
}
开发者ID:imclab,项目名称:max_oculus,代码行数:25,代码来源:CAPI_FrameTimeManager.cpp


示例2: arch_dump_summary

void arch_dump_summary(struct arch_t *arch, FILE *f)
{
	Emu *emu = arch->emu;
	Timing *timing = arch->timing;

	/* If no instruction was run for this architecture, skip
	 * statistics summary. */
	if (!emu->instructions)
		return;

	/* Architecture-specific emulation statistics */
	assert(emu->DumpSummary);
	emu->DumpSummary(emu, f);

	/* Timing simulation statistics */
	if (arch->sim_kind == arch_sim_kind_detailed)
	{
		/* Architecture-specific */
		assert(timing->DumpSummary);
		timing->DumpSummary(timing, f);
	}

	/* End */
	fprintf(f, "\n");
}
开发者ID:3upperm2n,项目名称:gpuSimulators,代码行数:25,代码来源:arch.c


示例3: arch_run

void arch_run(int *num_emu_active_ptr, int *num_timing_active_ptr) {
  struct arch_t *arch;
  long long cycle;

  int run;
  int i;

  Emu *emu;
  Timing *timing;

  /* Reset active emulation and timing simulation counters */
  *num_emu_active_ptr = 0;
  *num_timing_active_ptr = 0;

  /* Run one iteration for all architectures */
  for (i = 0; i < arch_list_count; i++) {
    /* Get architecture */
    arch = arch_list[i];
    if (arch->sim_kind == arch_sim_kind_functional) {
      /* Emulation iteration */
      emu = arch->emu;
      assert(emu && emu->Run);
      arch->active = emu->Run(emu);

      /* Increase number of active emulations if the architecture
       * actually performed a useful emulation iteration. */
      *num_emu_active_ptr += arch->active;
    } else {
      /* Check whether the architecture should actually run an
       * iteration. If it is working at a slower frequency than
       * the main simulation loop, we must skip this call. */
      timing = arch->timing;
      assert(timing);
      assert(timing->frequency_domain);
      cycle = esim_domain_cycle(timing->frequency_domain);
      run = cycle != arch->last_timing_cycle;

      /* Timing simulation iteration */
      if (run) {
        /* Do it... */
        arch->active = timing->Run(timing);

        /* ... but only update the last timing
         * simulation cycle if there was an effective
         * execution of the iteration loop. Otherwise,
         * there is a deadlock: 'esim_time' will not
         * advance (no call to 'esim_process_events')
         * because no architecture ran, and no
         * architecture will run because 'esim_time'
         * did not advance. */
        if (arch->active) arch->last_timing_cycle = cycle;
      }

      /* Increase number of active timing simulations if the
       * architecture actually performance a useful iteration. */
      *num_timing_active_ptr += arch->active;
    }
  }
}
开发者ID:xianggong,项目名称:multi2sim42,代码行数:59,代码来源:arch.c


示例4: WriteDataBin

// TODO: we might want to use multiple buffers at the same time
void Measurement::WriteDataBin(FILE *f, int channel)
{
	Timing t;
	long size_written;
	int i, j;

	const unsigned int length_datachunk = 1000000;
	char data_8bit[1000000];
	// std::vector<char>data_8bit(1000);

	std::cerr << "Write binary data for channel " << (char)('A'+channel) << " ... ";
	t.Start();
	// TODO: test if file exists
	if(channel < 0 || channel >= GetNumberOfChannels()) {
		throw "You can only write data for channels 0 - (N-1).";
	} else {
		if(GetChannel(channel)->IsEnabled()) {

			/*
			size_written = fwrite(data[channel], sizeof(short), GetLengthFetched(), f);
			// make sure the data is written
			fflush(f);
			if(size_written < GetLengthFetched()) {
				FILE_LOG(logERROR) << "Measurement::WriteDataBin didn't manage to write to file.";
			}*/
			// TODO: if only 8 bits
			int length_fetched   = GetLengthFetched();
			// int length_datachunk = data_8bit.size();
			for(i=0; i<length_fetched; i+=length_datachunk) {
				if(GetSeries() == PICO_6000) {
					for(j=0; j<length_datachunk && i+j<length_fetched; j++) {
						data_8bit[j] = data[channel][i+j] >> 8;
					}
					size_written = fwrite(data_8bit, sizeof(char), j, f);
				} else {
					// TODO: test!!!
					size_written = fwrite(data[channel]+1, sizeof(data[0][0]), j, f);
				}
				fflush(f);
				if(size_written < j) {
					FILE_LOG(logERROR) << "Measurement::WriteDataBin didn't manage to write to file.";
				}
			}
			// size_written = fwrite(data[channel], sizeof(short), GetLengthFetched(), f);
			// make sure the data is written
			// fflush(f);
			// if(size_written < GetLengthFetched()) {
			// 	FILE_LOG(logERROR) << "Measurement::WriteDataBin didn't manage to write to file.";
			// }
		} else {
开发者ID:enascimento,项目名称:picoscope,代码行数:51,代码来源:measurement.cpp


示例5: setStartDelay

Timing TimingInput::convert(const Dictionary& timingInputDictionary)
{
    Timing result;

    // FIXME: This method needs to be refactored to handle invalid
    // null, NaN, Infinity values better.
    // See: http://www.w3.org/TR/WebIDL/#es-double
    double startDelay = Timing::defaults().startDelay;
    timingInputDictionary.get("delay", startDelay);
    setStartDelay(result, startDelay);

    double endDelay = Timing::defaults().endDelay;
    timingInputDictionary.get("endDelay", endDelay);
    setEndDelay(result, endDelay);

    String fillMode;
    timingInputDictionary.get("fill", fillMode);
    setFillMode(result, fillMode);

    double iterationStart = Timing::defaults().iterationStart;
    timingInputDictionary.get("iterationStart", iterationStart);
    setIterationStart(result, iterationStart);

    double iterationCount = Timing::defaults().iterationCount;
    timingInputDictionary.get("iterations", iterationCount);
    setIterationCount(result, iterationCount);

    double iterationDuration = 0;
    if (timingInputDictionary.get("duration", iterationDuration)) {
        setIterationDuration(result, iterationDuration);
    }

    double playbackRate = Timing::defaults().playbackRate;
    timingInputDictionary.get("playbackRate", playbackRate);
    setPlaybackRate(result, playbackRate);

    String direction;
    timingInputDictionary.get("direction", direction);
    setPlaybackDirection(result, direction);

    String timingFunctionString;
    timingInputDictionary.get("easing", timingFunctionString);
    setTimingFunction(result, timingFunctionString);

    result.assertValid();

    return result;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:48,代码来源:TimingInput.cpp


示例6: convertTimingForCompositor

bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing, double timeOffset, CompositorTiming& out, double playerPlaybackRate)
{
    timing.assertValid();

    // FIXME: Compositor does not know anything about endDelay.
    if (timing.endDelay != 0)
        return false;

    if (std::isnan(timing.iterationDuration) || !timing.iterationCount || !timing.iterationDuration)
        return false;

    if (!std::isfinite(timing.iterationCount)) {
        out.adjustedIterationCount = -1;
    } else {
        out.adjustedIterationCount = timing.iterationCount;
    }

    out.scaledDuration = timing.iterationDuration;
    out.direction = timing.direction;
    // Compositor's time offset is positive for seeking into the animation.
    out.scaledTimeOffset = -timing.startDelay / playerPlaybackRate + timeOffset;
    out.playbackRate = timing.playbackRate * playerPlaybackRate;
    out.fillMode = timing.fillMode == Timing::FillModeAuto ? Timing::FillModeNone : timing.fillMode;
    out.iterationStart = timing.iterationStart;
    out.assertValid();
    return true;
}
开发者ID:kingysu,项目名称:blink-crosswalk,代码行数:27,代码来源:CompositorAnimations.cpp


示例7: arch_dump

void arch_dump(struct arch_t *arch, FILE *f)
{
	double time_in_sec;
	int i;

	Emu *emu;
	Timing *timing;

	/* Get objects */
	emu = arch->emu;
	timing = arch->timing;

	/* Nothing to print if architecture was not active */
	if (!emu->instructions)
		return;

	/* Header */
	for (i = 0; i < 80; i++)
		fprintf(f, "=");
	fprintf(f, "\nArchitecture '%s'\n", arch->name);
	for (i = 0; i < 80; i++)
		fprintf(f, "=");
	fprintf(f, "\n\n");

	/* Emulator */
	time_in_sec = (double) m2s_timer_get_value(emu->timer) / 1.0e6;
	fprintf(f, "SimKind = %s\n", str_map_value(&arch_sim_kind_map, arch->sim_kind));
	fprintf(f, "Time = %.2f\n", time_in_sec);
	fprintf(f, "Instructions = %lld\n", emu->instructions);
	fprintf(f, "\n");
	assert(emu->DumpSummary);
	emu->DumpSummary(emu, f);

	/* Continue with timing simulator only it active */
	if (arch->sim_kind == arch_sim_kind_functional)
		return;

	/* Timing simulator */
	fprintf(f, "Cycles = %lld\n", timing->cycle);
	fprintf(f, "\n");
	assert(timing->DumpSummary);
	timing->DumpSummary(timing, f);
}
开发者ID:3upperm2n,项目名称:gpuSimulators,代码行数:43,代码来源:arch.c


示例8: setInputMatrixToAlgebraDefault

void setInputMatrixToAlgebraDefault(float_tt* dst, size_t numVal) {
    Timing timer;
    memset(dst, 0, sizeof(float_tt) * numVal); // empty cells are implicit zeros for sparse matrices

    enum dummy {DBG_DENSE_ALGEBRA_WITH_NAN_FILL=0};  // won't be correct if empty cells present
    if(DBG_DENSE_ALGEBRA_WITH_NAN_FILL) {
        valsSet(dst, ::nan(""), numVal); // any non-signalling nan will do
        LOG4CXX_WARN(SCALAPACKPHYSICAL_HPP_logger, "@@@@@@@@@@@@@ WARNING: prefill matrix memory with NaN for debug");
    }
    LOG4CXX_DEBUG(SCALAPACKPHYSICAL_HPP_logger, "setInputMatrixToAlgebraDefault took " << timer.stop());
}
开发者ID:Goon83,项目名称:scidb,代码行数:11,代码来源:ScaLAPACKPhysical.hpp


示例9: SolveTheBGIP

void
SolveTheBGIP(BGIP_sharedPtr bgip)
{
    // Specify the solution method.
    // (See above and in BGIP_SolverType.h)
    BGIP_SolverType::BGIP_Solver_t method = BGIP_SolverType::AM;
    try {
        Timing timer;
        timer.Start( SoftPrint(method) );
        BayesianGameIdenticalPayoffSolver * bgip_solver = NewBGIPSolver(bgip, method);
        cout << "running " <<  SoftPrint(method) << "..."<<endl;
        cout << "...value is " << bgip_solver->Solve() << endl;
        timer.Stop(  SoftPrint(method) );
        delete bgip_solver;
    }
    catch(E& e)
    {
        e.Print();
    }
}
开发者ID:heckj,项目名称:MADP,代码行数:20,代码来源:example_RandomBGs.cpp


示例10: ASSERT

bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing, CompositorTiming& out)
{
    timing.assertValid();

    // All fill modes are supported (the calling code handles them).

    // FIXME: Support non-zero iteration start.
    if (timing.iterationStart)
        return false;

    // FIXME: Compositor only supports positive, integer iteration counts.
    // Zero iterations could be converted, but silly.
    if ((std::floor(timing.iterationCount) != timing.iterationCount) || timing.iterationCount <= 0)
        return false;

    if (std::isnan(timing.iterationDuration) || !timing.iterationDuration)
        return false;

    // FIXME: Support other playback rates
    if (timing.playbackRate != 1)
        return false;

    // All directions are supported.

    // Now attempt an actual conversion
    out.scaledDuration = timing.iterationDuration;
    ASSERT(out.scaledDuration > 0);

    double scaledStartDelay = timing.startDelay;
    if (scaledStartDelay > 0 && scaledStartDelay > out.scaledDuration * timing.iterationCount)
        return false;

    out.reverse = (timing.direction == Timing::PlaybackDirectionReverse
        || timing.direction == Timing::PlaybackDirectionAlternateReverse);
    out.alternate = (timing.direction == Timing::PlaybackDirectionAlternate
        || timing.direction == Timing::PlaybackDirectionAlternateReverse);

    if (!std::isfinite(timing.iterationCount)) {
        out.adjustedIterationCount = -1;
    } else {
        out.adjustedIterationCount = std::floor(timing.iterationCount);
        ASSERT(out.adjustedIterationCount > 0);
    }

    // Compositor's time offset is positive for seeking into the animation.
    out.scaledTimeOffset = -scaledStartDelay;
    return true;
}
开发者ID:wangshijun,项目名称:Blink,代码行数:48,代码来源:CompositorAnimations.cpp


示例11: main

int main(){
    Timing timer;
#ifdef _DEBUG
    int size = 4;{
#else
    for(int size=1; size>0; size*=2){
#endif
    
        std::cout << "size: " << size << '\n';
        const int times = 10;
        Matrix a, b;
        a.resize(size);
        b.resize(size);
        a.randomize();
        b.randomize();

    
        timer.setDivisor(times);
    
   

        timer.start();
        for(int i=0; i<times; i++){
            Matrix c = MatrixMultiplication::recursive(a, b);
#ifdef _DEBUG
            c.print();
#endif
        }
        timer.end();
        timer.reportCPUtime();


        timer.start();
        for(int i=0; i<times; i++){
            Matrix c = MatrixMultiplication::strassen(a, b);
#ifdef _DEBUG
            c.print();
#endif
        }
        timer.end();
        timer.reportCPUtime();
    }

    return system("pause");
}
开发者ID:lizy14,项目名称:algorithm-assignments,代码行数:45,代码来源:Source.cpp


示例12: main

int main()
{
	/******************************* [ signal ] ******************************/
	Type a = 0;
	Type b = Ls-1;
	Vector<Type> t = linspace(a,b,Ls) / Type(Fs);
	Vector<Type> s = sin( Type(400*PI) * pow(t,Type(2.0)) );

	/******************************** [ widow ] ******************************/
	a = 0;
	b = Type(Lg-1);
	Type u = (Lg-1)/Type(2);
	Type r = Lg/Type(8);
	t = linspace(a,b,Lg);
	Vector<Type> g = gauss(t,u,r);
	g = g/norm(g);

	/********************************* [ WFT ] *******************************/
	Type runtime = 0;
	Timing cnt;
	cout << "Taking windowed Fourier transform." << endl;
	cnt.start();
    Matrix< complex<Type> > coefs = wft( s, g );
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	/******************************** [ IWFT ] *******************************/
	cout << "Taking inverse windowed Fourier transform." << endl;
	cnt.start();
	Vector<Type> x = iwft( coefs, g );
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	cout << "The relative error is : " << "norm(s-x) / norm(s) = "
		 << norm(s-x)/norm(s) << endl << endl;

	return 0;
}
开发者ID:Holdlen2DH,项目名称:tspl,代码行数:40,代码来源:wft_test.cpp


示例13: setOutputMatrixToAlgebraDefault

void setOutputMatrixToAlgebraDefault(float_tt* dst, size_t numVal, log4cxx::LoggerPtr logger) {
    Timing timer;
    valsSet(dst, ::nan(""), numVal); // ScaLAPACK algorithm should provide all entries in matrix
    LOG4CXX_DEBUG(SCALAPACKPHYSICAL_HPP_logger, "setOutputMatrixToAlgebraDefault took " << timer.stop());
}
开发者ID:Goon83,项目名称:scidb,代码行数:5,代码来源:ScaLAPACKPhysical.hpp


示例14: main

int main(int argc, char** argv)
{
	Timing t;
	int i;

	// TODO: debug should be enabled with a command-line option
	// FILELog::ReportingLevel() = FILELog::FromString("DEBUG4");
	// FILELog::ReportingLevel() = FILELog::FromString("DEBUG1");
	FILELog::ReportingLevel() = FILELog::FromString("INFO");
	FILE_LOG(logDEBUG4) << "starting";

	t.Start();
	try {

		Picoscope6000 *pico = new Picoscope6000();
		Measurement   *meas = new Measurement(pico);
		Channel       *ch[4];

		meas->SetTimebaseInPs(400);
		meas->EnableChannels(true,false,false,false);
		for(i=0; i<PICOSCOPE_N_CHANNELS; i++) {
			ch[i] = meas->GetChannel(i);
			FILE_LOG(logDEBUG4) << "main - Channel " << (char)('A'+i) << " has index " << ch[i]->GetIndex();
		}

		Args x;
		x.parse_options(argc, argv, meas);
		if(x.IsJustHelp()) {
			return 0;
		}

		if(x.GetFilename() == NULL) { // TODO: maybe we want to use just text file
			throw("You have to provide some filename using '--name <filename>'.\n");
		}

		// meas->SetTimebaseInPs(10000);

		// TODO: fixme
		for(i=0; i<PICOSCOPE_N_CHANNELS; i++) {
			ch[i]->SetVoltage(x.GetVoltage());
		}

		// a->SetVoltage(U_100mV);
		// a[0]->SetVoltage(x.GetVoltage());
		// meas->SetLength(GIGA(1));
		meas->SetLength(x.GetLength());

		if(x.GetNTraces() > 1) {
			meas->SetNTraces(x.GetNTraces());
			// TODO: fix trigger
			FILE_LOG(logDEBUG4) << "main - checking for triggered events";
			if(x.IsTriggered()) {
				for(i=0; i<PICOSCOPE_N_CHANNELS && !(ch[i]->IsEnabled()); i++);
				FILE_LOG(logDEBUG4) << "main - will trigger on channel " << (char)('A'+i);
				meas->SetTrigger(x.GetTrigger(ch[i]));
			}
			meas->AllocateMemoryRapidBlock(MEGA(50));
		} else {
			meas->AllocateMemoryBlock(MEGA(50));
		}

		// std::cerr << "test w5\n";

		// it only makes sense to measure if we decided to use some positive number of samples
		if(x.GetLength()>0) {

			FILE *f = NULL;
			FILE *fb[4] = {NULL,NULL,NULL,NULL}, *ft[4] = {NULL,NULL,NULL,NULL};

			struct tm *current;
			time_t now;
			time(&now);
			current = localtime(&now);

			for(i=0; i<PICOSCOPE_N_CHANNELS; i++) {
				if(ch[i]->IsEnabled()) {
					if(x.IsTextOutput()) {
						ft[i] = fopen(x.GetFilenameText(i), "wt");
						if(ft[i] == NULL) {
							throw("Unable to open text file.\n"); // TODO: write filename
						}
					}
					if(x.IsBinaryOutput()) {
						fb[i] = fopen(x.GetFilenameBinary(i), "wb");
						if(fb[i] == NULL) {
							throw("Unable to open binary file.\n"); // TODO: write filename
						}
					}
				}
			}

			/************************************************************/
			double tmp_dbl;
			short  tmp_short;
			pico->Open();
			meas->InitializeSignalGenerator();
			meas->RunBlock();

			/* metadata */
			f = fopen(x.GetFilenameMeta(), "wt");
//.........这里部分代码省略.........
开发者ID:enascimento,项目名称:picoscope,代码行数:101,代码来源:run_picoscope.cpp


示例15: main

int main(int argc, char **argv)
{
    DecPOMDPDiscreteInterface* decpomdp;
    try {
        ArgumentHandlers::Arguments args;
        argp_parse (&ArgumentHandlers::theArgpStruc, argc, argv, 0, 0, &args);

        Timing times;
        times.Start("Parsing");
        //DecPOMDPDiscreteInterface* 
        decpomdp = GetDecPOMDPDiscreteInterfaceFromArgs(args);
        TransitionObservationIndependentMADPDiscrete *toi=0;
        if((toi=dynamic_cast<TransitionObservationIndependentMADPDiscrete*>(decpomdp)) &&
           args.qheur==eQMDP &&
           !args.cache_flat_models /* otherwise
                                    * GetDecPOMDPDiscreteInterfaceFromArgs
                                    * already caches the flat
                                    * models */)
        {
            // we don't need a centralized obs model
            toi->CreateCentralizedSparseTransitionModel();
        }

        times.Stop("Parsing");

        if(!args.dryrun)
            directories::MADPCreateResultsDir("GMAA",*decpomdp);
        
        size_t horizon;
        if(args.infiniteHorizon)
            horizon=MAXHORIZON;
        else
            horizon=args.horizon;

        times.Start("Overall");

        PlanningUnitMADPDiscreteParameters params;
#if 0 // Caching doesn't seem worth the trouble if we're computing
      // just one thing (not to mention the memory savings)
        if(Qheur==eQMDP) // don't need any of this for solving the MDP
            params.SetComputeAll(false);
        else
        {
            params.SetComputeAll(true);
            params.SetUseSparseJointBeliefs(true);
        }
#else
        params.SetComputeAll(false);
        if(args.sparse)
            params.SetUseSparseJointBeliefs(true);
#endif

        times.Start("PlanningUnit");
        NullPlanner np(params,horizon,decpomdp);
        times.Stop("PlanningUnit");

        struct timeval tvStart, tvEnd;
        gettimeofday (&tvStart, NULL);

        QFunctionJAOHInterface* q=0;
        for(int restartI = 0; restartI < args.nrRestarts; restartI++)
        {
            // with hybrid heuristics already some computation is done
            // before Compute(), so start timing now
            times.Start("ComputeQ");
            q = GetQheuristicFromArgs(&np, args);
            q->Compute();
            times.Stop("ComputeQ");

            // we want to keep the last q computed
            if(restartI<(args.nrRestarts-1))
                delete q;
        }

        gettimeofday (&tvEnd, NULL);

        clock_t wallclockTime = 
            static_cast<clock_t>(((tvEnd.tv_sec - tvStart.tv_sec) +
                                  static_cast<double>(tvEnd.tv_usec-tvStart.tv_usec)/1e6) * sysconf(_SC_CLK_TCK));

        cout << "Wallclock: from "
             << tvStart.tv_sec << "." << tvStart.tv_usec
             << " until "
             << tvEnd.tv_sec << "." << tvEnd.tv_usec
             << " which took " << wallclockTime << " clock ticks"
             << endl;
        
        times.AddEvent("WallclockTime", wallclockTime);

        if(!args.dryrun)
        {
            times.Start("Save");
            q->Save();
            times.Stop("Save");
            if(args.verbose >= 0)
                cout << "Q saved to " << q->GetCacheFilename() << endl;
        }
        times.Stop("Overall");

        if(args.verbose >= 0)
//.........这里部分代码省略.........
开发者ID:heckj,项目名称:MADP,代码行数:101,代码来源:calculateQheuristic.cpp


示例16: main

int main()
{

	/******************************* [ signal ] ******************************/
	Vector<double> t = linspace( 0.0, (Ls-1)/fs, Ls );
	Vector<double> st = sin( 200*PI*pow(t,2.0) );
	st = st-mean(st);

	/******************************** [ CWT ] ********************************/
	Matrix< complex<double> > coefs;
	CWT<double> wavelet("morlet");
	wavelet.setScales( fs, fs/Ls, fs/2 );
	Timing cnt;
	double runtime = 0.0;
	cout << "Taking continuous wavelet transform(Morlet)." << endl;
	cnt.start();
	coefs = wavelet.cwtC(st);
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	/******************************** [ ICWT ] *******************************/
	cout << "Taking inverse continuous wavelet transform." << endl;
	cnt.start();
	Vector<double> xt = wavelet.icwtC(coefs);
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	cout << "The relative error is : " << endl;
	cout << "norm(st-xt) / norm(st) = " << norm(st-xt)/norm(st) << endl;
	cout << endl << endl;


    /******************************* [ signal ] ******************************/
    Vector<float> tf = linspace( float(0.0), (Ls-1)/float(fs), Ls );
	Vector<float> stf = sin( float(200*PI) * pow(tf,float(2.0) ) );
	stf = stf-mean(stf);

	/******************************** [ CWT ] ********************************/
	CWT<float> waveletf("mexiHat");
	waveletf.setScales( float(fs), float(fs/Ls), float(fs/2), float(0.25) );
	runtime = 0.0;
	cout << "Taking continuous wavelet transform(Mexican Hat)." << endl;
	cnt.start();
	Matrix<float> coefsf = waveletf.cwtR(stf);
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	/******************************** [ ICWT ] *******************************/
	cout << "Taking inverse continuous wavelet transform." << endl;
	cnt.start();
	Vector<float> xtf = waveletf.icwtR(coefsf);
	cnt.stop();
	runtime = cnt.read();
	cout << "The running time = " << runtime << " (ms)" << endl << endl;

	cout << "The relative error is : " << endl;
	cout << "norm(st-xt) / norm(st) = " << norm(stf-xtf)/norm(stf) << endl << endl;

	return 0;
}
开发者ID:Holdlen2DH,项目名称:tspl,代码行数:63,代码来源:cwt_test.cpp


示例17: printClassMethodMsg

//Opens a text file set by the user and loads the requested parameters
void ParameterLoaderAnaysis::loadAnalysisParameters(string & strInputSetupFile, AnalysisSetupUniformity &aSetupUniformity){
    //Variable Declaration
    bool bExitSuccess = false;
    
    pair<string,string> pair_strParam; //Input file is setup in <Field, Value> pairs; not used here yet but placeholder
    
    string strLine = "";    //Line taken from the input file
    //string strHeading = ""; //For storing detector heading
    
    vector<string> vec_strList; //For storing char separated input; not used here yet but placeholder
    
    //Open the Data File
    //------------------------------------------------------
    if (bVerboseMode_IO) { //Case: User Requested Verbose Error Messages - I/O
        printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParameters", ("trying to open and read: " + strInputSetupFile).c_str() );
    } //End Case: User Requested Verbose Error Messages - I/O
    
    ifstream fStream( strInputSetupFile.c_str() );
    
    //Check to See if Data File Opened Successfully
    //------------------------------------------------------
    if (!fStream.is_open() && bVerboseMode_IO) {
        perror( ("Uniformity::ParameterLoaderAnaysis::loadAnalysisParameters(): error while opening file: " + strInputSetupFile).c_str() );
        printStreamStatus(fStream);
    }
    
    ////Loop Over data Input File
    //------------------------------------------------------
    //Read the file via std::getline().  Obey good coding practice rules:
    //  -first the I/O operation, then error check, then data processing
    //  -failbit and badbit prevent data processing, eofbit does not
    //See: http://gehrcke.de/2011/06/reading-files-in-c-using-ifstream-dealing-correctly-with-badbit-failbit-eofbit-and-perror/
    while ( getlineNoSpaces(fStream, strLine) ) {
        //Reset exit flag used in string manipulation
        bExitSuccess = false;
        
        //Does the user want to comment out this line?
        if ( 0 == strLine.compare(0,1,"#") ) continue;
        
        //Debugging
        cout<<"strLine = " << strLine.c_str() << endl;
        
        //Identify Section Headers
        if ( 0 == strLine.compare(strSecEnd_Analysis) ) { //Case: Reached End of File
            
            //Debugging
            cout<<"Found End of Analysis Section"<<endl;
            
            break;
        } //End Case: Reached End of File
        else if ( 0 == strLine.compare(strSecBegin_Analysis) ) { //Case: Analysis Header
            
            //Filler for now; intentionally empty
            
        } //End Case: Analysis Header
        else if ( 0 == strLine.compare(strSecBegin_Timing) ) { //Case: Timing Parameters
            //Debugging
            cout<<"Found Start of Timing Section"<<endl;
            
            loadAnalysisParametersTiming(fStream, aSetupUniformity);
        } //End Case: Timing Parameters
        else if ( 0 == strLine.compare(strSecBegin_Uniformity) ) { //Case: Uniformity Parameters
            //Debugging
            cout<<"Found Start of Uniformity Section"<<endl;
            
            loadAnalysisParametersUniformity(fStream, aSetupUniformity);
        } //End Case: Uniformity Parameters
        else { //Case: Unsorted Parameters
            
            //Filler for now; intentionally empty but may return to it later
            
        } //End Case: Unsorted Parameters
    } //End Loop Over Input File
    
    //Check to see if we had problems while reading the file
    if (fStream.bad() && bVerboseMode_IO) {
        perror( ("Uniformity::ParameterLoaderAnaysis::loadAnalysisParameters(): error while reading file: " + strInputSetupFile).c_str() );
        printStreamStatus(fStream);
    }
    
    return;
} //End ParameterLoaderAnaysis::loadAnalysisParameters()
开发者ID:jhallan,项目名称:CMS_GEM_Analysis_Framework,代码行数:83,代码来源:ParameterLoaderAnaysis.cpp


示例18: main

int main(int argc, char* argv[])
{
  char* myString;
  int* suffixArray;
  int stringLength;
  int i;
  ifstream inFile;
  inFile.open(argv[1]);
  Timing timehere;

  if (strcmp(argv[1], "test.dat") != 0) 
  {
    timehere.markbeg();
    if (strstr(argv[1], ".fas")[0] == '.')
    {
      read_fasta(inFile, myString, stringLength);
    }
    else
    {
      read_input(inFile, myString, stringLength);
    }
    timehere.markend();
    inFile.close();
    cout << "finish read "
	 << stringLength << " characters."<< endl;
    timehere.outtime();
  }
  else
  {
    read_input(inFile, myString, stringLength);
    inFile.close();
    cout << "finish read " 
	 << stringLength << " characters."<< endl;
  }

  timehere.markbeg();
  suffixArray = LinearSuffixSort(myString, stringLength);
  timehere.markend();
  timehere.outtime("finish suffix sort,");

  if (strcmp(argv[1], "test.dat") == 0) 
  {
    int result;
    bool pass = true;
    ifstream resultF;
    resultF.open("result.test.dat");

    cout << "Testing the Suffix Array" << endl;

    for (i = 0; i < stringLength; i++)
    {
      resultF >> result;
      if (result != suffixArray[i])
      {
	pass = false;
      }
    }
    if (pass == false)
    {
      cout << endl;
      cout << "***************" << endl;
      cout << "test has failed" << endl;
      cout << "***************" << endl;
    }
    else
    {
      cout << endl;
      cout << "******************" << endl;
      cout << "test is successful" << endl;
      cout << "******************" << endl;
    }
  }
开发者ID:kopang,项目名称:LinearSuffixArray,代码行数:72,代码来源:test.C


示例19: while

void ParameterLoaderAnaysis::loadAnalysisParametersHistograms(ifstream &inputFileStream, HistoSetup &hSetup){
    //Variable Declaration
    bool bExitSuccess;
    
    pair<string,string> pair_strParam;
    
    string strLine;
    
    vector<string> vec_strList;
    
    //Loop through the section
    while ( getlineNoSpaces(inputFileStream, strLine) ) {
        bExitSuccess = false;
        
	//Debugging
	//cout<<"loadAnalysisParametersHistograms (Base Level); strLine = " << strLine << endl;

        //Does the user want to comment out this line?
        if ( 0 == strLine.compare(0,1,"#") ) continue;
        
        //Has this section ended?
        if ( 0 == strLine.compare(strSecEnd_Uniformity_Hiso) ) break;
        
        //Get Parameter Pairing
        pair_strParam = Timing::getParsedLine(strLine, bExitSuccess);
        
        //transform field name to upper case
        transform(pair_strParam.first.begin(),pair_strParam.first.end(),pair_strParam.first.begin(),toupper);
        
        //Parse pair
        if (bExitSuccess) { //Case: Parameter Fetched Successfully
            if( 0 == pair_strParam.first.compare("HISTO_BINRANGE") ){
                //Get comma separated list
                vec_strList = Timing::getCharSeparatedList(pair_strParam.second,',');
                
                //Debugging
                //for(int i=0; i<vec_strList.size(); ++i){
                //	cout<<"vec_strList["<<i<<"] = " << vec_strList[i] << endl;
                //}
                
                if (vec_strList.size() >= 2) { //Case: at least 2 numbers
                    //Fetch
                    hSetup.fHisto_xLower = Timing::stofSafe(pair_strParam.first, vec_strList[0]);
                    hSetup.fHisto_xUpper = Timing::stofSafe(pair_strParam.first, vec_strList[1]);
                    
                    //Reset to ensure they are both correctly lower & upper values
                    hSetup.fHisto_xLower = std::min(hSetup.fHisto_xLower, hSetup.fHisto_xUpper);
                    hSetup.fHisto_xUpper = std::max(hSetup.fHisto_xLower, hSetup.fHisto_xUpper);
                    
                    //Tell the user they entered more than what was expected
                    if (vec_strList.size() > 2) { //Case: 3 or more numbers
                        printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ( "Sorry you entered 3 or more numbers for " + pair_strParam.first + "\n" ).c_str() );
                        printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", "\tI have only used the first two and ignored the rest:\n" );
                        printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ("\t" + getString( hSetup.fHisto_xLower ) ).c_str() );
                        printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ("\t" + getString( hSetup.fHisto_xUpper ) ).c_str() );
                    } //End Case: 3 or more numbers
                } //End Case: at least 2 numbers
                else{ //Case: Not enough numbers
                    if (vec_strList.size() == 1) { //Case: only 1 number entered
                        hSetup.fHisto_xUpper = Timing::stofSafe(pair_strParam.first, vec_strList[0]);
                    } //End Case: only 1 number entered
                    
                    //Reset to ensure they are both correctly lower & upper values
                    hSetup.fHisto_xLower = std::min(hSetup.fHisto_xLower, hSetup.fHisto_xUpper);
                    hSetup.fHisto_xUpper = std::max(hSetup.fHisto_xLower, hSetup.fHisto_xUpper);
                    
                    //Output to User
                    printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ( "Sorry I was expecting a comma separated list of 2 numbers for: " + pair_strParam.first + "\n" ).c_str() );
                    printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", "\tRight now I have set:\n" );
                    printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ("\t" + getString( hSetup.fHisto_xLower ) ).c_str() );
                    printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms", ("\t" + getString( hSetup.fHisto_xUpper ) ).c_str() );
                } //End Case: Not enough numbers
            } //End Case: Assign Histo Bin Range
            /*else if( 0 == pair_strParam.first.compare("HISTO_NAME") ) {
                hSetup.strHisto_Name = pair_strParam.second;
            }*/
            else if( 0 == pair_strParam.first.compare("HISTO_NUMBINS") ){
                hSetup.iHisto_nBins = Timing::stoiSafe(pair_strParam.first, pair_strParam.second);
            }
            else if( 0 == pair_strParam.first.compare("HISTO_XTITLE") ){
                hSetup.strHisto_Title_X = pair_strParam.second;
            }
            else if( 0 == pair_strParam.first.compare("HISTO_YTITLE") ){
                hSetup.strHisto_Title_Y = pair_strParam.second;
            }
            else if( 0 == pair_strParam.first.compare("PERFORM_FIT") ){
                hSetup.bFit = convert2bool(pair_strParam.second, bExitSuccess);
            }
            else{ //Case: Parameter not recognized
                printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms","Error!!! Parameter Not Recognized:\n");
                printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms",( "\tField = " + pair_strParam.first + "\n" ).c_str() );
                printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms",( "\tValue = " + pair_strParam.second + "\n" ).c_str() );

            } //End Case: Parameter not recognized
        } //End Case: Parameter Fetched Successfully
        else{ //Case: Parameter was NOT fetched Successfully
            printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms","Error!!!  I didn't parse parameter correctly\n");
            printClassMethodMsg("ParameterLoaderAnaysis","loadAnalysisParametersHistograms",("\tCurrent line: " + strLine).c_str() );
        } //End Case: Parameter was NOT fetched Successfully
    } //End Loop through Section
//.........这里部分代码省略.........
开发者ID:jhallan,项目名称:CMS_GEM_Analysis_Framework,代码行数:101,代码来源:ParameterLoaderAnaysis.cpp


示例20: loadAnalysisParametersHistograms

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TimingData类代码示例发布时间:2022-05-31
下一篇:
C++ Timeval类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap