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

C++ out函数代码示例

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

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



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

示例1: settingsQss

void QtUiStyle::generateSettingsQss() const {
  QFile settingsQss(Quassel::configDirPath() + "settings.qss");
  if(!settingsQss.open(QFile::WriteOnly|QFile::Truncate)) {
    qWarning() << "Could not open" << settingsQss.fileName() << "for writing!";
    return;
  }
  QTextStream out(&settingsQss);

  out << "// Style settings made in Quassel's configuration dialog\n"
      << "// This file is automatically generated, do not edit\n";

  // ChatView
  ///////////
  QtUiStyleSettings fs("Fonts");
  if(fs.value("UseCustomChatViewFont").toBool())
    out << "\n// ChatView Font\n"
        << "ChatLine { " << fontDescription(fs.value("ChatView").value<QFont>()) << "; }\n";

  QtUiStyleSettings s("Colors");
  if(s.value("UseChatViewColors").toBool()) {
    out << "\n// Custom ChatView Colors\n"

        // markerline is special in that it always used to use a gradient, so we keep this behavior even with the new implementation
        << "Palette { marker-line: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 " << color("MarkerLine", s) << ", stop: 0.1 transparent); }\n"
        << "ChatView { background: " << color("ChatViewBackground", s) << "; }\n\n"
        << "ChatLine[label=\"highlight\"] {\n"
        << "  foreground: " << color("Highlight",s) << ";\n"
        << "  background: " << color("HighlightBackground", s) << ";\n"
        << "}\n\n"
        << "ChatLine::timestamp { foreground: " << color("Timestamp", s) << "; }\n\n"

        << msgTypeQss("plain", "ChannelMsg", s)
        << msgTypeQss("notice", "ServerMsg", s)
        << msgTypeQss("action", "ActionMsg", s)
        << msgTypeQss("nick", "CommandMsg", s)
        << msgTypeQss("mode", "CommandMsg", s)
        << msgTypeQss("join", "CommandMsg", s)
        << msgTypeQss("part", "CommandMsg", s)
        << msgTypeQss("quit", "CommandMsg", s)
        << msgTypeQss("kick", "CommandMsg", s)
        << msgTypeQss("kill", "CommandMsg", s)
        << msgTypeQss("server", "ServerMsg", s)
        << msgTypeQss("info", "ServerMsg", s)
        << msgTypeQss("error", "ErrorMsg", s)
        << msgTypeQss("daychange", "ServerMsg", s)
        << msgTypeQss("topic", "CommandMsg", s)
        << msgTypeQss("netsplit-join", "CommandMsg", s)
        << msgTypeQss("netsplit-quit", "CommandMsg", s)
        << "\n";
  }

  if(s.value("UseSenderColors").toBool()) {
    out << "\n// Sender Colors\n"
        << "ChatLine::sender#plain[sender=\"self\"] { foreground: " << color("SenderSelf", s) << "; }\n\n";

    for(int i = 0; i < 16; i++)
      out << senderQss(i, s);
  }

  // ItemViews
  ////////////

  UiStyleSettings uiFonts("Fonts");
  if(uiFonts.value("UseCustomItemViewFont").toBool()) {
    QString fontDesc = fontDescription(uiFonts.value("ItemView").value<QFont>());
    out << "\n// ItemView Font\n"
        << "ChatListItem { " << fontDesc << "; }\n"
        << "NickListItem { " << fontDesc << "; }\n\n";
  }

  UiStyleSettings uiColors("Colors");
  if(uiColors.value("UseBufferViewColors").toBool()) {
    out << "\n// BufferView Colors\n"
        << "ChatListItem { foreground: " << color("DefaultBuffer", uiColors) << "; }\n"
        << chatListItemQss("inactive", "InactiveBuffer", uiColors)
        << chatListItemQss("channel-event", "ActiveBuffer", uiColors)
        << chatListItemQss("unread-message", "UnreadBuffer", uiColors)
        << chatListItemQss("highlighted", "HighlightedBuffer", uiColors);
  }

  if(uiColors.value("UseNickViewColors").toBool()) {
    out << "\n// NickView Colors\n"
        << "NickListItem[type=\"category\"] { foreground: " << color("DefaultBuffer", uiColors) << "; }\n"
        << "NickListItem[type=\"user\"] { foreground: " << color("OnlineNick", uiColors) << "; }\n"
        << "NickListItem[type=\"user\", state=\"away\"] { foreground: " << color("AwayNick", uiColors) << "; }\n";
  }

  settingsQss.close();
}
开发者ID:bawNg,项目名称:quassel,代码行数:89,代码来源:qtuistyle.cpp


示例2: register_language

