37 #ifndef GMM_REAL_PART_H 
   38 #define GMM_REAL_PART_H 
   46   struct linalg_real_part {};
 
   47   struct linalg_imag_part {};
 
   48   template <
typename R, 
typename PART> 
struct which_part {};
 
   50   template <
typename C> 
typename number_traits<C>::magnitude_type
 
   51   real_or_imag_part(C x, linalg_real_part) { 
return gmm::real(x); }
 
   52   template <
typename C> 
typename number_traits<C>::magnitude_type
 
   53   real_or_imag_part(C x, linalg_imag_part) { 
return gmm::imag(x); }
 
   54   template <
typename T, 
typename C, 
typename OP> C
 
   55   complex_from(T x, C y, OP op, linalg_real_part) { 
return std::complex<T>(op(std::real(y), x), std::imag(y)); }
 
   56   template <
typename T, 
typename C, 
typename OP> C
 
   57   complex_from(T x, C y, OP op,linalg_imag_part) { 
return std::complex<T>(std::real(y), op(std::imag(y), x)); }
 
   59   template<
typename T> 
struct project2nd {
 
   60     T operator()(T , T b)
 const { 
return b; }
 
   63   template<
typename T, 
typename R, 
typename PART> 
class ref_elt_vector<T, which_part<R, PART> > {
 
   69     operator T()
 const { 
return real_or_imag_part(std::complex<T>(r), PART()); }
 
   70     ref_elt_vector(R r_) : r(r_) {}
 
   71     inline ref_elt_vector &operator =(T v)
 
   72     { r = complex_from(v, std::complex<T>(r), gmm::project2nd<T>(), PART()); 
return *
this; }
 
   73     inline bool operator ==(T v)
 const { 
return (r == v); }
 
   74     inline bool operator !=(T v)
 const { 
return (r != v); }
 
   75     inline ref_elt_vector &operator +=(T v)
 
   76     { r = complex_from(v, std::complex<T>(r), std::plus<T>(), PART()); 
return *
this; }
 
   77     inline ref_elt_vector &operator -=(T v)
 
   78       { r = complex_from(v, std::complex<T>(r), std::minus<T>(), PART()); 
return *
this; }
 
   79     inline ref_elt_vector &operator /=(T v)
 
   80       { r = complex_from(v, std::complex<T>(r), std::divides<T>(), PART()); 
return *
this; }
 
   81     inline ref_elt_vector &operator *=(T v)
 
   82       { r = complex_from(v, std::complex<T>(r), std::multiplies<T>(), PART()); 
return *
this; }
 
   83     inline ref_elt_vector &operator =(
const ref_elt_vector &re)
 
   84       { *
this = T(re); 
return *
this; }
 
   89     T operator *(T v) { 
return T(*
this)* v; } 
 
   90     T operator /(T v) { 
return T(*
this)/ v; } 
 
   93   template<
typename reference> 
struct ref_or_value_type {
 
   94     template <
typename T, 
typename W>
 
