48 : _r(0), _fc(fc), _tc(tc), _fr(fr), _tr(tr) {
51 if (fc >= tc || fr >= tr) {
52 _fc=0; _tc=0; _fr=0; _tr=0;
59 for (
int h = fr; h < tr; h++)
60 for (
int w = fc; w < tc; w++)
67 for (
int i = 0;
i < _r.
size()/2;
i++)
68 std::swap(_r[
i], _r[_r.size()-i-1]);
89 Slice<A>::operator
const Matrix<typename Slice<A>::ArgsType>(void)
const {
90 return Matrix<ArgsType>(_r, _tc-_fc, _tr-_fr);
94 typename Slice<A>::ArgsType
102 typename Slice<A>::ArgsType
109 typename Slice<A>::ArgsType
116 typename Slice<A>::ArgsType
123 typename Slice<A>::ArgsType
132 :
_a(a), _w(w), _h(h) {
133 if ((_w * _h) != _a.size())
140 :
_a(a), _w(n), _h(n) {
141 if (n*n != _a.size())
160 if ((c >= _w) || (r >= _h))
168 if ((c >= _w) || (r >= _h))
176 return Slice<A>(*
this, fc, tc, fr, tr);
182 return slice(0, width(), r, r+1);
188 return slice(c, c+1, 0, height());
191 template<
class Char,
class Traits,
class A>
192 std::basic_ostream<Char,Traits>&
193 operator <<(std::basic_ostream<Char,Traits>& os,
const Matrix<A>& m) {
194 std::basic_ostringstream<Char,Traits> s;
195 s.copyfmt(os); s.
width(0);
196 for (
int i=0;
i<m.height();
i++) {
197 for (
int j=0; j<m.width(); j++) {
202 return os << s.str();
205 template<
class Char,
class Traits,
class A>
206 std::basic_ostream<Char,Traits>&
207 operator <<(std::basic_ostream<Char,Traits>& os,
const Slice<A>& s) {
208 return os << static_cast<typename Slice<A>::ArgsType>(s);
232 #ifdef GECODE_HAS_SET_VARS