コード例 #1
0
void
LocalSharedFilesDialog::tryToAddNewAssotiation()
{
    AddFileAssociationDialog afad(true, this);//'add file assotiations' dialog

    afad.setFileType(AddFileAssociationDialog::cleanFileType(currentFile));

    int ti = afad.exec();

    if (ti==QDialog::Accepted)
    {
        QString currType = afad.resultFileType() ;
        QString currCmd = afad.resultCommand() ;

        Settings->setValueToGroup("FileAssotiations", currType, currCmd);
    }
}
コード例 #2
0
ファイル: dfad_sfc_example.cpp プロジェクト: 00liujj/trilinos
int main(int argc, char **argv)
{
  double pi = std::atan(1.0)*4.0;

  // Values of function arguments
  double a = pi/4;
  double b = 2.0;
  double c = 3.0;

  // Number of independent variables
  int num_deriv = 2;

  // Compute function
  SFC as(a);
  SFC bs(b);
  SFC cs(c);
  SFC::resetCounters();
  SFC rs = func(as, bs, cs);
  SFC::finalizeCounters();

  std::cout << "Flop counts for function evaluation:";
  SFC::printCounters(std::cout);

  // Compute derivative analytically
  SFC drdas, drdbs;
  SFC::resetCounters();
  func_deriv(as, bs, cs, drdas, drdbs);
  SFC::finalizeCounters();

  std::cout << "\nFlop counts for analytic derivative evaluation:";
  SFC::printCounters(std::cout);

  // Compute function and derivative with AD
  FAD_SFC afad(num_deriv, 0, a); 
  FAD_SFC bfad(num_deriv, 1, b); 
  FAD_SFC cfad(c);               
  SFC::resetCounters();
  FAD_SFC rfad = func(afad, bfad, cfad);
  SFC::finalizeCounters();

  std::cout << "\nFlop counts for AD function and derivative evaluation:";
  SFC::printCounters(std::cout);

  // Extract value and derivatives
  double r = rs.val();               // r
  double drda = drdas.val();         // dr/da
  double drdb = drdbs.val();         // dr/db

  double r_ad = rfad.val().val();     // r
  double drda_ad = rfad.dx(0).val();  // dr/da
  double drdb_ad = rfad.dx(1).val();  // dr/db

  // Print the results
  int p = 4;
  int w = p+7;
  std::cout.setf(std::ios::scientific);
  std::cout.precision(p);
  std::cout << "\nValues/derivatives of computation" << std::endl
	    << "    r =  " << r << " (original) == " << std::setw(w) << r_ad
	    << " (AD) Error = " << std::setw(w) << r - r_ad << std::endl
	    << "dr/da = " << std::setw(w) << drda << " (analytic) == " 
	    << std::setw(w) << drda_ad << " (AD) Error = " << std::setw(w) 
	    << drda - drda_ad << std::endl
	    << "dr/db = " << std::setw(w) << drdb << " (analytic) == " 
	    << std::setw(w) << drdb_ad << " (AD) Error = " << std::setw(w) 
	    << drdb - drdb_ad << std::endl;

  double tol = 1.0e-14;
  Sacado::FlopCounterPack::FlopCounts fc = SFC::getCounters();
  // The Solaris and Irix CC compilers get higher counts for operator=
  // than does g++, which avoids an extra copy when returning a function value.
  // The test on fc.totalFlopCount allows for this variation.
  if (std::fabs(r - r_ad)       < tol &&
      std::fabs(drda - drda_ad) < tol &&
      std::fabs(drdb - drdb_ad) < tol &&
      (fc.totalFlopCount == 40)) {
    std::cout << "\nExample passed!" << std::endl;
    return 0;
  }
  else {
    std::cout <<"\nSomething is wrong, example failed!" << std::endl;
    return 1;
  }
}