MCPcopy Create free account
hub / github.com/NGSolve/ngsolve / SetTupleVec

Method SetTupleVec

basiclinalg/python_bla.cpp:158–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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];

Callers

nothing calls this directly

Calls 4

InitSliceFunction · 0.85
RowMethod · 0.45
ColMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected