Rheolef  7.1
an efficient C++ finite element environment
csr.h
Go to the documentation of this file.
1 # ifndef _RHEOLEF_CSR_H
2 # define _RHEOLEF_CSR_H
3 //
4 // This file is part of Rheolef.
5 //
6 // Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7 //
8 // Rheolef is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // Rheolef is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Rheolef; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //
22 // =========================================================================
23 // AUTHORS: Pierre.Saramito@imag.fr
24 // DATE: 10 february 1999
25 
26 namespace rheolef {
68 } // namespace rheolef
69 
70 #include "rheolef/vec.h"
71 #include "rheolef/asr.h"
72 #include "rheolef/vector_of_iterator.h"
73 #include "rheolef/scatter_message.h"
74 #include "rheolef/pair_util.h"
75 
76 namespace rheolef {
77 
78 // -------------------------------------------------------------
79 // the sequential representation
80 // -------------------------------------------------------------
81 template<class T, class M> class csr_rep {};
82 
83 template<class T>
84 class csr_rep<T,sequential> : public vector_of_iterator<std::pair<typename std::vector<T>::size_type,T> > {
85 public:
87  typedef T element_type;
89  typedef typename std::pair<size_type,T> pair_type;
95 
96  csr_rep (size_type loc_nrow1 = 0, size_type loc_ncol1 = 0, size_type loc_nnz1 = 0);
97  void resize (size_type loc_nrow1 = 0, size_type loc_ncol1 = 0, size_type loc_nnz1 = 0);
98  csr_rep (const distributor& row_ownership, const distributor& col_ownership, size_type nnz1 = 0);
99  void resize (const distributor& row_ownership, const distributor& col_ownership, size_type nnz1 = 0);
101  template<class A> void build_from_asr (const asr<T,sequential,A>& a);
102  template<class A> explicit csr_rep (const asr<T,sequential,A>& a);
103  template<class A> void build_from_diag (const disarray_rep<T,sequential,A>& d);
104 
105  const distributor& row_ownership() const { return _row_ownership; }
106  const distributor& col_ownership() const { return _col_ownership; }
112  size_type ncol() const { return _col_ownership.size(); }
113  size_type nnz() const { return _data.size(); }
114  size_type dis_nrow() const { return nrow(); }
115  size_type dis_ncol() const { return ncol(); }
116  size_type dis_nnz() const { return nnz(); }
117  T max_abs () const;
118  bool is_symmetric() const { return _is_symmetric; }
119  void set_symmetry (bool is_symm) const { _is_symmetric = is_symm; }
120  void set_symmetry_by_check (const T& tol = std::numeric_limits<T>::epsilon()) const;
121  bool is_definite_positive() const { return _is_definite_positive; }
122  void set_definite_positive (bool is_defpos) const { _is_definite_positive = is_defpos; }
123  size_type pattern_dimension() const { return _pattern_dimension; }
124  void set_pattern_dimension(size_type dim) const { _pattern_dimension = dim; }
125  size_type row_first_index () const { return 0; }
126  size_type row_last_index () const { return nrow(); }
127  size_type col_first_index () const { return 0; }
128  size_type col_last_index () const { return ncol(); }
129  idiststream& get (idiststream&);
130  odiststream& put (odiststream&, size_type istart = 0) const;
131  odiststream& put_matrix_market (odiststream&, size_type istart = 0) const;
132  odiststream& put_sparse_matlab (odiststream&, size_type istart = 0) const;
133  void dump (const std::string& name, size_type istart = 0) const;
134  void mult (const vec<T,sequential>& x, vec<T,sequential>& y) const;
135  void trans_mult (const vec<T,sequential>& x, vec<T,sequential>& y) const;
137  template <class BinaryOp>
138  void assign_add (const csr_rep<T,sequential>& a, const csr_rep<T,sequential>& b, BinaryOp binop);
139  void build_transpose (csr_rep<T,sequential>& b) const;
140  void assign_mult (const csr_rep<T,sequential>& a, const csr_rep<T,sequential>& b);
141 
142  // accessors, only for distributed (for interface compatibility)
143  size_type ext_nnz() const { return 0; }
144  size_type dis_ext_nnz() const { return 0; }
146  const_iterator ext_end() const { return const_iterator(); }
147  size_type jext2dis_j (size_type jext) const { return 0; }
148 
149 //protected:
153  mutable bool _is_symmetric;
154  mutable bool _is_definite_positive;
155  mutable size_type _pattern_dimension; // e.g. FEM 3d-pattern
156 };
157 template<class T>
158 template<class A>
159 inline
161  : vector_of_iterator<pair_type>(a.nrow()+1),
162  _row_ownership (a.row_ownership()),
163  _col_ownership (a.col_ownership()),
164  _data(a.nnz()),
165  _is_symmetric(false),
166  _is_definite_positive(false),
167  _pattern_dimension(0)
168 {
169  build_from_asr (a);
170 }
171 template<class T>
172 inline
173 idiststream&
174 csr_rep<T,sequential>::get (idiststream& ids)
175 {
176  typedef std::allocator<T> A; // TODO: use heap_allocator for asr
178  a.get(ids);
179  build_from_asr (a);
180  return ids;
181 }
182 // -------------------------------------------------------------
183 // the distributed representation
184 // -------------------------------------------------------------
185 #ifdef _RHEOLEF_HAVE_MPI
186 template<class T>
187 class csr_rep<T,distributed> : public csr_rep<T,sequential> {
188 public:
191  typedef typename base::size_type size_type;
193  typedef typename base::iterator iterator;
197 
198  csr_rep ();
200  template<class A> explicit csr_rep (const asr<T,distributed,A>& a);
201  template<class A> void build_from_asr (const asr<T,distributed,A>& a);
202  void resize (const distributor& row_ownership, const distributor& col_ownership, size_type nnz1 = 0);
203  template<class A> void build_from_diag (const disarray_rep<T,distributed,A>& d);
204 
205  const distributor& row_ownership() const { return base::_row_ownership; }
206  const distributor& col_ownership() const { return base::_col_ownership; }
207  const communicator& comm() const { return row_ownership().comm(); }
208  const_iterator begin() const { return base::begin(); }
209  const_iterator end() const { return base::end(); }
210  iterator begin() { return base::begin(); }
211  iterator end() { return base::end(); }
212  size_type ext_nnz() const { return _ext.nnz(); }
213  const_iterator ext_begin() const { return _ext.begin(); }
214  const_iterator ext_end() const { return _ext.end(); }
215  iterator ext_begin() { return _ext.begin(); }
216  iterator ext_end() { return _ext.end(); }
217  size_type nrow() const { return base::nrow(); }
218  size_type ncol() const { return base::ncol(); }
219  size_type nnz() const { return base::nnz(); }
220  size_type dis_nrow() const { return row_ownership().dis_size(); }
221  size_type dis_ncol() const { return col_ownership().dis_size(); }
222  size_type dis_nnz() const { return _dis_nnz; }
223  size_type dis_ext_nnz() const { return _dis_ext_nnz; }
224  T max_abs () const;
225  bool is_symmetric() const { return base::is_symmetric(); }
226  void set_symmetry (bool is_symm) const { base::set_symmetry(is_symm); }
227  void set_symmetry_by_check (const T& tol = std::numeric_limits<T>::epsilon()) const;
228  bool is_definite_positive() const { return base::is_definite_positive(); }
229  void set_definite_positive (bool is_defpos) const { base::set_definite_positive(is_defpos); }
230  size_type pattern_dimension() const { return base::pattern_dimension(); }
231  void set_pattern_dimension(size_type dim) const { base::set_pattern_dimension(dim); }
232  size_type row_first_index () const { return row_ownership().first_index(); }
233  size_type row_last_index () const { return row_ownership().last_index(); }
234  size_type col_first_index () const { return col_ownership().first_index(); }
235  size_type col_last_index () const { return col_ownership().last_index(); }
236  size_type jext2dis_j (size_type jext) const;
237  idiststream& get (idiststream&);
238  odiststream& put (odiststream&) const;
239  void dump (const std::string& name) const;
240  void mult (const vec<T,distributed>& x, vec<T,distributed>& y) const;
241  void trans_mult (const vec<T,distributed>& x, vec<T,distributed>& y) const;
243  template <class BinaryOp>
244  void assign_add (const csr_rep<T,distributed>& a, const csr_rep<T,distributed>& b, BinaryOp binop);
245  void build_transpose (csr_rep<T,distributed>& b) const;
246  void assign_mult (const csr_rep<T,distributed>& a, const csr_rep<T,distributed>& b);
247 protected:
248 // data:
249  // diagonal part is the basic csr_rep<seq> type
250  // extra-diagonal blocs are sequential csr also:
252  std::vector<size_type> _jext2dis_j;
255 
256  // A*x internal stuff: scatter and buffer (lazy initialization):
257  mutable bool _scatter_initialized;
260  mutable std::vector<T> _buffer;
261 // internal:
262  void _scatter_init() const;
263  void _scatter_init_guard() const {
264  if (_scatter_initialized) return;
265  _scatter_initialized = true;
266  _scatter_init();
267  }
268 };
269 template<class T>
270 inline
273 {
274  check_macro (jext < _jext2dis_j.size(), "jext2dis_j: jext="<<jext<<" is out of range [0:"<<_jext2dis_j.size()<<"[");
275  return _jext2dis_j [jext];
276 }
277 template<class T>
278 template<class A>
279 inline
281  : csr_rep<T,sequential>(),
282  _ext (),
283  _jext2dis_j(),
284  _dis_nnz(0),
285  _dis_ext_nnz(0),
286  _scatter_initialized(false),
287  _from(),
288  _to(),
289  _buffer()
290 {
291  build_from_asr (a);
292 }
293 template<class T>
294 inline
295 idiststream&
296 csr_rep<T,distributed>::get (idiststream& ips)
297 {
298  typedef std::allocator<T> A; // TODO: use heap_alloc for asr
300  a.get (ips);
301  build_from_asr (a);
302  return ips;
303 }
304 #endif // _RHEOLEF_HAVE_MPI
305 
306 namespace details {
307 // these classes are used for allocator from the std::initializer_list
308 template <class T, class M> class csr_concat_value;
309 template <class T, class M> class csr_concat_line;
310 } // namespace details
311 
312 // -------------------------------------------------------------
313 // the basic class with a smart pointer to representation
314 // the user-level class with memory-model parameter
315 // -------------------------------------------------------------
316 template <class T, class M = rheo_default_memory_model>
317 class csr {
318 public:
319  typedef M memory_type;
320 };
321 // [verbatim_csr]
322 template<class T>
323 class csr<T,sequential> : public smart_pointer<csr_rep<T,sequential> > {
324 public:
325 
326 // typedefs:
327 
330  typedef typename rep::memory_type memory_type;
331  typedef typename rep::size_type size_type;
332  typedef typename rep::element_type element_type;
333  typedef typename rep::iterator iterator;
337 
338 // allocators/deallocators:
339 
340  csr() : base(new_macro(rep())) {}
341  template<class A>
342  explicit csr(const asr<T,sequential,A>& a) : base(new_macro(rep(a))) {}
343  void resize (size_type loc_nrow1 = 0, size_type loc_ncol1 = 0, size_type loc_nnz1 = 0)
344  { base::data().resize(loc_nrow1, loc_ncol1, loc_nnz1); }
345  void resize (const distributor& row_ownership, const distributor& col_ownership, size_type nnz1 = 0)
346  { base::data().resize(row_ownership, col_ownership, nnz1); }
347 
348 // allocators from initializer list
349 
350  csr (const std::initializer_list<details::csr_concat_value<T,sequential> >& init_list);
351  csr (const std::initializer_list<details::csr_concat_line<T,sequential> >& init_list);
352 
353 // accessors:
354 
355  // global sizes
356  const distributor& row_ownership() const { return base::data().row_ownership(); }
357  const distributor& col_ownership() const { return base::data().col_ownership(); }
358  size_type dis_nrow () const { return row_ownership().dis_size(); }
359  size_type dis_ncol () const { return col_ownership().dis_size(); }
360  size_type dis_nnz () const { return base::data().nnz(); }
361  size_type dis_ext_nnz () const { return 0; }
362  bool is_symmetric() const { return base::data().is_symmetric(); }
363  void set_symmetry (bool is_symm) const { base::data().set_symmetry(is_symm); }
365  { base::data().set_symmetry_by_check(); }
366  bool is_definite_positive() const { return base::data().is_definite_positive(); }
367  void set_definite_positive (bool is_defpos) const { base::data().set_definite_positive(is_defpos); }
368  size_type pattern_dimension() const { return base::data().pattern_dimension(); }
369  void set_pattern_dimension(size_type dim) const { base::data().set_pattern_dimension(dim); }
370  T max_abs () const { return base::data().max_abs(); }
371 
372  // local sizes
373  size_type nrow () const { return base::data().nrow(); }
374  size_type ncol () const { return base::data().ncol(); }
375  size_type nnz () const { return base::data().nnz(); }
376 
377  // range on local memory
378  size_type row_first_index () const { return base::data().row_first_index(); }
379  size_type row_last_index () const { return base::data().row_last_index(); }
380  size_type col_first_index () const { return base::data().col_first_index(); }
381  size_type col_last_index () const { return base::data().col_last_index(); }
382 
383  const_iterator begin() const { return base::data().begin(); }
384  const_iterator end() const { return base::data().end(); }
385  iterator begin_nonconst() { return base::data().begin(); }
386  iterator end_nonconst() { return base::data().end(); }
387 
388  // accessors, only for distributed (for interface compatibility)
389  size_type ext_nnz() const { return 0; }
391  const_iterator ext_end() const { return const_iterator(); }
394  size_type jext2dis_j (size_type jext) const { return 0; }
395 
397 
398 // algebra:
399 
400  // y := a*x
402  base::data().mult (x,y);
403  }
405  vec<element_type,sequential> y (row_ownership(), element_type());
406  mult (x, y);
407  return y;
408  }
410  base::data().trans_mult (x,y);
411  }
413  vec<element_type,sequential> y (col_ownership(), element_type());
414  trans_mult (x, y);
415  return y;
416  }
417  // a+b, a-b, a*b
421 
422  // lambda*a
424  base::data().operator*= (lambda);
425  return *this;
426  }
427 // output:
428 
429  void dump (const std::string& name) const { base::data().dump(name); }
430 };
431 // [verbatim_csr]
432 
433 // lambda*a
434 template<class T>
435 inline
436 csr<T,sequential>
438 {
440  b.operator*= (lambda);
441  return b;
442 }
443 // -a
444 template<class T>
445 inline
446 csr<T,sequential>
448 {
449  return T(-1)*a;
450 }
452 template<class T>
453 inline
454 csr<T,sequential>
456 {
458  a.data().build_transpose (b.data());
459  return b;
460 }
461 //>verbatim:
462 
463 #ifdef _RHEOLEF_HAVE_MPI
464 //<verbatim:
465 template<class T>
466 class csr<T,distributed> : public smart_pointer<csr_rep<T,distributed> > {
467 public:
468 
469 // typedefs:
470 
473  typedef typename rep::memory_type memory_type;
474  typedef typename rep::size_type size_type;
475  typedef typename rep::element_type element_type;
476  typedef typename rep::iterator iterator;
480 
481 // allocators/deallocators:
482 
483  csr() : base(new_macro(rep())) {}
484  template<class A>
485  explicit csr(const asr<T,memory_type,A>& a) : base(new_macro(rep(a))) {}
486  void resize (const distributor& row_ownership, const distributor& col_ownership, size_type nnz1 = 0)
487  { base::data().resize(row_ownership, col_ownership, nnz1); }
488 
489 // allocators from initializer list (c++ 2011):
490 
491  csr (const std::initializer_list<details::csr_concat_value<T,distributed> >& init_list);
492  csr (const std::initializer_list<details::csr_concat_line<T,distributed> >& init_list);
493 
494 // accessors:
495 
496  // global sizes
497  const distributor& row_ownership() const { return base::data().row_ownership(); }
498  const distributor& col_ownership() const { return base::data().col_ownership(); }
499  size_type dis_nrow () const { return row_ownership().dis_size(); }
500  size_type dis_ncol () const { return col_ownership().dis_size(); }
501  size_type dis_nnz () const { return base::data().dis_nnz(); }
502  size_type dis_ext_nnz () const { return base::data().dis_ext_nnz(); }
503  bool is_symmetric() const { return base::data().is_symmetric(); }
504  void set_symmetry (bool is_symm) const { base::data().set_symmetry(is_symm); }
506  { base::data().set_symmetry_by_check(); }
507  bool is_definite_positive() const { return base::data().is_definite_positive(); }
508  void set_definite_positive (bool is_defpos) const { base::data().set_definite_positive(is_defpos); }
509  size_type pattern_dimension() const { return base::data().pattern_dimension(); }
510  void set_pattern_dimension(size_type dim) const { base::data().set_pattern_dimension(dim); }
511  T max_abs () const { return base::data().max_abs(); }
512 
513  // local sizes
514  size_type nrow () const { return base::data().nrow(); }
515  size_type ncol () const { return base::data().ncol(); }
516  size_type nnz () const { return base::data().nnz(); }
517 
518  // range on local memory
519  size_type row_first_index () const { return base::data().row_first_index(); }
520  size_type row_last_index () const { return base::data().row_last_index(); }
521  size_type col_first_index () const { return base::data().col_first_index(); }
522  size_type col_last_index () const { return base::data().col_last_index(); }
523 
524  const_iterator begin() const { return base::data().begin(); }
525  const_iterator end() const { return base::data().end(); }
526  iterator begin_nonconst() { return base::data().begin(); }
527  iterator end_nonconst() { return base::data().end(); }
528 
529  // accessors, only for distributed
530  size_type ext_nnz() const { return base::data().ext_nnz(); }
531  const_iterator ext_begin() const { return base::data().ext_begin(); }
532  const_iterator ext_end() const { return base::data().ext_end(); }
533  iterator ext_begin_nonconst() { return base::data().ext_begin(); }
534  iterator ext_end_nonconst() { return base::data().ext_end(); }
535  size_type jext2dis_j (size_type jext) const { return base::data().jext2dis_j(jext); }
536 
538 
539 // algebra:
540 
541  // y := a*x
543  base::data().mult (x,y);
544  }
546  vec<element_type,distributed> y (row_ownership(), element_type());
547  mult (x, y);
548  return y;
549  }
551  base::data().trans_mult (x,y);
552  }
554  vec<element_type,distributed> y (col_ownership(), element_type());
555  trans_mult (x, y);
556  return y;
557  }
558  // a+b, a-b, a*b
562 
563  // lambda*a
565  base::data().operator*= (lambda);
566  return *this;
567  }
568 // output:
569 
570  void dump (const std::string& name) const { base::data().dump(name); }
571 };
572 // lambda*a
573 template<class T>
574 inline
575 csr<T,distributed>
577 {
579  b.operator*= (lambda);
580  return b;
581 }
582 // -a
583 template<class T>
584 inline
585 csr<T,distributed>
587 {
588  return T(-1)*a;
589 }
590 // trans(a)
591 template<class T>
592 inline
593 csr<T,distributed>
595 {
597  a.data().build_transpose (b.data());
598  return b;
599 }
600 #endif // _RHEOLEF_HAVE_MPI
601 
602 // b = f(a); f as a class-function or usual fct
603 template<class T, class M, class Function>
604 csr<T,M>
606 {
607  csr<T,M> b = a;
608  typename csr<T,M>::size_type n = a.nrow();
609  typename csr<T,M>::const_iterator dia_ia = a.begin();
610  typename csr<T,M>::iterator dia_ib = b.begin_nonconst();
611  pair_transform_second (dia_ia[0], dia_ia[n], dia_ib[0], f);
612  if (a.ext_nnz() != 0) {
613  typename csr<T,M>::const_iterator ext_ia = a.ext_begin();
614  typename csr<T,M>::iterator ext_ib = b.ext_begin_nonconst();
615  pair_transform_second (ext_ia[0], ext_ia[n], ext_ib[0], f);
616  }
617  return b;
618 }
619 template<class T, class M, class Function>
620 csr<T,M>
621 csr_apply (T (*f)(const T&), const csr<T,M>& a)
622 {
623  return csr_apply (std::ptr_fun(f), a);
624 }
625 //>verbatim:
626 
627 template<class T, class M>
628 csr<T,M>
629 diag (const vec<T,M>&);
630 
631 // ------------------------------
632 // i/o
633 // ------------------------------
634 template <class T, class M>
635 inline
636 idiststream&
637 operator >> (idiststream& s, csr<T,M>& x)
638 {
639  return x.data().get(s);
640 }
641 template <class T, class M>
642 inline
644 operator << (odiststream& s, const csr<T,M>& x)
645 {
646  return x.data().put(s);
647 }
648 // ------------------------------
649 // a+b, a-b
650 // ------------------------------
651 template <class T>
652 inline
653 csr<T,sequential>
656  c.data().assign_add (this->data(), b.data(), std::plus<T>());
657  return c;
658 }
659 template <class T>
660 inline
664  c.data().assign_add (this->data(), b.data(), std::minus<T>());
665  return c;
666 }
667 #ifdef _RHEOLEF_HAVE_MPI
668 template <class T>
669 inline
673  c.data().assign_add (this->data(), b.data(), std::plus<T>());
674  return c;
675 }
676 template <class T>
677 inline
681  c.data().assign_add (this->data(), b.data(), std::minus<T>());
682  return c;
683 }
684 #endif // _RHEOLEF_HAVE_MPI
685 
686 // ------------------------------
687 // a*b
688 // ------------------------------
689 template <class T>
690 inline
694  c.data().assign_mult (this->data(), b.data());
695  return c;
696 }
697 #ifdef _RHEOLEF_HAVE_MPI
698 template <class T>
699 inline
703  c.data().assign_mult (this->data(), b.data());
704  return c;
705 }
706 #endif // _RHEOLEF_HAVE_MPI
707 
708 // ------------------------------
709 // a.max_abs
710 // ------------------------------
711 template <class T>
712 inline
713 T
715 {
716  T val = 0;
717  typename csr<T,sequential>::const_iterator ia = begin();
718  for (typename csr_rep<T,sequential>::const_data_iterator iter = ia[0], last = ia[nrow()]; iter != last; ++iter) {
719  val = std::max (val, abs((*iter).second));
720  }
721  return val;
722 }
723 #ifdef _RHEOLEF_HAVE_MPI
724 template <class T>
725 inline
726 T
728 {
730  val = mpi::all_reduce (comm(), val, mpi::maximum<T>());
731  return val;
732 }
733 #endif // _RHEOLEF_HAVE_MPI
734 
735 } // namespace rheolef
736 # endif // _RHEOLEF_CSR_H
field::size_type size_type
Definition: branch.cc:425
size_type dis_nnz() const
Definition: csr.h:501
rep::const_data_iterator const_data_iterator
Definition: csr.h:479
rep::element_type element_type
Definition: csr.h:475
size_type jext2dis_j(size_type jext) const
Definition: csr.h:535
void resize(const distributor &row_ownership, const distributor &col_ownership, size_type nnz1=0)
Definition: csr.h:486
rep::const_iterator const_iterator
Definition: csr.h:477
void mult(const vec< element_type, distributed > &x, vec< element_type, distributed > &y) const
Definition: csr.h:542
size_type row_last_index() const
Definition: csr.h:520
const_iterator begin() const
Definition: csr.h:524
size_type pattern_dimension() const
Definition: csr.h:509
void trans_mult(const vec< element_type, distributed > &x, vec< element_type, distributed > &y) const
Definition: csr.h:550
bool is_definite_positive() const
Definition: csr.h:507
size_type col_last_index() const
Definition: csr.h:522
void set_pattern_dimension(size_type dim) const
Definition: csr.h:510
csr_rep< T, distributed > rep
Definition: csr.h:471
iterator ext_begin_nonconst()
Definition: csr.h:533
const distributor & col_ownership() const
Definition: csr.h:498
iterator ext_end_nonconst()
Definition: csr.h:534
const_iterator ext_end() const
Definition: csr.h:532
size_type dis_ncol() const
Definition: csr.h:500
void set_symmetry(bool is_symm) const
Definition: csr.h:504
void set_symmetry_by_check(const T &tol=std::numeric_limits< T >::epsilon()) const
Definition: csr.h:505
size_type nrow() const
Definition: csr.h:514
iterator begin_nonconst()
Definition: csr.h:526
vec< element_type, distributed > trans_mult(const vec< element_type, distributed > &x) const
Definition: csr.h:553
size_type ext_nnz() const
Definition: csr.h:530
rep::iterator iterator
Definition: csr.h:476
size_type ncol() const
Definition: csr.h:515
smart_pointer< rep > base
Definition: csr.h:472
bool is_symmetric() const
Definition: csr.h:503
csr(const std::initializer_list< details::csr_concat_line< T, distributed > > &init_list)
csr(const std::initializer_list< details::csr_concat_value< T, distributed > > &init_list)
size_type row_first_index() const
Definition: csr.h:519
size_type dis_ext_nnz() const
Definition: csr.h:502
const distributor & row_ownership() const
Definition: csr.h:497
rep::memory_type memory_type
Definition: csr.h:473
void set_definite_positive(bool is_defpos) const
Definition: csr.h:508
rep::size_type size_type
Definition: csr.h:474
const_iterator end() const
Definition: csr.h:525
csr(const asr< T, memory_type, A > &a)
Definition: csr.h:485
size_type nnz() const
Definition: csr.h:516
rep::data_iterator data_iterator
Definition: csr.h:478
size_type col_first_index() const
Definition: csr.h:521
size_type dis_nrow() const
Definition: csr.h:499
const_iterator ext_begin() const
Definition: csr.h:531
void dump(const std::string &name) const
Definition: csr.h:570
size_type dis_nnz() const
Definition: csr.h:360
rep::const_data_iterator const_data_iterator
Definition: csr.h:336
rep::element_type element_type
Definition: csr.h:332
size_type jext2dis_j(size_type jext) const
Definition: csr.h:394
void resize(const distributor &row_ownership, const distributor &col_ownership, size_type nnz1=0)
Definition: csr.h:345
rep::const_iterator const_iterator
Definition: csr.h:334
void resize(size_type loc_nrow1=0, size_type loc_ncol1=0, size_type loc_nnz1=0)
Definition: csr.h:343
size_type row_last_index() const
Definition: csr.h:379
const_iterator begin() const
Definition: csr.h:383
size_type pattern_dimension() const
Definition: csr.h:368
bool is_definite_positive() const
Definition: csr.h:366
size_type col_last_index() const
Definition: csr.h:381
void mult(const vec< element_type, sequential > &x, vec< element_type, sequential > &y) const
Definition: csr.h:401
void set_pattern_dimension(size_type dim) const
Definition: csr.h:369
iterator ext_begin_nonconst()
Definition: csr.h:392
const distributor & col_ownership() const
Definition: csr.h:357
csr(const std::initializer_list< details::csr_concat_line< T, sequential > > &init_list)
iterator ext_end_nonconst()
Definition: csr.h:393
const_iterator ext_end() const
Definition: csr.h:391
size_type dis_ncol() const
Definition: csr.h:359
void set_symmetry(bool is_symm) const
Definition: csr.h:363
void set_symmetry_by_check(const T &tol=std::numeric_limits< T >::epsilon()) const
Definition: csr.h:364
size_type nrow() const
Definition: csr.h:373
iterator begin_nonconst()
Definition: csr.h:385
vec< element_type, sequential > trans_mult(const vec< element_type, sequential > &x) const
Definition: csr.h:412
size_type ext_nnz() const
Definition: csr.h:389
csr(const asr< T, sequential, A > &a)
Definition: csr.h:342
rep::iterator iterator
Definition: csr.h:333
size_type ncol() const
Definition: csr.h:374
smart_pointer< rep > base
Definition: csr.h:329
bool is_symmetric() const
Definition: csr.h:362
csr(const std::initializer_list< details::csr_concat_value< T, sequential > > &init_list)
size_type row_first_index() const
Definition: csr.h:378
size_type dis_ext_nnz() const
Definition: csr.h:361
const distributor & row_ownership() const
Definition: csr.h:356
iterator end_nonconst()
Definition: csr.h:386
rep::memory_type memory_type
Definition: csr.h:330
void set_definite_positive(bool is_defpos) const
Definition: csr.h:367
rep::size_type size_type
Definition: csr.h:331
const_iterator end() const
Definition: csr.h:384
void trans_mult(const vec< element_type, sequential > &x, vec< element_type, sequential > &y) const
Definition: csr.h:409
size_type nnz() const
Definition: csr.h:375
rep::data_iterator data_iterator
Definition: csr.h:335
size_type col_first_index() const
Definition: csr.h:380
size_type dis_nrow() const
Definition: csr.h:358
csr_rep< T, sequential > rep
Definition: csr.h:328
const_iterator ext_begin() const
Definition: csr.h:390
void dump(const std::string &name) const
Definition: csr.h:429
size_type dis_nnz() const
Definition: csr.h:222
base::data_iterator data_iterator
Definition: csr.h:195
scatter_message< std::vector< T > > _to
Definition: csr.h:259
size_type row_last_index() const
Definition: csr.h:233
const_iterator begin() const
Definition: csr.h:208
size_type pattern_dimension() const
Definition: csr.h:230
bool is_definite_positive() const
Definition: csr.h:228
size_type col_last_index() const
Definition: csr.h:235
void set_pattern_dimension(size_type dim) const
Definition: csr.h:231
const distributor & col_ownership() const
Definition: csr.h:206
csr_rep< T, sequential > base
Definition: csr.h:189
const_iterator ext_end() const
Definition: csr.h:214
size_type dis_ncol() const
Definition: csr.h:221
void _scatter_init_guard() const
Definition: csr.h:263
void set_symmetry(bool is_symm) const
Definition: csr.h:226
csr_rep< T, sequential > _ext
Definition: csr.h:251
base::size_type size_type
Definition: csr.h:191
size_type nrow() const
Definition: csr.h:217
size_type ext_nnz() const
Definition: csr.h:212
scatter_message< std::vector< T > > _from
Definition: csr.h:258
size_type ncol() const
Definition: csr.h:218
base::element_type element_type
Definition: csr.h:192
std::vector< T > _buffer
Definition: csr.h:260
base::const_iterator const_iterator
Definition: csr.h:194
size_type row_first_index() const
Definition: csr.h:232
size_type dis_ext_nnz() const
Definition: csr.h:223
const distributor & row_ownership() const
Definition: csr.h:205
void set_definite_positive(bool is_defpos) const
Definition: csr.h:229
const_iterator end() const
Definition: csr.h:209
const communicator & comm() const
Definition: csr.h:207
size_type nnz() const
Definition: csr.h:219
std::vector< size_type > _jext2dis_j
Definition: csr.h:252
size_type col_first_index() const
Definition: csr.h:234
size_type dis_nrow() const
Definition: csr.h:220
base::const_data_iterator const_data_iterator
Definition: csr.h:196
const_iterator ext_begin() const
Definition: csr.h:213
size_type dis_nnz() const
Definition: csr.h:116
size_type jext2dis_j(size_type jext) const
Definition: csr.h:147
vector_of_iterator< pair_type >::const_value_type const_data_iterator
Definition: csr.h:94
size_type row_last_index() const
Definition: csr.h:126
const_iterator begin() const
Definition: csr.h:107
size_type pattern_dimension() const
Definition: csr.h:123
bool is_definite_positive() const
Definition: csr.h:121
size_type col_last_index() const
Definition: csr.h:128
vector_of_iterator< pair_type >::iterator iterator
Definition: csr.h:90
void set_pattern_dimension(size_type dim) const
Definition: csr.h:124
const distributor & col_ownership() const
Definition: csr.h:106
const_iterator ext_end() const
Definition: csr.h:146
std::vector< std::pair< typename std::vector< T >::size_type, T > > _data
Definition: csr.h:152
size_type dis_ncol() const
Definition: csr.h:115
void set_symmetry(bool is_symm) const
Definition: csr.h:119
size_type nrow() const
Definition: csr.h:111
std::pair< size_type, T > pair_type
Definition: csr.h:89
size_type ext_nnz() const
Definition: csr.h:143
size_type ncol() const
Definition: csr.h:112
vector_of_iterator< pair_type >::difference_type difference_type
Definition: csr.h:92
std::vector< T >::size_type size_type
Definition: csr.h:86
vector_of_iterator< pair_type >::value_type data_iterator
Definition: csr.h:93
size_type row_first_index() const
Definition: csr.h:125
size_type dis_ext_nnz() const
Definition: csr.h:144
const distributor & row_ownership() const
Definition: csr.h:105
void set_definite_positive(bool is_defpos) const
Definition: csr.h:122
const_iterator end() const
Definition: csr.h:108
vector_of_iterator< pair_type >::const_iterator const_iterator
Definition: csr.h:91
size_type nnz() const
Definition: csr.h:113
size_type col_first_index() const
Definition: csr.h:127
size_type dis_nrow() const
Definition: csr.h:114
const_iterator ext_begin() const
Definition: csr.h:145
see the csr page for the full documentation
Definition: csr.h:317
M memory_type
Definition: csr.h:319
see the distributor page for the full documentation
Definition: distributor.h:62
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
see the smart_pointer page for the full documentation
see the vec page for the full documentation
Definition: vec.h:79
V::difference_type difference_type
const_value_type *const const_iterator
const_iterator end() const
geo_element_auto< heap_allocator< geo_element::size_type > > element_type
Definition: level_set.cc:346
rheolef::std Function
Expr1::float_type T
Definition: field_expr.h:261
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
return a operator*(eh)
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format format format dump
T max_abs(const T &x)
This file is part of Rheolef.
std::enable_if< details::is_rheolef_arithmetic< U >::value,ad3_basic< T > & >::type operator*=(ad3_basic< T > &a, const U &b)
Definition: ad3.h:367
void put(std::ostream &out, std::string name, const tiny_matrix< T > &a)
Definition: tiny_lu.h:155
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:88
csr< T, sequential > trans(const csr< T, sequential > &a)
trans(a): see the form page for the full documentation
Definition: csr.h:455
std::enable_if< details::is_rheolef_arithmetic< U >::value,ad3_basic< T >>::type operator+(const U &a, const ad3_basic< T > &b)
Definition: ad3.h:222
csr< T, sequential > operator-(const csr< T, sequential > &a)
Definition: csr.h:447
csr< T, M > diag(const vec< T, M > &d)
Definition: csr.cc:56
csr< T, sequential > operator*(const T &lambda, const csr< T, sequential > &a)
Definition: csr.h:437
void put_matrix_market(std::ostream &out, const Eigen::SparseMatrix< T, Eigen::RowMajor > &a)
Definition: eigen_util.h:79
OutputPairIterator pair_transform_second(InputPairIterator first, InputPairIterator last, OutputPairIterator result, UnaryOperation unary_op)
Definition: pair_util.h:41
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
csr< T, distributed > operator-(const csr< T, distributed > &a)
Definition: csr.h:586
csr< T, M > csr_apply(Function f, const csr< T, M > &a)
Definition: csr.h:605
Definition: cavity_dg.h:29
Float epsilon
Expr1::memory_type M
Definition: vec_expr_v2.h:416