23#include "arccore/alina/AlinaUtils.h"
24#include "arccore/alina/ValueTypeComplex.h"
25#include "arccore/alina/IO.h"
27#include "arccore/common/internal/ProgramOptions.h"
30namespace io = Alina::IO;
31namespace po = Arcane::ProgramOptions;
32using Alina::precondition;
38 std::ofstream f(ofile, std::ios::binary);
39 precondition(f,
"Failed to open output file for writing.");
43 std::vector<ptrdiff_t> ptr, col;
46 std::tie(rows, cols) = ifile(ptr, col, val);
48 precondition(io::write(f, rows),
"File I/O error.");
49 precondition(io::write(f, ptr),
"File I/O error.");
50 precondition(io::write(f, col),
"File I/O error.");
51 precondition(io::write(f, val),
"File I/O error.");
54 <<
"Wrote " << rows <<
" by " << cols <<
" sparse matrix, "
55 << ptr.back() <<
" nonzeros" << std::endl;
61 std::tie(rows, cols) = ifile(val);
63 precondition(io::write(f, rows),
"File I/O error.");
64 precondition(io::write(f, cols),
"File I/O error.");
65 precondition(io::write(f, val),
"File I/O error.");
68 <<
"Wrote " << rows <<
" by " << cols <<
" dense matrix"
74int main(
int argc,
char* argv[])
78 desc.add_options()(
"help,h",
"Show this help.")(
"input,i", po::value<std::string>()->required(),
79 "Input matrix in the MatrixMarket format.")(
"output,o", po::value<std::string>()->required(),
80 "Output binary file.");
83 po::store(po::parse_command_line(argc, argv, desc), vm);
85 if (vm.count(
"help")) {
86 std::cout << desc << std::endl;
92 io::mm_reader read(vm[
"input"].as<std::string>());
93 precondition(!read.is_integer(),
"Integer matrices are not supported!");
95 if (read.is_complex()) {
96 convert<std::complex<double>>(read, vm[
"output"].as<std::string>());
99 convert<double>(read, vm[
"output"].as<std::string>());
bool is_sparse() const
Matrix in the file is sparse.
Describes a set of command-line options.
Stores parsed option values.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --