コード例 #1
0
ファイル: main.c プロジェクト: AJcravea/mapbox-gl-native
int main(void)
{
  printf("Hello from main.c\n");
  prog1();
  prog2();
  return 0;
}
コード例 #2
0
int main()
{
	cout << "Hello World ! - Welcome to chapter 15  Introduction to operator overloading " << endl << endl ;
	//prog1 ();
	prog2 ();
	//prog3 ();
	prog4 ();
	prog5 ();
	prog6 ();
	prog7 ();
	prog8 ();
	prog9 ();
	prog10();
	prog11();
	prog12();
	prog13();
	prog14();
	prog15();
	prog16();
	prog17();
	prog18();
	prog19();
	prog20();
	prog21();
	prog22();
	prog23();
	prog24();
	prog25();

	cout << "\n\n\n ";
}
コード例 #3
0
ファイル: main.c プロジェクト: Toad2186/eecs149
/*
 * main.c
 */
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
    // Use 1 MHz DCO factory calibration
    DCOCTL = 0;
    BCSCTL1 = CALBC1_1MHZ;
    DCOCTL = CALDCO_1MHZ;
    P1DIR = 0xFF;					// Set P1.0 to output direction

    setupTriggerPulse();
    setupGpioEchoInterrupt();

    while(1) {
        switch(j % NUM_PROG) {
        case 0:
            prog1();
            break;
        case 1:
            prog2();
            break;
        case 2:
            prog3();
            break;
        case 3:
            prog4();
            break;
        }
    }

}
コード例 #4
0
int main()
{
    cout << "Hello World ! - Welcome to chapter 14 " << endl << endl;
    prog1 ();
    prog2 ();
    prog3 ();
    prog4 ();
    prog5 ();
    prog6 ();
    prog7 ();
    prog8 ();
    prog9 ();
    prog10();
    prog11();

    cout << "\n\n\n ";
}
コード例 #5
0
ファイル: test.cpp プロジェクト: BackupTheBerlios/damaris-svn
int simple_sequence() {
  try {
    SpinCorePulseBlaster24Bit sp24;
    PulseBlaster24BitProgram prog(sp24);
    // zero
    prog.push_back(prog.create_command());
    prog.back()->ttls=1;
    prog.back()->instruction=SpinCorePulseBlaster::LOOP;
    prog.back()->loop_count=10;
    prog.back()->length=20;
    // one
    prog.push_back(prog.create_command());
    prog.back()->ttls=0;
    prog.back()->instruction=SpinCorePulseBlaster::END_LOOP;
    prog.back()->jump=prog.begin();
    prog.back()->length=10;
    // two
    prog.push_back(prog.create_command());
    prog.back()->ttls=0;
    prog.back()->instruction=SpinCorePulseBlaster::STOP;
    sp24.run_pulse_program(prog);

    PulseBlaster24BitProgram prog2(prog);
    prog.write_to_file(stdout);
    sp24.run_pulse_program(prog2);
  }
  catch(SpinCorePulseBlaster_error e) {
    fprintf(stderr, "pulseblaster: %s\n", e.c_str());
    return 1;
  }
  catch(pulse_exception e) {
    fprintf(stderr, "pulse: %s\n", e.c_str());
    return 1;
  }
  return 0;
}
コード例 #6
0
/** Calculate a workspace that contains the result of the fit to the
* transmission fraction that was calculated
*  @param raw [in] the workspace with the unfitted transmission ratio data
*  @param rebinParams [in] the parameters for rebinning
*  @param fitMethod [in] string can be Log, Linear, Poly2, Poly3, Poly4, Poly5,
* Poly6
*  @return a workspace that contains the evaluation of the fit
*  @throw runtime_error if the Linear or ExtractSpectrum algorithm fails during
* execution
*/
API::MatrixWorkspace_sptr
CalculateTransmission::fit(API::MatrixWorkspace_sptr raw,
                           std::vector<double> rebinParams,
                           const std::string fitMethod) {
  MatrixWorkspace_sptr output =
      this->extractSpectra(raw, std::vector<size_t>(1, 0));

  Progress progress(this, m_done, 1.0, 4);
  progress.report("CalculateTransmission: Performing fit");

  // these are calculated by the call to fit below
  double grad(0.0), offset(0.0);
  std::vector<double> coeficients;
  const bool logFit = (fitMethod == "Log");
  if (logFit) {
    g_log.debug("Fitting to the logarithm of the transmission");

    MantidVec &Y = output->dataY(0);
    MantidVec &E = output->dataE(0);
    double start = m_done;
    Progress prog2(this, start, m_done += 0.1, Y.size());
    for (size_t i = 0; i < Y.size(); ++i) {
      // Take the log of each datapoint for fitting. Recalculate errors
      // remembering that d(log(a))/da  = 1/a
      E[i] = std::abs(E[i] / Y[i]);
      Y[i] = std::log10(Y[i]);
      progress.report("Fitting to the logarithm of the transmission");
    }

    // Now fit this to a straight line
    output = fitData(output, grad, offset);
  }                                 // logFit true
  else if (fitMethod == "Linear") { // Linear fit
    g_log.debug("Fitting directly to the data (i.e. linearly)");
    output = fitData(output, grad, offset);
  } else { // fitMethod Polynomial
    int order = getProperty("PolynomialOrder");
    std::stringstream info;
    info << "Fitting the transmission to polynomial order=" << order;
    g_log.information(info.str());
    output = fitPolynomial(output, order, coeficients);
  }

  progress.report("CalculateTransmission: Performing fit");

  // if no rebin parameters were set the output workspace will have the same
  // binning as the input ones, otherwise rebin
  if (!rebinParams.empty()) {
    output = rebin(rebinParams, output);
  }
  progress.report("CalculateTransmission: Performing fit");

  // if there was rebinnning or log fitting we need to recalculate the Ys,
  // otherwise we can just use the workspace kicked out by the fitData()'s call
  // to Linear
  if ((!rebinParams.empty()) || logFit) {
    const MantidVec &X = output->readX(0);
    MantidVec &Y = output->dataY(0);
    if (logFit) {
      // Need to transform back to 'unlogged'
      const double m(std::pow(10, grad));
      const double factor(std::pow(10, offset));

      MantidVec &E = output->dataE(0);
      for (size_t i = 0; i < Y.size(); ++i) {
        // the relationship between the grad and interspt of the log fit and the
        // un-logged value of Y contain this dependence on the X (bin center
        // values)
        Y[i] = factor * (std::pow(m, 0.5 * (X[i] + X[i + 1])));
        E[i] = std::abs(E[i] * Y[i]);
        progress.report();
      }
    } // end logFit
    else if (fitMethod == "Linear") {
      // the simpler linear situation
      for (size_t i = 0; i < Y.size(); ++i) {
        Y[i] = (grad * 0.5 * (X[i] + X[i + 1])) + offset;
      }
    } else { // the polynomial fit
      for (size_t i = 0; i < Y.size(); ++i) {
        double aux = 0;
        double x_v = 0.5 * (X[i] + X[i + 1]);

        for (int j = 0; j < static_cast<int>(coeficients.size()); ++j) {
          aux += coeficients[j] * std::pow(x_v, j);
        }
        Y[i] = aux;
      }
    }
  }
  progress.report("CalculateTransmission: Performing fit");

  return output;
}