| 156 | } |
| 157 | |
| 158 | static void SetTupleVec( TMAT & self, py::tuple t, const FlatVector<TSCAL> &v) { |
| 159 | py::object rows = t[0]; |
| 160 | py::object cols = t[1]; |
| 161 | |
| 162 | // First element of tuple is of type int |
| 163 | if(py::isinstance<py::int_>(rows)) { |
| 164 | py::object row = py::cast( self.Row(rows.cast<int>()) ); |
| 165 | row.attr("__setitem__")(cols, v); |
| 166 | return; |
| 167 | } |
| 168 | |
| 169 | // Second element of tuple is of type int |
| 170 | if(py::isinstance<py::int_>(cols)) { |
| 171 | auto row_slice = rows.cast<py::slice>(); |
| 172 | auto col = self.Col(cols.cast<int>()); |
| 173 | size_t start, step, n; |
| 174 | InitSlice( row_slice, self.Height(), start, step, n ); |
| 175 | for (int i=0; i<n; i++, start+=step) |
| 176 | col[start] = v[i]; |
| 177 | return; |
| 178 | } |
| 179 | |
| 180 | // One of the indices has to be of type int |
| 181 | cerr << "Invalid Matrix access!" << endl; |
| 182 | } |
| 183 | |
| 184 | static void SetTupleScal( TMAT & self, py::tuple t, TSCAL val) { |
| 185 | py::object rows = t[0]; |