vec_concat.h
Go to the documentation of this file.
#ifndef _RHEOLEF_VEC_CONCAT_H
#define _RHEOLEF_VEC_CONCAT_H
// build vec from initializer lists
//
#include "rheolef/vec.h"
namespace rheolef { namespace details {
// ----------------------------------------------------------------------------
// 1) implementation
// ----------------------------------------------------------------------------
static int constraint_process_rank (const communicator& comm = communicator()) { return 0; }
template <class T, class M>
class vec_concat_value {
public:
// typedef:
typedef enum { scalar, scalars, vector} variant_type;
// allocators:
template <class U,
class Sfinae
= typename std::enable_if<
is_rheolef_arithmetic<U>::value
,void
>::type
>
vec_concat_value (const U& x) : s(x), ss(), v(), variant(scalar) {}
vec_concat_value (const std::vector<T>& x) : s(), ss(x), v(), variant(scalars) {}
vec_concat_value (const vec<T,M>& x) : s(), ss(), v(x), variant(vector) {}
// data:
public:
T s;
std::vector<T> ss;
vec<T,M> v;
variant_type variant;
};
template <class T, class M>
class vec_concat {
public:
// typedef:
typedef typename vec<T,M>::size_type size_type;
typedef vec_concat_value<T,M> value_type;
// allocators:
vec_concat () : _l() {}
vec<T,M> build_vec() const;
vec_concat (const std::initializer_list<value_type>& il) : _l() {
typedef typename std::initializer_list<value_type>::const_iterator const_iterator;
for (const_iterator iter = il.begin(); iter != il.end(); ++iter) {
_l.push_back(*iter);
}
}
// data:
protected:
std::list<value_type> _l;
};
} // namespace details
// ----------------------------------------------------------------------------
// 2) interface with the vec<T,M> class
// ----------------------------------------------------------------------------
template <class T, class M>
inline
int
vec<T,M>::constraint_process_rank() const
{
return details::constraint_process_rank (base::comm());
}
template <class T, class M>
inline
vec<T,M>::vec (const std::initializer_list<details::vec_concat_value<T,M> >& init_list)
{
details::vec_concat<T,M> vc (init_list);
vec<T,M>::operator= (vc.build_vec());
}
template <class T, class M>
inline
vec<T,M>&
vec<T,M>::operator= (const std::initializer_list<details::vec_concat_value<T,M> >& init_list)
{
details::vec_concat<T,M> vc (init_list);
vec<T,M>::operator= (vc.build_vec());
return *this;
}
} // namespace rheolef
#endif // _RHEOLEF_VEC_CONCAT_H
rheolef::details::vec_concat_value
Definition: vec_concat.h:37
rheolef::details::vec_concat_value::ss
std::vector< T > ss
Definition: vec_concat.h:55
rheolef::details::vec_concat_value::vec_concat_value
vec_concat_value(const vec< T, M > &x)
Definition: vec_concat.h:51
rheolef::details::vec_concat_value::variant_type
variant_type
Definition: vec_concat.h:40
rheolef::details::vec_concat_value::scalars
@ scalars
Definition: vec_concat.h:40
rheolef::details::vec_concat_value::scalar
@ scalar
Definition: vec_concat.h:40
rheolef::details::vec_concat_value::vector
@ vector
Definition: vec_concat.h:40
rheolef::details::vec_concat_value::vec_concat_value
vec_concat_value(const std::vector< T > &x)
Definition: vec_concat.h:50
rheolef::details::vec_concat_value::s
T s
Definition: vec_concat.h:54
rheolef::details::vec_concat_value::variant
variant_type variant
Definition: vec_concat.h:57
rheolef::details::vec_concat_value::v
vec< T, M > v
Definition: vec_concat.h:56
rheolef::details::vec_concat_value::vec_concat_value
vec_concat_value(const U &x)
Definition: vec_concat.h:49
rheolef::details::vec_concat
Definition: vec_concat.h:61
rheolef::details::vec_concat::_l
std::list< value_type > _l
Definition: vec_concat.h:81
rheolef::details::vec_concat::size_type
vec< T, M >::size_type size_type
Definition: vec_concat.h:64
rheolef::details::vec_concat::vec_concat
vec_concat(const std::initializer_list< value_type > &il)
Definition: vec_concat.h:72
rheolef::details::vec_concat::build_vec
vec< T, M > build_vec() const
Definition: vec_concat.cc:29
rheolef::details::vec_concat::vec_concat
vec_concat()
Definition: vec_concat.h:69
rheolef::details::vec_concat::value_type
vec_concat_value< T, M > value_type
Definition: vec_concat.h:65
rheolef::vec< T, M >
rheolef::vec::constraint_process_rank
int constraint_process_rank() const
Definition: vec_concat.h:91
rheolef::type
rheolef::std type
T
Expr1::float_type T
Definition: field_expr.h:261
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::const_iterator
Definition: field_expr_recursive.h:552
rheolef::details::is_rheolef_arithmetic
Definition: Float.h:150