25#include "rheolef/asr.h"
26#include "rheolef/csr.h"
27#include "rheolef/iorheo.h"
28#include "rheolef/mm_io.h"
35template<
class T,
class M,
class A>
41 ext_ia = a.ext_begin();
42 size_type first_dis_i = a.row_ownership().first_index();
43 size_type first_dis_j = a.col_ownership().first_index();
44 for (
size_type i = 0, n = a.nrow(); i < n; i++) {
46 size_type dis_j = first_dis_j + (*p).first;
47 const T& value = (*p).second;
53 size_type dis_j = a.jext2dis_j ((*p).first);
54 const T& value = (*p).second;
63template <
class T,
class M,
class A>
70 last = base::end(); iter != last; ++iter) {
71 _nnz += (*iter).size();
74#ifdef _RHEOLEF_HAVE_MPI
83template <
class T,
class M,
class A>
87 std::ostream& os = ods.
os();
88 std::string name = iorheo::getbasename(ods.
os());
89 if (name ==
"") name =
"a";
90 os << std::setprecision (std::numeric_limits<T>::digits10)
91 << name <<
" = spalloc(" <<
nrow() <<
"," <<
ncol() <<
"," <<
nnz() <<
");" << std::endl;
92 if (
_nnz == 0)
return ods;
96 last = base::end(); iter != last; ++iter, ++i) {
99 row_iter = row.begin(),
100 row_last = row.end(); row_iter != row_last; ++row_iter) {
101 os << name <<
"(" << first_dis_i+i+1 <<
","
102 << (*row_iter).first+1 <<
") = "
103 << (*row_iter).second <<
";" << std::endl;
108template <
class T,
class M,
class A>
112 std::ostream& os = ods.
os();
113 os << std::setprecision(std::numeric_limits<T>::digits10)
114 <<
"%%MatrixMarket matrix coordinate real general" << std::endl
115 <<
nrow() <<
" " <<
ncol() <<
" " <<
nnz() << std::endl;
116 if (
_nnz == 0)
return ods;
119 iter = base::begin(),
120 last = base::end(); iter != last; ++iter, ++i) {
123 row_iter = row.begin(),
124 row_last = row.end(); row_iter != row_last; ++row_iter) {
125 os << first_dis_i+i+1 <<
" "
126 << (*row_iter).first+1 <<
" "
127 << (*row_iter).second << std::endl;
132template <
class T,
class M,
class A>
142template <
class T,
class M,
class A>
151 asr<T> a (io_row_ownership, io_col_ownership);
155 iter = base::begin(),
156 last = base::end(); iter != last; ++iter, ++i) {
159 row_iter = row.begin(),
160 row_last = row.end(); row_iter != row_last; ++row_iter) {
161 a.dis_entry (first_dis_i + i, (*row_iter).first) += (*row_iter).second;
164 a.dis_entry_assembly();
165 if (my_proc == io_proc) {
171template <
class T,
class M,
class A>
181template <
class T,
class M,
class A>
201 std::istream& is = ips.
is();
205 is >> dis_i >> dis_j >> value;
223#define _RHEOLEF_instanciation(T,M,A) \
224template class asr<T,M,A>;
227#ifdef _RHEOLEF_HAVE_MPI
#define _RHEOLEF_instanciation(T, M, A)
see the communicator page for the full documentation
size_type dis_nnz() const
T & semi_dis_entry(size_type i, size_type dis_j)
void dis_entry_assembly()
odiststream & put_seq_sparse_matlab(odiststream &ops, size_type first_dis_i=0) const
idiststream & get(idiststream &ips)
pair_set< T, A > row_type
const distributor & col_ownership() const
size_type dis_ncol() const
odiststream & put_mpi(odiststream &ops) const
odiststream & put(odiststream &ops) const
base::size_type size_type
void build_from_csr(const csr_rep< T, M > &)
dis_reference dis_entry(size_type dis_i, size_type dis_j)
const distributor & row_ownership() const
odiststream & put_seq(odiststream &ops, size_type first_dis_i=0) const
void resize(const distributor &row_ownership, const distributor &col_ownership)
odiststream & put_seq_matrix_market(odiststream &ops, size_type first_dis_i=0) const
size_type dis_nrow() const
const communicator & comm() const
see the csr page for the full documentation
rep::base::const_iterator const_iterator
see the distributor page for the full documentation
static const size_type decide
idiststream: see the diststream page for the full documentation
static size_type io_proc()
This routine returns the rank of a process that can perform i/o.
const communicator & comm() const
std::bitset< last > flag_type
static flag_type flags(std::ios &s)
static flag_type format_field
odiststream: see the diststream page for the full documentation
static size_type io_proc()
base::const_iterator const_iterator
double Float
see the Float page for the full documentation
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
This file is part of Rheolef.
struct matrix_market read_matrix_market_header(idiststream &ips)
static const format_type general
static const format_type symmetric
static const format_type skew_symmetric
static const format_type hermitian