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


C++ df函数代码示例

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


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

示例1: x

void TestExprDiff::vec01() {

	Variable x(4,"x");
	Function f(x,x[0]+x[3]);
	Function df(f,Function::DIFF);
	const ExprConstant* c=dynamic_cast<const ExprConstant*>(&df.expr());
	TEST_ASSERT(c);
	TEST_ASSERT(c->dim.type()==Dim::ROW_VECTOR);
	double _grad[][2] = {{1,1},{0,0},{0,0},{1,1}};
	IntervalVector grad(4,_grad);

	TEST_ASSERT(c->get_vector_value()==grad);
}
开发者ID:nicolaje,项目名称:IBEX,代码行数:13,代码来源:TestExprDiff.cpp

示例2: vector_remove

void vector_remove(vector_t *v, size_t index, void df(void *)) {
    assert(v);
    size_t i = index;
    if (v->count <= index) {
        i = v->count - 1;
    }
    void *to_delete = v->data[i];
    if (df != NULL) {
        df(to_delete);
    }
    size_t diff = v->count - i + 1;
    memmove(v->data + i, v->data + i + 1, sizeof(void *) * diff);
    v->count--;
}
开发者ID:bendst,项目名称:cu,代码行数:14,代码来源:vector.c

示例3: main

int main(int argc, char **argv)
{
	// open the file passed in on the command-line
	assert(argc > 1);
	FILE* f = fopen(argv[1], "r");
	
	// construct a dwarf::file
	dwarf::lib::file df(fileno(f));
    
    // encapsulate the DIEs
    dwarf::encap::file def(fileno(f));
    
    std::cout << def.ds();
}
开发者ID:antmd,项目名称:libdwarfpp,代码行数:14,代码来源:dwarfppdump.cpp

示例4: main

void main()
{
    double  eps, fopt, x[3], xm[3], g[3];
    int itmax = 50, n = 3, it;
    double f();
    void df();
    eps = 1e-7;
    x[0] = x[1] = x[2] = 0.0;
    it = bfgs(x, xm, n, &fopt, f, df, eps, itmax);
    printf("iterations = %d:\nx0=%f,x1=%f,x2=%f\nfopt=%f\n", it, xm[0], xm[1],
           xm[2], fopt);
    df(xm, g, 3);
    printf("df[0]=%f, df[1]=%f, df[2]=%f\n", g[0], g[1], g[2]);
}
开发者ID:Masshat,项目名称:C_and_CPP,代码行数:14,代码来源:bfgs0.c

示例5: fileDlg

/**
 *  Initialize the applet.
 *
 *  Only called when we create a new applet. Asks the user for an URL and
 *  creates a .desktop file...
 */
bool LauncherApplet::init()
{
    //    
    // Get an url...
    //
    KFileDialog fileDlg(0, 0, 0, 0, true);
    fileDlg.exec();
    _url = fileDlg.selectedURL();
    
    if (!_url.isValid()) {
        return false;
    }
    
    //
    // Create a .desktop file
    //
    QString file = newDesktopFile(_url);
    
    if (KDesktopFile::isDesktopFile(_url.path())) {
        // Copy existing file...
        KURL dest;
        dest.setPath(file);
        KIO::NetAccess::upload(_url.path(), dest, 0);
    } else {
        // Create new file...
        KDesktopFile df(file);
        
        df.writeEntry("Encoding", "UTF-8");
        df.writeEntry("Type","Link");
        df.writeEntry("Name", _url.prettyURL());
        
        if (_url.isLocalFile()) {
            KFileItem item( KFileItem::Unknown, KFileItem::Unknown, _url );
            df.writeEntry("Icon", item.iconName() );
        } else {
            df.writeEntry("Icon", KMimeType::favIconForURL(_url));
        }
        df.writeEntry("URL", _url.url());
        df.sync();
    }
    
    // Use the .desktop file as URL
    _url = KURL();
    _url.setPath(file);
    
    // Update everything...
    slotSettingsChanged();
    
    return true;
}
开发者ID:BackupTheBerlios,项目名称:slicker-svn,代码行数:56,代码来源:launcherapplet.cpp

示例6: df_main

int df_main(int argc, char *argv[]) {
    printf("Filesystem               Size     Used     Free   Blksize\n");
    if (argc == 1) {
        char s[2000];
        FILE *f = fopen("/proc/mounts", "r");

        while (fgets(s, 2000, f)) {
            char *c, *e = s;

            for (c = s; *c; c++) {
                if (*c == ' ') {
                    e = c + 1;
                    break;
                }
            }

            for (c = e; *c; c++) {
                if (*c == ' ') {
                    *c = '\0';
                    break;
                }
            }

            df(e, 0);
        }

        fclose(f);
    } else {
        int i;

        for (i = 1; i < argc; i++) {
            df(argv[i], 1);
        }
    }

    exit(ok);
}
开发者ID:00zhengfu00,项目名称:platform_system_core,代码行数:37,代码来源:df.c