   95     static W r(
const T &x, linalg_real_part, W) {
 
   98     template <
typename T, 
typename W>
 
   99     static W r(
const T &x, linalg_imag_part, W) {
 
  104   template<
typename U, 
typename R, 
typename PART>
 
  105   struct ref_or_value_type<ref_elt_vector<U, which_part<R, PART> > > {
 
  106     template<
typename T , 
typename W>
 
  107     static const T &r(
const T &x, linalg_real_part, W)
 
  109     template<
typename T, 
typename W>
 
  110     static const T &r(
const T &x, linalg_imag_part, W) {
 
  113     template<
typename T , 
typename W>
 
  114     static T &r(T &x, linalg_real_part, W)
 
  116     template<
typename T, 
typename W>
 
  117     static T &r(T &x, linalg_imag_part, W) {
 
  127   template <
typename IT, 
typename MIT, 
typename PART>
 
  128   struct part_vector_iterator {
 
  129     typedef typename std::iterator_traits<IT>::value_type      vtype;
 
  130     typedef typename gmm::number_traits<vtype>::magnitude_type value_type;
 
  131     typedef value_type                                        *pointer;
 
  132     typedef ref_elt_vector<value_type, which_part<typename std::iterator_traits<IT>::reference, PART> > reference;
 
  133     typedef typename std::iterator_traits<IT>::difference_type difference_type;
 
  134     typedef typename std::iterator_traits<IT>::iterator_category
 
  139     part_vector_iterator(
void) {}
 
  140     explicit part_vector_iterator(
const IT &i) : it(i) {}
 
  141     part_vector_iterator(
const part_vector_iterator<MIT, MIT, PART> &i)
 
  143     part_vector_iterator &
operator =
 
  144     (
const part_vector_iterator<MIT, MIT, PART> &i) { it = i.it; 
return *
this; }
 
  146     size_type index(
void)
 const { 
return it.index(); }
 
  147     part_vector_iterator operator ++(
int)
 
  148     { part_vector_iterator tmp = *
this; ++it; 
return tmp; }
 
  149     part_vector_iterator operator --(
int)
 
  150     { part_vector_iterator tmp = *
this; --it; 
return tmp; }
 
  151     part_vector_iterator &operator ++() { ++it; 
return *
this; }
 
  152     part_vector_iterator &operator --() { --it; 
return *
this; }
 
  153     part_vector_iterator &operator +=(difference_type i)
 
  154       { it += i; 
return *
this; }
 
  155     part_vector_iterator &operator -=(difference_type i)
 
  156       { it -= i; 
return *
this; }
 
  157     part_vector_iterator 
operator +(difference_type i)
 const 
  158       { part_vector_iterator itb = *
this; 
return (itb += i); }
 
  159     part_vector_iterator 
operator -(difference_type i)
 const 
  160       { part_vector_iterator itb = *
this; 
return (itb -= i); }
 
  161     difference_type 
operator -(
const part_vector_iterator &i)
 const 
  162       { 
return difference_type(it - i.it); }
 
  164     reference operator  *()
 const { 
return reference(*it); }
 
  165     reference operator [](
size_type ii)
 const { 
return reference(it[ii]); }
 
  167     bool operator ==(
const part_vector_iterator &i)
 const 
  168       { 
return (i.it == it); }
 
  169     bool operator !=(
const part_vector_iterator &i)
 const 
  170       { 
return (i.it != it); }
 
  171     bool operator < (
const part_vector_iterator &i)
 const 
  172       { 
return (it < i.it); }
 
  173     bool operator > (
const part_vector_iterator &i)
 const 
  174       { 
return (it > i.it); }
 
  175     bool operator >=(
const part_vector_iterator &i)
 const 
  176       { 
return (it >= i.it); }
 
  180   template <
typename PT, 
typename PART> 
struct part_vector {
 
  181     typedef part_vector<PT, PART> this_type;
 
  182     typedef typename std::iterator_traits<PT>::value_type V;
 
  184     typedef typename select_ref<typename linalg_traits<V>::const_iterator,
 
  185             typename linalg_traits<V>::iterator, PT>::ref_type iterator;
 
  186     typedef typename linalg_traits<this_type>::reference reference;
 
  187     typedef typename linalg_traits<this_type>::value_type value_type;
 
  188     typedef typename linalg_traits<this_type>::porigin_type porigin_type;
 
  190     iterator begin_, end_;
 
  194     size_type size(
void)
 const { 
return size_; }
 
  196     reference operator[](
size_type i)
 const {
 
  197       return reference(ref_or_value_type<reference>::r(
 
  198              linalg_traits<V>::access(origin, begin_, end_, i),
 
  199              PART(), value_type()));
 
  203       : begin_(vect_begin(v)),  end_(vect_end(v)),
 
  204         origin(linalg_origin(v)), size_(gmm::vect_size(v)) {}
 
  205     part_vector(
const V &v)
 
  206       : begin_(vect_begin(const_cast<V &>(v))),
 
  207         end_(vect_end(const_cast<V &>(v))),
 
  208         origin(linalg_origin(const_cast<V &>(v))), size_(gmm::vect_size(v)) {}
 
  210     part_vector(
const part_vector<CPT, PART> &cr)
 
  211       : begin_(cr.begin_),end_(cr.end_),origin(cr.origin), size_(cr.size_) {}
 
  214   template <
typename IT, 
typename MIT, 
typename ORG, 
typename PT,
 
  215             typename PART> 
inline 
  216   void set_to_begin(part_vector_iterator<IT, MIT, PART> &it,
 
  217                     ORG o, part_vector<PT, PART> *, linalg_modifiable) {
 
  218     typedef part_vector<PT, PART> VECT;
 
  219     typedef typename linalg_traits<VECT>::V_reference ref_t;
 
  220     set_to_begin(it.it, o, 
typename linalg_traits<VECT>::pV(), ref_t());
 
  222   template <
typename IT, 
typename MIT, 
typename ORG, 
typename PT,
 
  223             typename PART> 
inline 
  224   void set_to_begin(part_vector_iterator<IT, MIT, PART> &it,
 
  225                     ORG o, 
const part_vector<PT, PART> *, linalg_modifiable) {
 
  226     typedef part_vector<PT, PART> VECT;
 
  227     typedef typename linalg_traits<VECT>::V_reference ref_t;
 
  228     set_to_begin(it.it, o, 
typename linalg_traits<VECT>::pV(), ref_t());
 
  230   template <
typename IT, 
typename MIT, 
typename ORG, 
typename PT,
 
  231             typename PART> 
inline 
  232   void set_to_end(part_vector_iterator<IT, MIT, PART> &it,
 
  233                   ORG o, part_vector<PT, PART> *, linalg_modifiable) {
 
  234     typedef part_vector<PT, PART> VECT;
 
  235     typedef typename linalg_traits<VECT>::V_reference ref_t;
 
  236     set_to_end(it.it, o, 
typename linalg_traits<VECT>::pV(), ref_t());
 
  238   template <
typename IT, 
typename MIT, 
typename ORG,
 
  239             typename PT, 
typename PART> 
inline 
  240   void set_to_end(part_vector_iterator<IT, MIT, PART> &it,
 
  241                   ORG o, 
const part_vector<PT, PART> *,
 
  243     typedef part_vector<PT, PART> VECT;
 
  244     typedef typename linalg_traits<VECT>::V_reference ref_t;
 
  245     set_to_end(it.it, o, 
typename linalg_traits<VECT>::pV(), ref_t());
 
  248   template <
typename PT, 
typename PART> std::ostream &
operator <<
 
  249     (std::ostream &o, 
const part_vector<PT, PART>& m)
 
  250   { gmm::write(o,m); 
return o; }
 
  258   template <
typename PT, 
typename PART> 
struct  part_row_ref {
 
  260     typedef part_row_ref<PT, PART> this_type;
 
  261     typedef typename std::iterator_traits<PT>::value_type M;
 
  263     typedef typename std::iterator_traits<PT>::reference ref_M;
 
  264     typedef typename select_ref<typename linalg_traits<this_type>
 
  265             ::const_row_iterator, 
typename linalg_traits<this_type>
 
  266             ::row_iterator, PT>::ref_type iterator;
 
  267     typedef typename linalg_traits<this_type>::value_type value_type;
 
  268     typedef typename linalg_traits<this_type>::reference reference;
 
  269     typedef typename linalg_traits<this_type>::porigin_type porigin_type;
 
  271     iterator begin_, end_;
 
  275     part_row_ref(ref_M m)
 
  276       : begin_(mat_row_begin(m)), end_(mat_row_end(m)),
 
  277         origin(linalg_origin(m)), nr(mat_nrows(m)), nc(mat_ncols(m)) {}
 
  279     part_row_ref(
const part_row_ref<CPT, PART> &cr) :
 
  280       begin_(cr.begin_),end_(cr.end_), origin(cr.origin),nr(cr.nr),nc(cr.nc) {}
 
  283       return reference(ref_or_value_type<reference>::r(
 
  284                        linalg_traits<M>::access(begin_+i, j),
 
  285                        PART(), value_type()));
 
  289   template<
typename PT, 
typename PART> std::ostream &
operator <<
 
  290     (std::ostream &o, 
const part_row_ref<PT, PART>& m)
 
  291   { gmm::write(o,m); 
return o; }
 
  293   template <
typename PT, 
typename PART> 
struct  part_col_ref {
 
  295     typedef part_col_ref<PT, PART> this_type;
 
  296     typedef typename std::iterator_traits<PT>::value_type M;
 
  298     typedef typename std::iterator_traits<PT>::reference ref_M;
 
  299     typedef typename select_ref<typename linalg_traits<this_type>
 
  300             ::const_col_iterator, 
typename linalg_traits<this_type>
 
  301             ::col_iterator, PT>::ref_type iterator;
 
  302     typedef typename linalg_traits<this_type>::value_type value_type;
 
  303     typedef typename linalg_traits<this_type>::reference reference;
 
  304     typedef typename linalg_traits<this_type>::porigin_type porigin_type;
 
  306     iterator begin_, end_;
 
  310     part_col_ref(ref_M m)
 
  311       : begin_(mat_col_begin(m)), end_(mat_col_end(m)),
 
  312         origin(linalg_origin(m)), nr(mat_nrows(m)), nc(mat_ncols(m)) {}
 
  314     part_col_ref(
const part_col_ref<CPT, PART> &cr) :
 
  315       begin_(cr.begin_),end_(cr.end_), origin(cr.origin),nr(cr.nr),nc(cr.nc) {}
 
  318       return reference(ref_or_value_type<reference>::r(
 
  319                        linalg_traits<M>::access(begin_+j, i),
 
  320                        PART(), value_type()));
 
  326   template<
typename PT, 
typename PART> std::ostream &
operator <<
 
  327     (std::ostream &o, 
const part_col_ref<PT, PART>& m)
 
  328   { gmm::write(o,m); 
return o; }
 
  335 template <
typename TYPE, 
typename PART, 
typename PT>
 
  336   struct part_return_ {
 
  337     typedef abstract_null_type return_type;
 
  339   template <
typename PT, 
typename PART>
 
  340   struct part_return_<row_major, PART, PT> {
 
  341     typedef typename std::iterator_traits<PT>::value_type L;
 
  342     typedef typename select_return<part_row_ref<const L *, PART>,
 
  343                      part_row_ref< L *, PART>, PT>::return_type return_type;
 
  345   template <
typename PT, 
typename PART>
 
  346   struct part_return_<col_major, PART, PT> {
 
  347     typedef typename std::iterator_traits<PT>::value_type L;
 
  348     typedef typename select_return<part_col_ref<const L *, PART>,
 
  349                      part_col_ref<L *, PART>, PT>::return_type return_type;
 
  352   template <
typename PT, 
typename PART, 
typename LT> 
struct part_return__{
 
  353     typedef abstract_null_type return_type;
 
  356   template <
typename PT, 
typename PART>
 
  357   struct part_return__<PT, PART, abstract_matrix> {
 
  358     typedef typename std::iterator_traits<PT>::value_type L;
 
  359     typedef typename part_return_<
typename principal_orientation_type<
 
  360       typename linalg_traits<L>::sub_orientation>::potype, PART,
 
  361       PT>::return_type return_type;
 
  364   template <
typename PT, 
typename PART>
 
  365   struct part_return__<PT, PART, abstract_vector> {
 
  366     typedef typename std::iterator_traits<PT>::value_type L;
 
  367     typedef typename select_return<part_vector<const L *, PART>,
 
  368       part_vector<L *, PART>, PT>::return_type return_type;
 
  371   template <
typename PT, 
typename PART> 
struct part_return {
 
  372     typedef typename std::iterator_traits<PT>::value_type L;
 
  373     typedef typename part_return__<PT, PART,
 
  374       typename linalg_traits<L>::linalg_type>::return_type return_type;
 
  377   template <
typename L> 
inline 
  378   typename part_return<const L *, linalg_real_part>::return_type
 
  379   real_part(
const L &l) {
 
  380     return typename part_return<const L *, linalg_real_part>::return_type
 
  381       (linalg_cast(
const_cast<L &
>(l)));
 
  384   template <
typename L> 
inline 
  385   typename part_return<L *, linalg_real_part>::return_type
 
  387     return typename part_return<L *, linalg_real_part>::return_type(linalg_cast(l));
 
  390   template <
typename L> 
inline 
  391   typename part_return<const L *, linalg_imag_part>::return_type
 
  392   imag_part(
const L &l) {
 
  393     return typename part_return<const L *, linalg_imag_part>::return_type
 
  394       (linalg_cast(
const_cast<L &
>(l)));
 
  397   template <
typename L> 
inline 
  398   typename part_return<L *, linalg_imag_part>::return_type
 
  400     return typename part_return<L *, linalg_imag_part>::return_type(linalg_cast(l));
 
  404   template <
typename PT, 
typename PART>
 
  405   struct linalg_traits<part_vector<PT, PART> > {
 
  406     typedef part_vector<PT, PART> this_type;
 
  407     typedef this_type * pthis_type;
 
  409     typedef typename std::iterator_traits<PT>::value_type V;
 
  410     typedef typename linalg_traits<V>::index_sorted index_sorted;
 
  411     typedef typename linalg_traits<V>::is_reference V_reference;
 
  412     typedef typename linalg_traits<V>::origin_type origin_type;
 
  413     typedef typename select_ref<
const origin_type *, origin_type *,
 
  414                                 PT>::ref_type porigin_type;
 
  415     typedef typename which_reference<PT>::is_reference is_reference;
 
  416     typedef abstract_vector linalg_type;
 
  417     typedef typename linalg_traits<V>::value_type vtype;
 
  418     typedef typename number_traits<vtype>::magnitude_type value_type;
 
  419     typedef typename select_ref<value_type, ref_elt_vector<value_type,
 
  420                      which_part<typename linalg_traits<V>::reference,
 
  421                                 PART> >, PT>::ref_type reference;
 
  422     typedef typename select_ref<typename linalg_traits<V>::const_iterator,
 
  423             typename linalg_traits<V>::iterator, PT>::ref_type pre_iterator;
 
  424     typedef typename select_ref<abstract_null_type,
 
  425             part_vector_iterator<pre_iterator, pre_iterator, PART>,
 
  426             PT>::ref_type iterator;
 
  427     typedef part_vector_iterator<typename linalg_traits<V>::const_iterator,
 
  428                                  pre_iterator, PART> const_iterator;
 
  429     typedef typename linalg_traits<V>::storage_type storage_type;
 
  430     static size_type size(
const this_type &v) { 
return v.size(); }
 
  431     static iterator begin(this_type &v) {
 
  432       iterator it; it.it = v.begin_;
 
  433       if (!is_const_reference(is_reference()) && is_sparse(storage_type()))
 
  434         set_to_begin(it, v.origin, pthis_type(), is_reference());
 
  437     static const_iterator begin(
const this_type &v) {
 
  438       const_iterator it(v.begin_);
 
  439       if (!is_const_reference(is_reference()) && is_sparse(storage_type()))
 
  440         { set_to_begin(it, v.origin, pthis_type(), is_reference()); }
 
  443     static iterator end(this_type &v) {
 
  445       if (!is_const_reference(is_reference()) && is_sparse(storage_type()))
 
  446         set_to_end(it, v.origin, pthis_type(), is_reference());
 
  449     static const_iterator end(
const this_type &v) {
 
  450       const_iterator it(v.end_);
 
  451       if (!is_const_reference(is_reference()) && is_sparse(storage_type()))
 
  452         set_to_end(it, v.origin, pthis_type(), is_reference());
 
  455     static origin_type* origin(this_type &v) { 
return v.origin; }
 
  456     static const origin_type* origin(
const this_type &v) { 
return v.origin; }
 
  458     static void clear(origin_type* o, 
const iterator &begin_,
 
  459                       const iterator &end_, abstract_sparse) {
 
  460       std::deque<size_type> ind;
 
  461       iterator it = begin_;
 
  462       for (; it != end_; ++it) ind.push_front(it.index());
 
  463       for (; !(ind.empty()); ind.pop_back())
 
  464         access(o, begin_, end_, ind.back()) = value_type(0);
 
  466     static void clear(origin_type* o, 
const iterator &begin_,
 
  467                       const iterator &end_, abstract_skyline) {
 
  468       clear(o, begin_, end_, abstract_sparse());
 
  470     static void clear(origin_type* o, 
const iterator &begin_,
 
  471                       const iterator &end_, abstract_dense) {
 
  472       for (iterator it = begin_; it != end_; ++it)
 
  476    static void clear(origin_type* o, 
const iterator &begin_,
 
  477                      const iterator &end_)
 
  478     { 
clear(o, begin_, end_, storage_type()); }
 
  479     static void do_clear(this_type &v) { 
clear(v.origin, begin(v), end(v)); }
 
  480     static value_type access(
const origin_type *o, 
const const_iterator &it,
 
  481                              const const_iterator &ite, 
size_type i) {
 
  482       return  real_or_imag_part(linalg_traits<V>::access(o, it.it, ite.it,i),
 
  485     static reference access(origin_type *o, 
const iterator &it,
 
  487     { 
return reference(linalg_traits<V>::access(o, it.it, ite.it,i)); }
 
  490   template <
typename PT, 
typename PART>
 
  491   struct linalg_traits<part_row_ref<PT, PART> > {
 
  492     typedef part_row_ref<PT, PART> this_type;
 
  493     typedef typename std::iterator_traits<PT>::value_type M;
 
  494     typedef typename linalg_traits<M>::origin_type origin_type;
 
  495     typedef typename select_ref<
const origin_type *, origin_type *,
 
  496                                 PT>::ref_type porigin_type;
 
  497     typedef typename which_reference<PT>::is_reference is_reference;
 
  498     typedef abstract_matrix linalg_type;
 
  499     typedef typename linalg_traits<M>::value_type vtype;
 
  500     typedef typename number_traits<vtype>::magnitude_type value_type;
 
  501     typedef typename linalg_traits<M>::storage_type storage_type;
 
  502     typedef abstract_null_type sub_col_type;
 
  503     typedef abstract_null_type const_sub_col_type;
 
  504     typedef abstract_null_type col_iterator;
 
  505     typedef abstract_null_type const_col_iterator;
 
  506     typedef typename org_type<typename linalg_traits<M>::const_sub_row_type>::t
 
  507             pre_const_sub_row_type;
 
  508     typedef typename org_type<typename linalg_traits<M>::sub_row_type>::t pre_sub_row_type;
 
  509     typedef part_vector<const pre_const_sub_row_type *, PART>
 
  511     typedef typename select_ref<abstract_null_type,
 
  512             part_vector<pre_sub_row_type *, PART>, PT>::ref_type sub_row_type;
 
  513     typedef typename linalg_traits<M>::const_row_iterator const_row_iterator;
 
  514     typedef typename select_ref<abstract_null_type, 
typename 
  515             linalg_traits<M>::row_iterator, PT>::ref_type row_iterator;
 
  516     typedef typename select_ref<
 
  517             typename linalg_traits<const_sub_row_type>::reference,
 
  518             typename linalg_traits<sub_row_type>::reference,
 
  519                                 PT>::ref_type reference;
 
  520     typedef row_major sub_orientation;
 
  521     typedef typename linalg_traits<M>::index_sorted index_sorted;
 
  522     static size_type ncols(
const this_type &v) { 
return v.nc; }
 
  523     static size_type nrows(
const this_type &v) { 
return v.nr; }
 
  524     static const_sub_row_type row(
const const_row_iterator &it)
 
  525     { 
return const_sub_row_type(linalg_traits<M>::row(it)); }
 
  526     static sub_row_type row(
const row_iterator &it)
 
  527     { 
return sub_row_type(linalg_traits<M>::row(it)); }
 
  528     static row_iterator row_begin(this_type &m) { 
return m.begin_; }
 
  529     static row_iterator row_end(this_type &m) { 
return m.end_; }
 
  530     static const_row_iterator row_begin(
const this_type &m)
 
  532     static const_row_iterator row_end(
const this_type &m) { 
return m.end_; }
 
  533     static origin_type* origin(this_type &v) { 
return v.origin; }
 
  534     static const origin_type* origin(
const this_type &v) { 
return v.origin; }
 
  535     static void do_clear(this_type &v);
 
  536     static value_type access(
const const_row_iterator &itrow, 
size_type i)
 
  537     { 
return real_or_imag_part(linalg_traits<M>::access(itrow, i), PART()); }
 
  538     static reference access(
const row_iterator &itrow, 
size_type i) {
 
  539       return reference(ref_or_value_type<reference>::r(
 
  540                        linalg_traits<M>::access(itrow, i),
 
  541                        PART(), value_type()));
 
  545   template <
typename PT, 
typename PART>
 
  546   struct linalg_traits<part_col_ref<PT, PART> > {
 
  547     typedef part_col_ref<PT, PART> this_type;
 
  548     typedef typename std::iterator_traits<PT>::value_type M;
 
  549     typedef typename linalg_traits<M>::origin_type origin_type;
 
  550     typedef typename select_ref<
const origin_type *, origin_type *,
 
  551                                 PT>::ref_type porigin_type;
 
  552     typedef typename which_reference<PT>::is_reference is_reference;
 
  553     typedef abstract_matrix linalg_type;
 
  554     typedef typename linalg_traits<M>::value_type vtype;
 
  555     typedef typename number_traits<vtype>::magnitude_type value_type;
 
  556     typedef typename linalg_traits<M>::storage_type storage_type;
 
  557     typedef abstract_null_type sub_row_type;
 
  558     typedef abstract_null_type const_sub_row_type;
 
  559     typedef abstract_null_type row_iterator;
 
  560     typedef abstract_null_type const_row_iterator;
 
  561     typedef typename org_type<typename linalg_traits<M>::const_sub_col_type>::t
 
  562             pre_const_sub_col_type;
 
  563     typedef typename org_type<typename linalg_traits<M>::sub_col_type>::t pre_sub_col_type;
 
  564     typedef part_vector<const pre_const_sub_col_type *, PART>
 
  566     typedef typename select_ref<abstract_null_type,
 
  567             part_vector<pre_sub_col_type *, PART>, PT>::ref_type sub_col_type;
 
  568     typedef typename linalg_traits<M>::const_col_iterator const_col_iterator;
 
  569     typedef typename select_ref<abstract_null_type, 
typename 
  570             linalg_traits<M>::col_iterator, PT>::ref_type col_iterator;
 
  571     typedef typename select_ref<
 
  572             typename linalg_traits<const_sub_col_type>::reference,
 
  573             typename linalg_traits<sub_col_type>::reference,
 
  574                                 PT>::ref_type reference;
 
  575     typedef col_major sub_orientation;
 
  576     typedef typename linalg_traits<M>::index_sorted index_sorted;
 
  577     static size_type nrows(
const this_type &v) { 
return v.nr; }
 
  578     static size_type ncols(
const this_type &v) { 
return v.nc; }
 
  579     static const_sub_col_type col(
const const_col_iterator &it)
 
  580     { 
return const_sub_col_type(linalg_traits<M>::col(it)); }
 
  581     static sub_col_type col(
const col_iterator &it)
 
  582     { 
return sub_col_type(linalg_traits<M>::col(it)); }
 
  583     static col_iterator col_begin(this_type &m) { 
return m.begin_; }
 
  584     static col_iterator col_end(this_type &m) { 
return m.end_; }
 
  585     static const_col_iterator col_begin(
const this_type &m)
 
  587     static const_col_iterator col_end(
const this_type &m) { 
return m.end_; }
 
  588     static origin_type* origin(this_type &v) { 
return v.origin; }
 
  589     static const origin_type* origin(
const this_type &v) { 
return v.origin; }
 
  590     static void do_clear(this_type &v);
 
  591     static value_type access(
const const_col_iterator &itcol, 
size_type i)
 
  592     { 
return real_or_imag_part(linalg_traits<M>::access(itcol, i), PART()); }
 
  593     static reference access(
const col_iterator &itcol, 
size_type i) {
 
  594       return reference(ref_or_value_type<reference>::r(
 
  595                        linalg_traits<M>::access(itcol, i),
 
  596                        PART(), value_type()));
 
  600   template <
typename PT, 
typename PART>
 
  601   void linalg_traits<part_col_ref<PT, PART> >::do_clear(this_type &v) {
 
  602     col_iterator it = mat_col_begin(v), ite = mat_col_end(v);
 
  603     for (; it != ite; ++it) 
clear(col(it));
 
  606   template <
typename PT, 
typename PART>
 
  607   void linalg_traits<part_row_ref<PT, PART> >::do_clear(this_type &v) {
 
  608     row_iterator it = mat_row_begin(v), ite = mat_row_end(v);
 
  609     for (; it != ite; ++it) 
clear(row(it));
 
void clear(L &l)
clear (fill with zeros) a vector or matrix.
 
Basic definitions and tools of GMM.
 
Declaration of the vector types (gmm::rsvector, gmm::wsvector, gmm::slvector ,..)
 
rational_fraction< T > operator-(const polynomial< T > &P, const rational_fraction< T > &Q)
Subtract Q from P.
 
rational_fraction< T > operator+(const polynomial< T > &P, const rational_fraction< T > &Q)
Add Q to P.
 
size_t size_type
used as the common size type in the library