int clobber_parse_optionst::doit()
{
  if(cmdline.isset("version"))
  {
    std::cout << CBMC_VERSION << std::endl;
    return 0;
  }

  register_language(new_ansi_c_language);
  register_language(new_cpp_language);

  //
  // command line options
  //

  optionst options;
  get_command_line_options(options);

  eval_verbosity();

  goto_functionst goto_functions;

  if(get_goto_program(options, goto_functions))
    return 6;
    
  label_properties(goto_functions);

  if(cmdline.isset("show-properties"))
  {
    const namespacet ns(symbol_table);
    show_properties(ns, get_ui(), goto_functions);
    return 0;
  }

  if(set_properties(goto_functions))
    return 7;
    
  // do instrumentation

  try
  {
    const namespacet ns(symbol_table);
    
    std::ofstream out("simulator.c");
    
    if(!out)
      throw std::string("failed to create file simulator.c");
    
    dump_c(goto_functions, true, ns, out);
    
    status() << "instrumentation complete; compile and execute simulator.c" << eom;
    
    return 0;
  }
  
  catch(const std::string error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  catch(const char *error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  #if 0                                         
  // let's log some more statistics
  debug() << "Memory consumption:" << messaget::endl;
  memory_info(debug());
  debug() << eom;
  #endif
}
开发者ID:Dthird,项目名称:CBMC,代码行数:74,代码来源:clobber_parse_options.cpp


示例3: plot_funz_ml

void plot_funz_ml(const char *out_path,const char *title,const char *xlab,const char *ylab,bvec &X,bvec &Y,bvec &par,double X_phys,double (*fun)(double,double,double,double,double,double),boot &chiral_extrap_cont)
{
  //setup the plot
  grace out(out_path);
  out.plot_size(800,600);
  out.plot_title(combine("Chiral extrapolation of %s",title).c_str());
  out.axis_label(xlab,ylab);
  
  if(fun!=NULL)
    {
      //plot the function with error
      int npoint=100;
      double X_pol[npoint];
      bvec Y_pol(npoint,nboot,njack);
      for(int ipoint=0;ipoint<npoint;ipoint++) X_pol[ipoint]=0.0599/(npoint-1)*ipoint+0.0001;
      for(int ib=0;ib<nbeta;ib++)
	{
	  bvec Y_pol(npoint,nboot,njack);
	  for(int ipoint=0;ipoint<npoint;ipoint++)
	    for(int iboot=plot_iboot=0;iboot<nboot+1;plot_iboot=iboot++)
	      Y_pol.data[ipoint].data[iboot]=fun(par[0][iboot],par[1][iboot],par[2][iboot],par[3][iboot],X_pol[ipoint],lat[ib][iboot]);
	  
	  out.set(1,set_fill_color[ib]);
	  out.polygon(X_pol,Y_pol);
	  out.new_set();
	  out.set(1,set_color[ib]);
	  out.set_line_size(2);
	  out.ave_line(X_pol,Y_pol);
	  out.new_set();
	}
      //plot continuum curve
      for(int ipoint=0;ipoint<npoint;ipoint++)
	for(int iboot=plot_iboot=0;iboot<nboot+1;plot_iboot=iboot++)
	  Y_pol.data[ipoint]=fun(par[0][iboot],par[1][iboot],par[2][iboot],par[3][iboot],X_pol[ipoint],0);
      //out.set(1,"magenta");
      //out.polygon(X_pol,Y_pol);
      //out.new_set();
      out.set(1,"magenta");
      out.set_line_size(3);
      out.ave_line(X_pol,Y_pol);
      out.new_set();
    }
  
  //plot the original data with error  
  for(int ib=0;ib<nbeta;ib++)
    {
      out.set(4,"none",set_symbol[ib],set_color[ib],"filled");
      out.set_legend(set_legend_fm[ib]);
      out.set_line_size(2);
      out.fout<<"@type xydy"<<endl;
      for(int iens=0;iens<nens;iens++) if(ibeta[iens]==ib) out.fout<<X[iens].med()<<" "<<Y.data[iens]<<endl;
      out.new_set();
    }
  
  //plot the extrapolated point with error
  out.set(4,"none","circle","indigo","filled");
  out.set_line_size(3);
  out.set_legend("Physical point");
  out.print_graph(X_phys,chiral_extrap_cont);
  out.new_set();
}
开发者ID:sunpho84,项目名称:sunpho,代码行数:61,代码来源:extr_adim.cpp


示例4: err_bmf

void err_bmf() { out("553 sorry, your envelope sender is in my badmailfrom list (#5.7.1)\r\n"); }
开发者ID:kp-org,项目名称:eQmail,代码行数:1,代码来源:qmail-smtpd.c


示例5: out

void UnitTestOutputLog::testUnit()
{
  // Make cout and cerr available as log stream targets.
  stk::register_log_ostream(std::cout, "cout");
  stk::register_log_ostream(std::cerr, "cerr");

  // Test registration, binding, rebinding and unregistration
  {
    std::ostringstream log1;
    std::ostringstream log2;
    
    std::ostream out(std::cout.rdbuf());

    stk::register_ostream(out, "out");

    CPPUNIT_ASSERT(stk::is_registered_ostream("out"));
    
    stk::register_log_ostream(log1, "log1");
    stk::register_log_ostream(log2, "log2");

    stk::bind_output_streams("out>log1");

    out << "stk::bind_output_streams(\"out>log1\");" << std::endl;

    stk::bind_output_streams("out>+log2");
    out << "stk::bind_output_streams(\"out>+log2\");" << std::endl;
    
    stk::bind_output_streams("out>-log1");
    out << "stk::bind_output_streams(\"out>-log1\");" << std::endl;

    stk::bind_output_streams("out>-log2");
    out << "stk::bind_output_streams(\"out>-log2\");" << std::endl;

    std::ostringstream log1_result;
    log1_result << "stk::bind_output_streams(\"out>log1\");" << std::endl
                << "stk::bind_output_streams(\"out>+log2\");" << std::endl;
    
    std::ostringstream log2_result;
    log2_result << "stk::bind_output_streams(\"out>+log2\");" << std::endl
                << "stk::bind_output_streams(\"out>-log1\");" << std::endl;
    
    CPPUNIT_ASSERT_EQUAL(log1_result.str(), log1.str());
    CPPUNIT_ASSERT_EQUAL(log2_result.str(), log2.str());

    stk::unregister_log_ostream(log1);
    stk::unregister_log_ostream(log2);
    stk::unregister_ostream(out);

    CPPUNIT_ASSERT_EQUAL(out.rdbuf(), std::cout.rdbuf());
  }

  // Test logging to a file
  {
    std::ostream out(std::cout.rdbuf());

    stk::register_ostream(out, "out");

    stk::bind_output_streams("log=\"logfile\" out>log");

    CPPUNIT_ASSERT_EQUAL(std::string("logfile"), stk::get_log_path("log")); 
    
    out << "This is a test" << std::endl;

    stk::bind_output_streams("log=\"\"");
    
    stk::unregister_ostream(out);

    std::ostringstream log_result;
    log_result << "This is a test";
    
    std::ifstream log_stream("logfile");
    std::string log_string;
    getline(log_stream, log_string);
    CPPUNIT_ASSERT_EQUAL(log_result.str(), log_string);
  }

  // Test results of unregistration of an output stream bound as a log stream
  {
    std::ostringstream default_log;
    std::ostream out(default_log.rdbuf());
    std::ostream pout(std::cout.rdbuf());

    stk::register_ostream(out, "out");
    stk::register_ostream(pout, "pout");

    //  Constructing the log streams after the registered output stream is not exception safe.
    std::ostringstream log;
    stk::register_log_ostream(log, "log");

    // As a result, this try catch block must be represent to ensure the that unregistration
    // happens correctly.
    try {  
      stk::bind_output_streams("out>pout pout>log");

      out << "This is to out" << std::endl;
      pout << "This is to pout" << std::endl;

      std::ostringstream log_result;
      log_result << "This is to out" << std::endl
                 << "This is to pout" << std::endl;
//.........这里部分代码省略.........
开发者ID:haripandey,项目名称:trilinos,代码行数:101,代码来源:UnitTestOutputLog.cpp


示例6: die_control

void die_control() { logit("unable to read controls"); out("421 unable to read controls (#4.3.0)\r\n"); flush(); _exit(1); }
开发者ID:kp-org,项目名称:eQmail,代码行数:1,代码来源:qmail-smtpd.c


示例7: straynewline

void straynewline() { logit("bad newlines"); out("451 See http://pobox.com/~djb/docs/smtplf.html.\r\n"); flush(); _exit(1); }
开发者ID:kp-org,项目名称:eQmail,代码行数:1,代码来源:qmail-smtpd.c


示例8: main

int main() {
    //std::vector<int> items = {1,2,3,4,5,6,7,8,9,10};

    std::string filename("sampleEmbedding_200.txt");
    //std::string filename("iris.data");
    std::vector< std::vector<double> > items = load_data(filename);

    // generate similarity matrix
    unsigned int size = items.size();
    Eigen::MatrixXd m = Eigen::MatrixXd::Zero(size,size);
    std::cout << "------------" << std::endl;

    for (unsigned int i=0; i < size; i++) {
        for (unsigned int j=0; j < size; j++) {
            // generate similarity
            //int d = items[i] - items[j];
	    double d = eculidean_distance(items[i], items[j]);
            int similarity = exp(-d*d / 1);
            m(i,j) = similarity;
            m(j,i) = similarity;
        }
    }

    // the number of eigenvectors to consider. This should be near (but greater) than the number of clusters you expect. Fewer dimensions will speed up the clustering
    int numDims = size;

    // do eigenvalue decomposition
    SpectralClustering* c = new SpectralClustering(m, numDims);

    // whether to use auto-tuning spectral clustering or kmeans spectral clustering
    bool autotune = false;

    std::vector<std::vector<int> > clusters;
    if (autotune) {
        // auto-tuning clustering
        clusters = c->clusterRotate();
    } else {
        // how many clusters you want
        int numClusters = 10;
        clusters = c->clusterKmeans(numClusters);
    }

    // output clustered items
    // items are ordered according to distance from cluster centre
    for (unsigned int i=0; i < clusters.size(); i++) {
        std::cout << "Cluster " << i << ": " << "Item ";
        std::copy(clusters[i].begin(), clusters[i].end(), std::ostream_iterator<int>(std::cout, ", "));
        std::cout << std::endl;
    }
	std::map<int, int> sampleid_to_clusterid;
    for (unsigned int i = 0; i < clusters.size(); i++) {
    	for (unsigned int j = 0; j < clusters[i].size(); j++){
		sampleid_to_clusterid.insert(std::make_pair(clusters[i][j], i));
	}
    }
    
    std::string output_filename("sample_assignment.txt");

    std::ofstream out(output_filename.c_str(), std::ios::out);
    if(!out) {
    	std::cerr << "Can't open output file " << output_filename << std::endl;
    	return 0;
    }
    std::map<int, int>::iterator it;
    for(it = sampleid_to_clusterid.begin(); it != sampleid_to_clusterid.end(); it++) {
    	out << it->second << std::endl;
    }
    out.close();
   
}
开发者ID:EnjoyHacking,项目名称:stsc,代码行数:70,代码来源:example.cpp


示例9: switch

//Запуск программы юзера
void MainWindow::on_run_triggered()
{
    if (n) //Если вкадки открыты
    {
        QString format,compiler;
        switch (tabs[cur_tab]->getLang())
        {
        case CPP:
            format = "cpp";
            compiler = "g++ temp.cpp";
            break;
        case PAS:
            format = "pas";
            compiler = "fpc temp.pas";
            break;
        case APX:
            format = "apx";
            compiler = "apx temp.apx";
            break;
        }

        QString str = tabs[cur_tab]->toPlainText();

        //Запись текста таба во временный файл
        QFile("temp."+format).remove();
        std::ofstream out(std::string("temp."+format.toStdString()).c_str());
        out << str.toStdString();
        out << "\n";
        out.close();

        if (tabs[cur_tab]->getLang()==APX)
        {
            //Запуск интерпретатора (если апх)
            switchRun();
            cp->start(compiler);
            cp->waitForStarted();
        }
        else
        {
            //Компилируем
            comp_in_progress = true;
            cp->start(compiler);
            cp->waitForFinished();
            comp_in_progress = false;

            if (cp->exitCode())
                ui->textEdit->append(allErrors);
            allErrors = "";

            if (!cp->exitCode()) //Если успешно скомпилилось
            {
			#ifdef Q_OS_UNIX
                switchRun();
                cp->start(cur_lang==CPP?"./a.out":"./temp.out");
                cp->waitForStarted();
                QFile(cur_lang==CPP?"./a.out":"./temp.out").remove();//Для Linux
            #endif
            #ifdef Q_OS_WIN
                switchRun();
                cp->start(cur_lang==CPP?"a.exe":"temp.exe");
                cp->waitForStarted();
                QFile(cur_lang==CPP?"a.exe":"temp.exe").remove();//Для Windows
            #endif
            }
        }
    }
    else
        QMessageBox::warning(ui->tabWidget,"Error","Возможно вы не открыли/создали ни одного файла",QMessageBox::Yes,QMessageBox::Yes);
}
开发者ID:NOOBS-DevTeam,项目名称:Appendix,代码行数:70,代码来源:mainwindow.cpp


示例10: main

main () {
	
	int an,ad;
	int rm;
	char *p;
    int i,j,k,c;
	int hl,sz,lp,pl;
	
	//clock_t st,ed,*pt;
    
	fin  = fopen ("fracdec.in", "r");
	fout = fopen ("fracdec.out", "w");
	//fout = stdout;
	
    fscanf (fin, "%d %d", &an,&ad);
	//scanf ("%d %d", &an,&ad);
	
	sprintf(ret,"%d",an/ad);
	hl=strlen(ret);
	lp=pl=0;//big trouble without init
	if(an%ad==0){
		strcpy(ret+hl,".0");
	}else{
		ret[hl]='.';
		p=ret+hl+1;
		for(i=0;i<mxn-hl-10;i++){
			rm=an%ad;
			if(!ql[rm])ql[rm]=i+1;
			else{
				lp=ql[rm]-1;
				pl=i-lp;
				*p='\0';
				break;
			}
			rm*=10;
			*p++=rm/ad+'0';
			an=rm%ad;
			if(an==0){
				*p='\0';break;
			}
		}
	}
	
	if(pl){
		*p='\0';
		p=ret+hl+1;
		i=lp;k=pl;
#if 0 //tle
	if(i==mxn-hl-10){
		*p='\0';
		p=ret+hl+1;
		sz=mxn-hl-10;
		for(k=1;k<ad&&k<sz/2;k++){
			for(i=0;i<k;i++){
				j=i+k;
				while(j<sz-k){
					if(strncmp(p+i,p+j,k)!=0)break;
					j+=k;
				}
				if(j>=sz-k)break;
			}
			if(i<k)break;
		}
#endif
		printf("%d %d\n",i,k);
		p[i+k+1]=')';
		p[i+k+2]='\0';
		for(j=i+k;j>i;j--){
			p[j]=p[j-1];
		}
		p[i]='(';
    }
	
	out();
    exit (0);
}
开发者ID:hitme,项目名称:USACO,代码行数:76,代码来源:task41-fracdec.c


示例11: out

void	CHD61102::save_internal(QFile *file){
    QDataStream out(file);

    out.writeRawData("HD61102STA", 10);					//header
    out.writeRawData((char*)&info,sizeof(info));		//reg
}
开发者ID:TheProjecter,项目名称:pockemul,代码行数:6,代码来源:hd61102.cpp


示例12: out

pdsp::Patchable& ofxPDSPMonoFader::out_signal() {
    return out("signal");
}
开发者ID:npisanti,项目名称:ofxPDSP,代码行数:3,代码来源:ofxPDSPMonoFader.cpp


示例13: main

int main(int argc, char *argv[])
{
    QString title;
    title = title + "********************************************************************* \n";
    title = title + " * Create from XML                                                   * \n";
    title = title + " * This tool create a SQL DDL script file from a XML schema file     * \n";
    title = title + " * created by ODKToMySQL.                                            * \n";
    title = title + " *                                                                   * \n";
    title = title + " * This tool is usefull when dealing with multiple versions of an    * \n";
    title = title + " * ODK survey that were combined into a common XML schema using      * \n";
    title = title + " * compareCreateXML.                                                 * \n";
    title = title + " ********************************************************************* \n";

    TCLAP::CmdLine cmd(title.toUtf8().constData(), ' ', "2.0");

    TCLAP::ValueArg<std::string> inputArg("i","input","Input create XML file",true,"","string");
    TCLAP::ValueArg<std::string> outputArg("o","output","Output SQL file",false,"./create.sql","string");

    for (int i = 1; i < argc; i++)
    {
        command = command + argv[i] + " ";
    }

    cmd.add(inputArg);
    cmd.add(outputArg);

    //Parsing the command lines
    cmd.parse( argc, argv );

    //Getting the variables from the command
    QString input = QString::fromUtf8(inputArg.getValue().c_str());
    QString output = QString::fromUtf8(outputArg.getValue().c_str());
    idx = 0;

    if (input != output)
    {
        if (QFile::exists(input))
        {
            //Openning and parsing input file A
            QDomDocument docA("input");
            QFile fileA(input);
            if (!fileA.open(QIODevice::ReadOnly))
            {
                log("Cannot open input file");
                return 1;
            }
            if (!docA.setContent(&fileA))
            {
                log("Cannot parse input file");
                fileA.close();
                return 1;
            }
            fileA.close();

            QDomElement rootA = docA.documentElement();

            if (rootA.tagName() == "XMLSchemaStructure")
            {
                QFile file(output);
                if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
                {
                    log("Cannot create output file");
                    return 1;
                }

                QDateTime date;
                date = QDateTime::currentDateTime();

                QTextStream out(&file);

                out << "-- Code generated by createFromXML" << "\n";
                out << "-- " + command << "\n";
                out << "-- Created: " + date.toString("ddd MMMM d yyyy h:m:s ap")  << "\n";
                out << "-- by: createFromXML Version 1.0" << "\n";
                out << "-- WARNING! All changes made in this file might be lost when running createFromXML again" << "\n\n";

                QDomNode lkpTables = docA.documentElement().firstChild();
                QDomNode tables = docA.documentElement().firstChild().nextSibling();
                if (!lkpTables.isNull())
                {
                    procLKPTables(lkpTables.firstChild(),out);
                }
                if (!tables.isNull())
                {
                    procTables(tables.firstChild(),out);
                }
            }
            else
            {
                log("Input document is not a XML create file");
                return 1;
            }
        }
        else
        {
            log("Input file does not exists");
            return 1;
        }
    }
    else
//.........这里部分代码省略.........
开发者ID:ilri,项目名称:odktools,代码行数:101,代码来源:main.cpp


示例14: getOption

void SdpSolverInternal::init() {
  // Call the init method of the base class
  FunctionInternal::init();

  calc_p_ = getOption("calc_p");
  calc_dual_ = getOption("calc_dual");
  print_problem_ = getOption("print_problem");

  // Find aggregate sparsity pattern
  Sparsity aggregate = input(SDP_SOLVER_G).sparsity();
  for (int i=0;i<n_;++i) {
    aggregate = aggregate + input(SDP_SOLVER_F)(ALL, Slice(i*m_, (i+1)*m_)).sparsity();
  }

  // Detect block diagonal structure in this sparsity pattern
  std::vector<int> p;
  std::vector<int> r;
  nb_ = aggregate.stronglyConnectedComponents(p, r);
  block_boundaries_.resize(nb_+1);
  std::copy(r.begin(), r.begin()+nb_+1, block_boundaries_.begin());

  block_sizes_.resize(nb_);
  for (int i=0;i<nb_;++i) {
    block_sizes_[i]=r[i+1]-r[i];
  }

  // Make a mapping function from dense blocks to inversely-permuted block diagonal P
  std::vector< SX > full_blocks;
  for (int i=0;i<nb_;++i) {
    full_blocks.push_back(SX::sym("block", block_sizes_[i], block_sizes_[i]));
  }

  Pmapper_ = SXFunction(full_blocks, blkdiag(full_blocks)(lookupvector(p, p.size()),
                                                         lookupvector(p, p.size())));
  Pmapper_.init();

  if (nb_>0) {
    // Make a mapping function from (G, F) -> (G[p, p]_j, F_i[p, p]j)
    SX G = SX::sym("G", input(SDP_SOLVER_G).sparsity());
    SX F = SX::sym("F", input(SDP_SOLVER_F).sparsity());

    std::vector<SX> in;
    in.push_back(G);
    in.push_back(F);
    std::vector<SX> out((n_+1)*nb_);
    for (int j=0;j<nb_;++j) {
      out[j] = G(p, p)(Slice(r[j], r[j+1]), Slice(r[j], r[j+1]));
    }
    for (int i=0;i<n_;++i) {
      SX Fi = F(ALL, Slice(i*m_, (i+1)*m_))(p, p);
      for (int j=0;j<nb_;++j) {
        out[(i+1)*nb_+j] = Fi(Slice(r[j], r[j+1]), Slice(r[j], r[j+1]));
      }
    }
    mapping_ = SXFunction(in, out);
    mapping_.init();
  }

  // Output arguments
  setNumOutputs(SDP_SOLVER_NUM_OUT);
  output(SDP_SOLVER_X) = DMatrix::zeros(n_, 1);
  output(SDP_SOLVER_P) = calc_p_? DMatrix(Pmapper_.output().sparsity(), 0) : DMatrix();
  output(SDP_SOLVER_DUAL) = calc_dual_? DMatrix(Pmapper_.output().sparsity(), 0) : DMatrix();
  output(SDP_SOLVER_COST) = 0.0;
  output(SDP_SOLVER_DUAL_COST) = 0.0;
  output(SDP_SOLVER_LAM_X) = DMatrix::zeros(n_, 1);
  output(SDP_SOLVER_LAM_A) = DMatrix::zeros(nc_, 1);

}
开发者ID:tmmsartor,项目名称:casadi,代码行数:69,代码来源:sdp_solver_internal.cpp


示例15: die_alarm

void die_alarm() { logit("timeout"); out("451 timeout (#4.4.2)\r\n"); flush(); _exit(1); }
开发者ID:kp-org,项目名称:eQmail,代码行数:1,代码来源:qmail-smtpd.c


示例16: main

void main() 
{ 
int p,q,r,s; 
int k,m,n; 
int temp,wap; 
int num,j; 


cout<<"请输入四个数:"<<endl; 
for(j=1;j<NUM;j++) 
cin>>array[j]; 
for(p=1;p<NUM;p++) 
for(q=1;q<NUM;q++) 
for(r=1;r<NUM;r++) 
for(s=1;s<NUM;s++) 
{//sssssssssssssssssssssssssssssssssssssssssssss 
if(q!=p&&r!=p&&r!=q&&s!=p&&s!=q&&s!=r) 
{a=array[p];b=array[q];c=array[r];d=array[s];} 
else continue; 
for(k=1;k<NUM;k++) 
{ 
switch(k) 
{//k 
case 1: 
num=a+b;break; 
case 2: 
if(a>=b) 
num=a-b; 
else continue;break; 
case 3: 
num=a*b;break; 
case 4: 
if(a>=b&&b!=0&&a%b==0) 
num=a/b; 
else continue;break; 
} 
wap=num; 
for(m=1;m<NUM;m++) 
{//m 
num=wap; 
switch(m)//###################### 
{ 
case 1: 
if(k==3) 
{ 
if(a*b+c*d==GAME) 
output(k,m,3); 
if((c>=d&&d!=0&&c%d==0)&&(a*b+c/d==GAME)) 
output(k,m,4); 
} 
if(k==4) 
{ 
if(a/b+c*d==GAME) 
output(k,m,3); 
if((c>=d&&d!=0&&c%d==0)&&(a/b+c/d==GAME)) 
output(k,m,4); 
} 
num=num+c; 
break; 
case 2: 
if(k==3) 
{ 
if(a*b>=c*d&&(a*b-c*d==GAME)) 
output(k,m,3); 
if((c>=d&&d!=0&&c%d==0&&a*b>=c/d)&&(a*b-c/d==GAME)) 
output(k,m,4); 
} 
if(k==4) 
{ 
if(a/b>=c*d&&(a/b-c*d==GAME)) 
output(k,m,3); 
if((c>=d&&d!=0&&(c%d==0))&&a/b>c/d&&(a/b-c/d==GAME)) 
output(k,m,4); 
} 
if(num>=c) 
num=num-c; 
else continue; 
break; 
case 3: 
num=num*c;break; 
case 4: 
if(num>=c&&c!=0&&num%c==0) 
num=num/c; 
else continue;break; 
}//############################# 
temp=num; 
for(n=1;n<NUM;n++) 
{//n 
num=temp; 
switch(n) 
{ 
case 1: 
num=num+d;break; 
case 2: 
if(num>=d) 
num=num-d; 
else continue;break; 
case 3: 
num=num*d;break; 
case 4: 
//.........这里部分代码省略.........
开发者ID:alannet,项目名称:example,代码行数:101,代码来源:24点问题.cpp


示例17: die_nomem

void die_nomem() { out("421 out of memory (#4.3.0)\r\n"); flush(); _exit(1); }
开发者ID:kp-org,项目名称:eQmail,代码行数:1,代码来源:qmail-smtpd.c


示例18: main

int main ( void )

/******************************************************************************/
/*
  Purpose:

    MAIN is the main program for FEM1D_PMETHOD.

  Discussion:

    FEM1D_PMETHOD implements the P-version of the finite element method.

    Program to solve the one dimensional problem:

      - d/dX (P dU/dX) + Q U  =  F

    by the finite-element method using a sequence of polynomials
    which satisfy the boundary conditions and are orthogonal
    with respect to the inner product:

      (U,V)  =  Integral (-1 to 1) P U' V' + Q U V dx

    Here U is an unknown scalar function of X defined on the
    interval [-1,1], and P, Q and F are given functions of X.

    The boundary values are U(-1) = U(1)=0.

    Sample problem #1:

      U=1-x^4,        P=1, Q=1, F=1.0+12.0*x^2-x^4

    Sample problem #2:

      U=cos(0.5*pi*x), P=1, Q=0, F=0.25*pi*pi*cos(0.5*pi*x)

    The program should be able to get the exact solution for
    the first problem, using NP = 2.

  Licensing:

    This code is distributed under the GNU LGPL license.

  Modified:

    04 July 2013

  Author:

    Original FORTRAN77 version by Max Gunzburger, Teresa Hodge.
    C version by John Burkardt.

  Local Parameters:

    Local, double A[NP+1], the squares of the norms of the
    basis functions.

    Local, double ALPHA[NP], BETA[NP], the basis function 
    recurrence coefficients.

    Local, double F[NP+1].
    F contains the basis function coefficients that form the
    representation of the solution U.  That is,
      U(X)  =  SUM (I=0 to NP) F(I) * BASIS(I)(X)
    where "BASIS(I)(X)" means the I-th basis function
    evaluated at the point X.

    Local, int NP.
    The highest degree polynomial to use.

    Local, int NPRINT.
    The number of points at which the computed solution
    should be printed out at the end of the computation.

    Local, int PROBLEM, indicates the problem being solved.
    1, U=1-x^4, P=1, Q=1, F=1.0+12.0*x^2-x^4.
    2, U=cos(0.5*pi*x), P=1, Q=0, F=0.25*pi*pi*cos(0.5*pi*x).

    Local, int QUAD_NUM, the order of the quadrature rule.

    Local, double QUAD_W[QUAD_NUM], the quadrature weights.

    Local, double QUAD_X[QUAD_NUM], the quadrature abscissas.
*/
{
# define NP 2
# define QUAD_NUM 10

  double a[NP+1];
  double alpha[NP];
  double beta[NP];
  double f[NP+1];
  int nprint = 10;
  int problem = 2;
  double quad_w[QUAD_NUM];
  double quad_x[QUAD_NUM];

  timestamp ( );
  printf ( "\n" );
  printf ( "FEM1D_PMETHOD\n" );
  printf ( "  C version\n" );
//.........这里部分代码省略.........
开发者ID:johannesgerer,项目名称:jburkardt-c,代码行数:101,代码来源:fem1d_pmethod.c


示例19: die_ipme

void die_ipme() { logit("unable to figure out my IP addresses"); out("421 unable to figure out my IP addresses (#4.3.0)\r\n"); flush(); _exit(1); }
开发者ID:kp-org,项目名称:eQmail,代码行数:1,代码来源:qmail-smtpd.c


示例20: file

void BinaryDataGenerator::SaveCharmap(const CharMap &charmap, bool compress,
	enum OutputFormat format, const wxString &filePath)
{
	// Try opening the file for writing
	wxFFileOutputStream file(filePath);
	if (!file.IsOk()) {
		wxLogError(_("Could not open the file for writing"));
		return;
	}
	wxDataOutputStream out(file);
	out.BigEndianOrdered(false);
	out.UseBasicPrecisions();

	int numCodePages = charmap.GetCountCodePages();
	int headerSize = sizeof(wxUint32) + sizeof(wxInt16) + 2 * sizeof(wxUint8) + numCodePages * sizeof(wxUint32);
	int codePageBaseSize = sizeof(wxUint32) * 2 + 16;

	wxASSERT(numCodePages <= UINT8_MAX);
	if(compress) wxLogDebug("Compression not supported yet");
	// TODO: add compression
	// Write header
	wxUint32 magic = 'EMGF';
	wxUint8 flags = format;
	if (compress) flags |= FLAG_COMPRESSED;
	int ascender = 0;
	int ascenderDiv = 0;
	out.Write32(magic);
	file.SeekO(sizeof(wxInt16), wxFromCurrent);
	out.Write8(flags);
	out.Write8((wxUint8)numCodePages);

	wxUint32 *codepagePtrs = new wxUint32[numCodePages];
	wxUint32 **glyphPtrs = new wxUint32*[numCodePages];

	// Write codepages
	file.SeekO(headerSize);
	std::list<CodePage *>::const_iterator it = charmap.CBegin();
	for (int i = 0; i < numCodePages; i++) {
		wxASSERT(it != charmap.CEnd());
		codepagePtrs[i] = file.TellO();
		out.Write32((*it)->GetRangeStart());
		out.Write32((*it)->GetRangeEnd());
		const wxString &name = (*it)->GetName();
		for (unsigned int j = 0; j < 16; ++j) {
			out.Write8(j < name.Length() ? name.ToAscii()[j] : '\0');
		}
		glyphPtrs[i] = new wxUint32[(*it)->GetSize()];
		file.SeekO(sizeof(wxUint32) * (*it)->GetSize(), wxFromCurrent);
	}
	// Write glyphs
	it = charmap.CBegin();
	for (int i = 0; i < numCodePages; i++) {
		wxASSERT(it != charmap.CEnd());
		for (unsigned int j = 0; j < (*it)->GetSize(); j++) {
			const CharMapEntry *entry = (*it)->GetCharMapEntry((*it)->GetRangeStart() + j);
			if (entry == NULL) {
				glyphPtrs[i][j] = 0;
				continue;
			}
			LoadFont(entry->GetFamily(), entry->GetStyle(), entry->GetSize(), entry->GetEncodingID());
			wxUint32 glyph;
			if (!m_loadedFont.IsOk() || (glyph = m_loadedFont.GetGlyphIndex(entry->GetCode())) == 0)
			{
				wxLogWarning("Could not load glyph with code %u", (*it)->GetRangeStart() + j);
				glyphPtrs[i][j] = 0;
				continue;
			}
			wxPoint advance = m_loadedFont.GetGlyphAdvance(glyph);
			wxPoint bitmapTL = m_loadedFont.GetGlyphBitmapTL(glyph);
			int bitmapWidth, bitmapHeight;
			int bitmapSize = m_loadedFont.GetGlyphBitmap(glyph, NULL, &bitmapWidth, &bitmapHeight);
			if (bitmapSize < 0) {
				wxLogWarning("Error while getting bitmap for glyph with code %u", (*it)->GetRangeStart() + j);
				glyphPtrs[i][j] = 0;
				continue;
			}
			wxUint8 *bitmap = new wxUint8[bitmapSize];
			int result = m_loadedFont.GetGlyphBitmap(glyph, bitmap, &bitmapWidth, &bitmapHeight);
			wxASSERT(result == bitmapSize);

			bitmapSize = ConvertToFormat(bitmap, bitmapSize, format);

			if (compress) {
				CompressBitmap(&bitmap, &bitmapSize,  bitmapWidth * bitmapHeight, format);
			}

			ascender += m_loadedFont.GetAscender();
			ascenderDiv++;

			glyphPtrs[i][j] = file.TellO();
			out.Write16((wxInt16)advance.x);
			out.Write16((wxInt16)advance.y);
			out.Write16((wxInt16)bitmapTL.x);
			out.Write16((wxInt16)bitmapTL.y);
			out.Write16((wxUint16)bitmapWidth);
			out.Write16((wxUint16)bitmapHeight);
			out.Write32(bitmapSize);
			file.Write(bitmap, bitmapSize & ~(1<<31));
			delete[] bitmap;
		}
//.........这里部分代码省略.........
开发者ID:robojan,项目名称:EMGL,代码行数:101,代码来源:BinaryDataGenerator.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ out1fmt函数代码示例发布时间:2022-05-30
下一篇:
C++ other_select_init函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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