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

Method MultAdd

linalg/sparsematrix_impl.hpp:265–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263
264 template <class TM, class TV_ROW, class TV_COL>
265 void SparseMatrix<TM,TV_ROW,TV_COL> ::
266 MultAdd (double s, const BaseVector & x, BaseVector & y) const
267 {
268 static Timer t("SparseMatrix::MultAdd"); RegionTimer reg(t);
269 t.AddFlops (this->NZE()*sizeof(TV_ROW)*sizeof(TV_COL)/sqr(sizeof(double)));
270
271 ParallelForRange
272 (balance, [&] (IntRange myrange)
273 {
274 FlatVector<TVX> fx = x.FV<TVX>();
275 FlatVector<TVY> fy = y.FV<TVY>();
276
277 for (auto i : myrange)
278 fy(i) += s * RowTimesVector (i, fx);
279 });
280
281#ifdef OLD
282 if (task_manager)
283 {
284 FlatVector<TVX> fx = x.FV<TVX>();
285 FlatVector<TVY> fy = y.FV<TVY>();
286
287 // int ntasks = task_manager->GetNumThreads();
288
289 task_manager -> CreateJob
290 ([&] (TaskInfo & ti)
291 {
292 int tasks_per_part = ti.ntasks / balance.Size();
293 int mypart = ti.task_nr / tasks_per_part;
294 int num_in_part = ti.task_nr % tasks_per_part;
295
296 auto myrange = balance[mypart].Split (num_in_part, tasks_per_part);
297
298 for (auto row : myrange)
299 fy(row) += s * RowTimesVector (row, fx);
300
301 });
302 return;
303 }
304
305
306 FlatVector<TVX> fx = x.FV<TVX>();
307 FlatVector<TVY> fy = y.FV<TVY>();
308
309 int h = this->Height();
310 for (int i = 0; i < h; i++)
311 fy(i) += s * RowTimesVector (i, fx);
312#endif
313
314
315 }
316
317 template <class TM, class TV_ROW, class TV_COL>
318 void SparseMatrix<TM,TV_ROW,TV_COL> ::

Callers

nothing calls this directly

Calls 6

RowTimesVectorFunction · 0.85
MultAddFunction · 0.70
NZEMethod · 0.45
SizeMethod · 0.45
SplitMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected