1 #ifndef _RHEOLEF_FORM_CONCAT_H
2 #define _RHEOLEF_FORM_CONCAT_H
3 #include "rheolef/form.h"
4 #include "rheolef/csr_concat.h"
9 template <
class T,
class M>
15 friend std::ostream& operator<< (std::ostream& o, const form_concat_value<T,M>& x) {
16 if (x.variant ==
scalar)
return o <<
"s";
17 else if (x.variant ==
field)
return o <<
"f";
27 template <
class T,
class M>
34 #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST
36 #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_ITERATOR
37 typedef typename std::initializer_list<value_type>::const_iterator
const_iterator;
38 #else // _RHEOLEF_HAVE_STD_INITIALIZER_ITERATOR
40 #endif // _RHEOLEF_HAVE_STD_INITIALIZER_ITERATOR
41 for(const_iterator iter = il.begin(); iter != il.end(); ++iter) {
45 #endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST
50 friend std::ostream& operator<< (std::ostream& o, const form_concat_line<T,M>& x) {
52 for(
typename std::list<value_type>::const_iterator iter = x._l.begin(); iter != x._l.end(); ++iter) {
53 std::cout << *iter <<
" ";
55 return std::cout <<
"}";
65 std::list<value_type>
_l;
67 template <
class T,
class M>
73 typename std::vector<std::pair<bool,space_basic<T,M> > >::iterator xh_iter = l_Xh.begin();
74 for (
typename std::list<value_type>::const_iterator iter = _l.begin(); iter != _l.end(); ++iter, xh_iter++, j_comp++) {
78 check_macro (x.
s == 0,
"unsupported non-nul scalar `"<<x.
s<<
"' in form concatenation"
79 <<
" at ("<<i_comp<<
","<<j_comp<<
")");
83 if (!(*xh_iter).first) {
84 (*xh_iter).first =
true;
85 (*xh_iter).second = x.
m.get_first_space();
87 check_macro (x.
m.get_first_space() == (*xh_iter).second,
"form initializer: invalid second space `"
88 << x.
m.get_first_space().stamp() <<
"': expect `" << (*xh_iter).second.stamp() <<
"'"
89 <<
" at ("<<i_comp<<
","<<j_comp<<
")");
93 Yh = x.
m.get_second_space();
95 check_macro (x.
m.get_second_space() == Yh,
"form initializer: invalid second space `"
96 << x.
m.get_second_space().stamp() <<
"': expect `" << Yh.stamp() <<
"'"
97 <<
" at ("<<i_comp<<
","<<j_comp<<
")");
101 default:
error_macro (
"non-form or scalar concatenation not yet supported"
102 <<
" at ("<<i_comp<<
","<<j_comp<<
")");
105 check_macro (have_Yh,
"form concatenation: "<<i_comp<<
"th row space remains undefined");
107 template <
class T,
class M>
114 xh_iter = l_Xh.begin(),
115 xh_last = l_Xh.end(); xh_iter != xh_last; xh_iter++, j_comp++) {
116 check_macro ((*xh_iter).first,
"form concatenation: "<<j_comp<<
"th column space remains undefined");
117 sml_X *= (*xh_iter).second;
121 template <
class T,
class M>
125 std::vector<std::pair<bool,space_basic<T,M> > > l_Xh (_l.size(), std::pair<bool,space_basic<T,M> >(
false,
space_basic<T,M>()));
126 build_form_pass0 (l_Xh, Yh);
127 build_first_space (l_Xh, Xh);
129 template <
class T,
class M>
135 for(
typename std::list<value_type>::const_iterator iter = _l.begin(); iter != _l.end(); ++iter) {
145 default:
error_macro (
"non-form concatenation not yet supported");
154 template <
class T,
class M>
159 build_form_pass1 (Xh, Yh);
160 return build_form_pass2 (Xh, Yh);
162 #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST
163 template <
class T,
class M>
170 #endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST
171 template <
class T,
class M>
178 #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST
180 #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_ITERATOR
181 typedef typename std::initializer_list<line_type>::const_iterator const_iterator;
182 #else // _RHEOLEF_HAVE_STD_INITIALIZER_ITERATOR
184 #endif // _RHEOLEF_HAVE_STD_INITIALIZER_ITERATOR
185 for(const_iterator iter = il.begin(); iter != il.end(); ++iter) {
189 #endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST
191 friend std::ostream& operator<< (std::ostream& o, const form_concat<T,M>& x) {
193 for(
typename std::list<line_type>::const_iterator iter = x._l.begin(); iter != x._l.end(); ++iter) {
194 std::cout << *iter <<
" ";
196 return std::cout <<
"}";
201 std::list<line_type>
_l;
203 template <
class T,
class M>
209 std::vector<std::pair<bool,space_basic<T,M> > > l_Xh (_l.size(), std::pair<bool,space_basic<T,M> >(
false,
space_basic<T,M>()));
210 for (
typename std::list<line_type>::const_iterator iter = _l.begin(); iter != _l.end(); ++iter, i_comp++) {
220 for (
typename std::list<line_type>::const_iterator iter = _l.begin(); iter != _l.end(); ++iter) {
223 for (
typename std::list<value_type>::const_iterator jter = line.
begin(); jter != line.
end(); ++jter) {
227 check_macro (x.
s == 0,
"unsupported non-nul scalar `"<<x.
s<<
"' in form concatenation");
242 default:
error_macro (
"non-form or scalar concatenation not yet supported");
258 #ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST
259 template <
class T,
class M>
266 #endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST
269 #endif // _RHEOLEF_FORM_CONCAT_H