| 220 | } |
| 221 | |
| 222 | static void SetTuple( TMAT & self, py::tuple t, const TMAT & rmat) { |
| 223 | py::object rows = t[0]; |
| 224 | py::object cols = t[1]; |
| 225 | // Both elements have to be slices |
| 226 | try { |
| 227 | auto row_slice = rows.cast<py::slice> (); |
| 228 | auto col_slice = cols.cast<py::slice> (); |
| 229 | /* |
| 230 | size_t start, step, n; |
| 231 | InitSlice( row_slice, self.Height(), start, step, n ); |
| 232 | for (int i=0; i<n; i++, start+=step) { |
| 233 | py::object row = py::cast(self.Row(start)); |
| 234 | py::object f = row.attr("__setitem__"); |
| 235 | f(row, cols, rmat.Row(i)); |
| 236 | } |
| 237 | */ |
| 238 | size_t rstart, rstep, rn; |
| 239 | size_t cstart, cstep, cn; |
| 240 | InitSlice( row_slice, self.Height(), rstart, rstep, rn ); |
| 241 | InitSlice( col_slice, self.Width(), cstart, cstep, cn ); |
| 242 | for (int i = 0, ii=rstart; i < rn; i++, ii+=rstep) |
| 243 | for (int j = 0, jj = cstart; j < cn; j++, jj+=cstep) |
| 244 | self(ii,jj) = rmat(i,j); |
| 245 | |
| 246 | } catch (py::error_already_set const &) { |
| 247 | PyErr_Print(); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | static TROW RowGetInt( TMAT & self, int ind ) { |
| 252 | return self.Row(ind); |