本文整理汇总了C++中out_file函数的典型用法代码示例。如果您正苦于以下问题:C++ out_file函数的具体用法?C++ out_file怎么用?C++ out_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了out_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv) {
try {
using float_t = double;
using size_type = std::uint32_t;
if (4 != argc)
throw std::invalid_argument("usage: simplify <<t> | -p> <in_file> <out_file>");
// read the flow complex from file
auto fc = FC::flow_complex<float_t, size_type>(42, 42); // dummy
{
auto in_filename = argv[2];
std::ifstream in_file(in_filename);
in_file >> fc;
}
char const* action = argv[1];
if (std::string(action) == "-p") {
char const* out_filename = argv[3];
std::ofstream out_file(out_filename);
print_histogram(out_file, std::move(fc));
} else {
// simplify
float_t const t = std::atof(argv[1]);
if (t < 1)
throw std::invalid_argument("prerequisite: t >= 1");
fc = simplify(std::move(fc), t);
// write result flow complex to file
char const* out_filename = argv[3];
std::ofstream out_file(out_filename);
out_file << fc;
}
} catch (std::exception & e) {
std::cerr << e.what() << std::endl;
std::exit(EXIT_FAILURE);
}
std::exit(EXIT_SUCCESS);
}
示例2: save_column_vector
void ExplicitSystemManager::dump_system() {
int denominator = std::max((int)options.save_frequency, 1);
std::string filename_tail = (boost::format("_%05d") % (iteration_number / denominator)).str();
std::string displacements_filename = (boost::format("%s%s.txt") % options.nodal_displacements_filename % filename_tail).str();
std::string velocities_filename = (boost::format("%s%s.txt") % options.nodal_velocities_filename % filename_tail).str();
std::string forces_filename = (boost::format("%s%s.txt") % options.nodal_forces_filename % filename_tail).str();
save_column_vector(explicit_system->getDisplacements(), displacements_filename);
config_doc["nodal_displacements"].SetString(displacements_filename.c_str(), displacements_filename.length());
save_column_vector(explicit_system->getVelocities(), velocities_filename);
config_doc["nodal_velocities"].SetString(velocities_filename.c_str(), velocities_filename.length());
save_column_vector(explicit_system->getForces(), forces_filename);
config_doc["start_time"].SetDouble(explicit_system->getTime());
config_doc["iteration_number"].SetUint(iteration_number);
std::string state_filename((boost::format("%s%s.json") % options.state_filename % filename_tail).str());
std::ofstream out_file(state_filename);
if (out_file.is_open()) {
rapidjson::OStreamWrapper o_wrapper(out_file);
rapidjson::PrettyWriter<rapidjson::OStreamWrapper> writer(o_wrapper);
config_doc.Accept(writer);
out_file.close();
}
else {
throw std::runtime_error((boost::format("Unable to open %s.") % state_filename).str());
}
}
示例3: out_file
void EMFit::output(std::string out_file_name, std::string out_pdb_file_name) {
std::ofstream out_file(out_file_name.c_str());
out_file << "receptorPdb (str) " << rec_file_name_ << std::endl;
out_file << "ligandPdb (str) " << lig_file_name_ << std::endl;
EM3DFitResult::print_header(out_file);
out_file.setf(std::ios::fixed, std::ios::floatfield);
out_file.setf(std::ios::right, std::ios::adjustfield);
IMP::algebra::Vector3Ds lig_points;
IMP::saxs::get_coordinates(lig_particles_, lig_points);
for (unsigned int i = 0; i < fit_results_.size(); i++) {
out_file << fit_results_[i] << std::endl;
}
out_file.close();
if (fit_results_.size() == 1) { // output PDB
IMP::algebra::Transformation3D tr = fit_results_[0].get_map_trans();
IMP::Particles ps = rec_particles_;
ps.insert(ps.end(), lig_particles_.begin(), lig_particles_.end());
// transform
for (IMP::Particles::iterator it = ps.begin(); it != ps.end();
it++) {
IMP::core::XYZ d(*it);
d.set_coordinates(tr * d.get_coordinates());
}
// output
std::ofstream out_file2(out_pdb_file_name.c_str());
IMP::ParticlesTemp pst = ps;
IMP::atom::write_pdb(pst, out_file2);
out_file2.close();
}
}
示例4: out_file
bool Curves::plot_print_standard_residual(const char *path , double *standard_residual) const
{
bool status = false;
register int i;
ofstream out_file(path);
if (out_file) {
status = true;
// writing of observed responses and standardized residuals
for (i = 0;i < length;i++) {
if (frequency[i] > 0) {
out_file << i << " " << point[0][i];
if (standard_residual) {
out_file << " " << standard_residual[i];
}
out_file << " " << frequency[i] << endl;
}
}
}
return status;
}
示例5: file_init
static void
file_init(void)
{
int i; /* loop index */
/*
*
* Gets everything ready for the next input file.
*
*/
dwb_devname[0] = '\0';
res = 0;
hort = 1;
vert = 1;
font = 1;
size = 10;
nfonts = 0;
slant = 0;
height = 0;
for ( i = 0; i < NFONT; i++ )
fontname[i].name[0] = '\0';
pages = 0;
bytes = 0;
out_file(); /* set up the output file */
} /* End of file_init */
示例6: in_file
void ObjectWriter::CopyFile(std::string in, std::string out){
std::ifstream in_file(in.c_str(), std::fstream::binary);
std::ofstream out_file(out.c_str(), std::fstream::trunc|std::fstream::binary);
out_file << in_file.rdbuf();
in_file.close();
out_file.close();
}
示例7: main
int main()
{
// set_Progress_Bar_visibility(true);
std::ofstream out_file("data/Precision_Scan.txt", std::fstream::out);
out_file << "Tilde basis:" << std::endl;
out_file.close();
Verify::Precision_Scan(&Tilde::Palphabeta, 0, 1e-2);
Verify::Precision_Scan(&Tilde::Palphabeta, 1, 1e-2);
out_file.open("data/Precision_Scan.txt", std::fstream::app);
out_file << "Hat basis:" << std::endl;
out_file.close();
Verify::Precision_Scan(&Hat::Palphabeta, 0, 1e-2);
Verify::Precision_Scan(&Hat::Palphabeta, 0, 1e-3);
Verify::Precision_Scan(&Hat::Palphabeta, 1, 1e-2);
Verify::Precision_Scan(&Hat::Palphabeta, 1, 1e-3);
out_file.open("data/Precision_Scan.txt", std::fstream::app);
out_file << "Check basis (GF):" << std::endl;
out_file.close();
Verify::Precision_Scan(&GF::Palphabeta, 0, 1e-2);
Verify::Precision_Scan(&Check::Palphabeta, 0, 1e-2);
Verify::Precision_Scan(&GF::Palphabeta, 0, 1e-3);
Verify::Precision_Scan(&GF::Palphabeta, 1, 1e-3);
out_file.close();
return 0;
}
示例8: main
int main() {
// NOTE The rotation matrices below are in Yin Yang's convention (not mine!)
// Airship2IMU gives matrix such that v_Airship = Airship2IMU * v_IMU
double Airship2IMU_raw[] = { 0.280265845357, 0.0, 0.959922421827, 0.0, -1.0, 0.0, 0.959922421827, 0.0, -0.280265845357};
ReaK::rot_mat_3D<double> Airship2IMU(Airship2IMU_raw);
ReaK::quaternion<double> Airship2IMU_quat = ReaK::quaternion<double>(Airship2IMU);
ReaK::quaternion<double> IMU_orientation = Airship2IMU_quat;
ReaK::vect<double,3> IMU_location(-0.896665, 0.0, 0.25711);
// Room2Global gives matrix such that v_room = Room2Global * v_gbl
double Room2Global_raw[] = { 0.75298919442, -0.65759795928, 0.02392064034, -0.6577626482, -0.7532241836, -0.0012758604, 0.018856608, -0.0147733946, -0.9997130464};
ReaK::rot_mat_3D<double> Room2Global(Room2Global_raw);
ReaK::quaternion<double> Room2Global_quat = ReaK::quaternion<double>(Room2Global);
ReaK::quaternion<double> room_orientation = invert(Room2Global_quat);
ReaK::serialization::xml_oarchive out_file("airship3D_transforms.xml");
out_file & RK_SERIAL_SAVE_WITH_NAME(IMU_orientation)
& RK_SERIAL_SAVE_WITH_NAME(IMU_location)
& RK_SERIAL_SAVE_WITH_NAME(room_orientation);
return 0;
};
示例9: printTime2File
void printTime2File ( const double Time )
{
std::stringstream msg;
msg << "Total scope_life time= " << Time << " usecs" << std::endl;
File out_file( "times.log" );
out_file.write( msg.str( ).c_str( ) );
}
示例10: f
void LogSelectorForm::check_config(){
QString conf_path = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation).append("/config.json");
QFile f(conf_path);
if (!f.exists()){
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
QJsonValue algorithm("KMeans");
QJsonObject param = QJsonObject();
param.insert("n_clusters",4);
QJsonArray features;
features.append(QString("count_domain_with_numbers"));
features.append(QString("average_domain_length"));
features.append(QString("std_domain_length"));
features.append(QString("count_request"));
features.append(QString("average_requisition_degree"));
features.append(QString("std_requisition_degree"));
features.append(QString("minimum_requisition_degree"));
QJsonObject target = QJsonObject();
target.insert("algorithm",algorithm);
target.insert("features",features);
target.insert("param",param);
QJsonDocument config_out(target);
QFile out_file(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation).append("/config.json"));
out_file.open(QIODevice::WriteOnly | QIODevice::Text);
out_file.write(config_out.toJson());
out_file.close();
}
}
示例11: out_file
bool CompoundData::ascii_write(StatError &error , const string path ,
bool exhaustive) const
{
bool status = false;
if (compound) {
ofstream out_file(path.c_str());
error.init();
if (!out_file) {
status = false;
error.update(STAT_error[STATR_FILE_NAME]);
}
else {
status = true;
compound->ascii_write(out_file , this , exhaustive , true);
}
}
return status;
}
示例12: convert_matrices
void convert_matrices(const std::string &in, const std::string &out) {
std::ifstream in_file(in);
// TODO check if in file exists
std::ofstream out_file(out, std::ofstream::trunc);
std::string line;
int line_num = 0;
while (std::getline(in_file, line)) {
std::istringstream line_stream(line);
std::stringstream output_stream;
out_file << line_num << ' ';
++line_num;
bool c;
int c_num = 0;
int matches = 0;
while (line_stream >> c) {
if (c) {
++matches;
output_stream << ' ' << c_num;
}
++c_num;
}
// construct line
out_file << matches << output_stream.str() << std::endl;
}
in_file.close();
out_file.close();
}
示例13: SaveToFile
void SaveToFile(const FileEx &src_file, LONGLONG &ptr)
{
DWORD rw = 0;
BYTE buff[BLOCK_SIZE] = {0};
STATISTIC statistic;
TCHAR file_name[1024] = {0};
_stprintf_s(file_name, 1024, _T("%06I64d.txt"), ptr);
FileEx out_file(file_name);
if (const_cast<FileEx &>(src_file).SetPointer(ptr))
{
while (rw = const_cast<FileEx &>(src_file).Read(buff, BLOCK_SIZE))
{
AnalyzeBuffer(buff, rw, statistic);
if (IsPartOfTextFile(statistic) && out_file.Create())
{
if (statistic.ch_cnt < rw)
{
out_file.Write(buff, GetSequenceLength(buff, rw));
break;
}
else
out_file.Write(buff, rw);
}
else return;
}
}
}
示例14: write_half_exr
void write_half_exr( const boost::filesystem::path& p, Imf::Header& header,
const image::const_image_view_t& view, bool write_alpha)
{
boost::gil::rgba16f_image_t img( view.width(), view.height());
boost::gil::copy_and_convert_pixels( view, boost::gil::view( img));
header.channels().insert( "R", Imf::HALF);
header.channels().insert( "G", Imf::HALF);
header.channels().insert( "B", Imf::HALF);
if( write_alpha)
header.channels().insert( "A", Imf::HALF);
Imf::FrameBuffer frameBuffer;
char *ptr = (char *) boost::gil::interleaved_view_get_raw_data( boost::gil::view( img));
std::size_t xstride = 4 * sizeof(half);
std::size_t ystride = xstride * img.width();
frameBuffer.insert( "R", Imf::Slice( Imf::HALF, ptr, xstride, ystride)); ptr += sizeof(half);
frameBuffer.insert( "G", Imf::Slice( Imf::HALF, ptr, xstride, ystride)); ptr += sizeof(half);
frameBuffer.insert( "B", Imf::Slice( Imf::HALF, ptr, xstride, ystride)); ptr += sizeof(half);
if( write_alpha)
frameBuffer.insert( "A", Imf::Slice( Imf::HALF, ptr, xstride, ystride));
Imf::OutputFile out_file( p.external_file_string().c_str(), header);
out_file.setFrameBuffer( frameBuffer);
out_file.writePixels( img.height());
}
示例15: out_file
// Saves Solver input (.sif) file.
void
Control::saveSolverInputFile(char* out_filename)
{
ofstream out_file(out_filename, ios::out);
if ( !write_ok(out_file, out_filename, "(Writing ELMER Solver input file)") )
return;
#if defined(FRONT_DEBUG)
theModel->saveSolverInputFile(out_file, out_filename);
#else
try
{
theModel->saveSolverInputFile(out_file, out_filename);
}
catch (...)
{
theUI->showMsg("ERROR: Unable to save Solver input file (sif-file)!");
}
#endif
out_file.close();
}