22#include <boost/program_options.hpp>
23#include "arccore/alina/AlinaUtils.h"
24#include "arccore/alina/Adapters.h"
25#include "arccore/alina/IO.h"
27int main(
int argc,
char* argv[])
29 namespace po = boost::program_options;
30 namespace io = Arcane::Alina::IO;
32 using Arcane::Alina::precondition;
34 po::options_description desc(
"Options");
36 desc.add_options()(
"help,h",
"Show this help.")(
"dense,d", po::bool_switch()->default_value(
false),
37 "Matrix is dense.")(
"input,i", po::value<std::string>()->required(),
38 "Input binary file.")(
"output,o", po::value<std::string>()->required(),
39 "Ouput matrix in the MatrixMarket format.");
42 po::store(po::parse_command_line(argc, argv, desc), vm);
44 if (vm.count(
"help")) {
45 std::cout << desc << std::endl;
51 if (vm[
"dense"].as<bool>()) {
53 std::vector<double> v;
55 io::read_dense(vm[
"input"].as<std::string>(), n, m, v);
56 io::mm_write(vm[
"output"].as<std::string>(), v.data(), n, m);
59 <<
"Wrote " << n <<
" by " << m <<
" dense matrix"
64 std::vector<ptrdiff_t> ptr, col;
65 std::vector<double> val;
67 io::read_crs(vm[
"input"].as<std::string>(), n, ptr, col, val);
68 io::mm_write(vm[
"output"].as<std::string>(), std::tie(n, ptr, col, val));
71 <<
"Wrote " << n <<
" by " << n <<
" sparse matrix, "
72 << ptr.back() <<
" nonzeros" << std::endl;