示例7: reset

void PlasmaThemeListModel::refresh()
{
    reset();
    clearThemeList();

    // get all desktop themes
    QStringList themes;
    const QStringList &packs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "plasma/desktoptheme", QStandardPaths::LocateDirectory);
    foreach (const QString &ppath, packs) {
        const QDir cd(ppath);
        const QStringList &entries = cd.entryList(QDir::Dirs | QDir::Hidden);
        foreach (const QString pack, entries) {
            const QString _metadata = ppath+QLatin1Char('/')+pack+QStringLiteral("/metadata.desktop");
            if ((pack != "." && pack != "..") &&
                (QFile::exists(_metadata))) {
                themes << _metadata;
            }
        }
    }

    foreach (const QString &theme, themes) {
        int themeSepIndex = theme.lastIndexOf('/', -1);
        QString themeRoot = theme.left(themeSepIndex);
        int themeNameSepIndex = themeRoot.lastIndexOf('/', -1);
        QString packageName = themeRoot.right(themeRoot.length() - themeNameSepIndex - 1);

        KDesktopFile df(theme);

        if (df.noDisplay()) {
            continue;
        }

        QString name = df.readName();
        if (name.isEmpty()) {
            name = packageName;
        }
        const QString comment = df.readComment();
        const QString author = df.desktopGroup().readEntry("X-KDE-PluginInfo-Author",QString());
        const QString version = df.desktopGroup().readEntry("X-KDE-PluginInfo-Version",QString());


        ThemeInfo info;
        info.package = packageName;
        info.description = comment;
        info.author = author;
        info.version = version;
        info.themeRoot = themeRoot;
        m_themes[name] = info;
    }
开发者ID:plasma-extensions,项目名称:plasma-widget-quick-controls,代码行数:49,代码来源:plasmathemelistmodel.cpp

示例8: getAbsolute

    void LuaPath::_init(std::string const &arg0,
                        std::string const &vrjlua_base) {
        _valid = true;

        _initialPath = fs::initial_path().string();
        std::vector<std::string> startingPlaces;
        startingPlaces.push_back(_initialPath);
        if (!vrjlua_base.empty()) {
            startingPlaces.push_back(getAbsolute(vrjlua_base).string());
        }

        if (!arg0.empty()) {
            _exeDir = getAbsolute(arg0).remove_filename().string();
            startingPlaces.push_back(_exeDir);
        }

        _root = _findFilePath(startingPlaces,
                              "share/vrjugglua/lua/vrjlua-init.lua");
        if (!_root.empty()) {
            _luaDir = (fs::path(_root) / "share/vrjugglua/lua/").string();
            startingPlaces.push_back(
                (fs::path(_root) / "share/vrjugglua/").string());
        } else {
            _root = _findFilePath(startingPlaces, "vrjlua-init.lua");
            _luaDir = _root;
        }
        std::string sourceTreeIndicator =
            (fs::path(_luaDir) / "vrjlua-sourcetreeloc.lua").string();
        if (fs::exists(sourceTreeIndicator)) {
            std::ifstream df(sourceTreeIndicator.c_str());
            if (df.is_open()) {
                std::string line;
                std::getline(df, line);
                boost::algorithm::trim(line);
                if (!line.empty()) {
                    VRJLUA_MSG_START(dbgVRJLUA, MSG_STATUS)
                        << "LuaPath: Presence of file " << sourceTreeIndicator
                        << " indicated we are running from a build tree, "
                           "adding extra path hint " << line
                        << VRJLUA_MSG_END(dbgVRJLUA, MSG_STATUS);
                    startingPlaces.push_back(line);
                }
            }
        }
        _shareDir = _findFilePath(startingPlaces,
                                  "assets/fonts/droid-fonts/DroidSans.ttf");
        _jugglerRoot = _findJuggler();
        _setJugglerEnvironment();
    }
开发者ID:carlsonp,项目名称:vr-jugglua,代码行数:49,代码来源:LuaPath.cpp

示例9: newton

void newton(double x,double eps){
  int num=0,i;
  double ax[MAX+1],dx;
  ax[0]=x;
  for(i=0;i<MAX;i++){
    dx=-1*f(ax[i])/df(ax[i]);
    ax[i+1]=ax[i]+dx;
    if(fabs(dx)<eps){
      num=i+1;
      break;
    }
  }
  if(num==0)printf("Over the limit of times\n");
  else printf("answer is:%lf at %d times\n",ax[num],num);
}
开发者ID:HAVRM,项目名称:work,代码行数:15,代码来源:kadai6_1.c

示例10: f

void TestExprDiff::cst_grad() {
	Function f("x","y","z","10*(x-y)");
	Function df(f,Function::DIFF);
	const ExprNode& y=df.expr();
	const ExprConstant* c = dynamic_cast<const ExprConstant*>(&y);

	CPPUNIT_ASSERT(c);
	CPPUNIT_ASSERT(c->dim.is_vector());
	IntervalVector v(3);
	v[0]=Interval(10,10);
	v[1]=Interval(-10,-10);
	v[2]=Interval(0,0);
	check(c->get_vector_value(),v);
	CPPUNIT_ASSERT((c->get_vector_value()).is_superset(v));
}
开发者ID:SimonRohou,项目名称:ibex-lib,代码行数:15,代码来源:TestExprDiff.cpp

示例11: backwardRun

/* Function for passing over the network (backward pass) */
void backwardRun() {
    int from[2],to[2]; // declarations of auxiliary arrays
    
    /*      Compute deltas in output layers      */
    for (int i = FO, j = 0; i <= LO; i++, j++) { // from first to last neuron in output layer
        d(i) = (dv(j) - y(i)) * df(x(i));        // using formula to compute deltas on output layer
        //printf("\nd(%d) = (dv(%d) - y(%d)) * df(x(%d))",i,j,i,i);
    }
    //printf("\n---------");
    
    /* Compute deltas in first hidden layer  */
    from[0] = F1H; to[0] = L1H;              // definitions from-to for j (from first to last in first hidden layer)
    from[1] =  FO; to[1] =  LO;              // definitions from-to for i (from first to last in second hidden layer)
    deltaRun(from,to);                       // runs function
}
开发者ID:Sinedko,项目名称:Ball_following,代码行数:16,代码来源:backprop-1H.c

示例12: bounds

 void DBARS::add_point(double z){
   if(z > x.back()){
     throw_exception<std::runtime_error>("z out of bounds (too large) in DBARS::add_point");
   }
   if(z < x[0]){
     throw_exception<std::runtime_error>("z out of bounds (too small) in DBARS::add_point");
   }
   IT it = std::lower_bound(x.begin(), x.end(), z);
   int k = it - x.begin();
   x.insert(it, z);
   logf.insert(logf.begin()+k, f(z));
   dlogf.insert(dlogf.begin() + k, df(z));
   refresh_knots();
   update_cdf();
 }
开发者ID:comenerv,项目名称:Boom,代码行数:15,代码来源:DoublyBoundedAdaptiveRejectionSampler.cpp

示例13: df

void IntlTestDecimalFormatSymbols::Verify(double value, const UnicodeString& pattern,
                                          const DecimalFormatSymbols &sym, const UnicodeString& expected){
    UErrorCode status = U_ZERO_ERROR;
    DecimalFormat df(pattern, sym, status);
    if(U_FAILURE(status)){
        errln("ERROR: construction of decimal format failed - %s", u_errorName(status));
    }
    UnicodeString buffer;
    FieldPosition pos(FieldPosition::DONT_CARE);
    buffer = df.format(value, buffer, pos);
    if(buffer != expected){
        errln((UnicodeString)"ERROR: format() returns wrong result\n Expected " +
            expected + ", Got " + buffer);
    }
}
开发者ID:cyrusimap,项目名称:icu4c,代码行数:15,代码来源:tsdcfmsy.cpp

示例14: report_error

 void Tn2Sampler::add_point(double z){
   if(z > x.back()){
     report_error("z out of bounds (too large) in Tn2Sampler::add_point");
   }
   if(z < x[0]){
     report_error("z out of bounds (too small) in Tn2Sampler::add_point");
   }
   IT it = std::lower_bound(x.begin(), x.end(), z);
   int k = it - x.begin();
   x.insert(it, z);
   logf.insert(logf.begin()+k, f(z));
   dlogf.insert(dlogf.begin() + k, df(z));
   refresh_knots();
   update_cdf();
 }
开发者ID:Hkey1,项目名称:boom,代码行数:15,代码来源:Tn2Sampler.cpp

示例15: write_bin_offset

bool write_bin_offset(const wchar_t *file, const void *buffer, int buflen, int offset)
// записывает кусок файла по текущему смещению из буфера, файл должен существовать!
// может писать в любую часть файла, в т.ч. с увеличением его первонач-го размера,
// пропущенные при этом куски заполняются нулями (если смещение больше длины файла)
{
  if ( buflen < 0 || offset < 0 ) return false;

  FILEopen df( file, L"r+b" ); // w+b работает не так как надо!
  if ( !df ) return false;

  if ( fseek(df, offset, SEEK_SET) != 0 ) return false;

  int wnum = (int)fwrite( buffer, 1, buflen, df );
  return wnum == buflen;
}
开发者ID:vadimrm,项目名称:Dichotic-Harmony-Files-Converter,代码行数:15,代码来源:files.cpp


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