matrixMult.hh

Go to the documentation of this file.
1 
6 #ifndef matrixmult_hh
7 #define matrixmult_hh
8 
9 #include "matrixIterator.hh"
10 #include "basics/exceptions.hh"
11 #include "basics/debug.hh"
12 
13 #define MatrixMultRowSort_D 0
14 
15 namespace concepts {
16 
17  // ********************************************** matrixMultiplyRowSorting **
18 
27  template<class F, class G, class H>
28  void matrixMultiplyRowSorting(const F& factL, const G& factR,
29  Matrix<H>& dest) {
30  conceptsAssert(factL.nofCols() == factR.nofRows(), Assertion());
31  conceptsAssert(factL.nofRows() == dest.nofRows(), Assertion());
32  conceptsAssert(factR.nofCols() == dest.nofCols(), Assertion());
33  DEBUGL(MatrixMultRowSort_D, "factL = " << factL << ", factR = " << factR);
34 
35  // current column and row in the left matrix
36  uint col, row;
37  // current value in left matrix
38  typename F::type value;
39 
40  typename F::const_iterator factL_end = factL.end();
41  typename G::const_iterator factR_end = factR.end();
42  // iterator over one row in factR
43  for(typename F::const_iterator i = factL.begin(); i != factL_end; ++i) {
44  DEBUGL(MatrixMultRowSort_D, "i = " << i);
45  col = i.col();
46  row = i.row();
47  value = *i;
48  for(typename G::const_iterator j = factR.begin(col);
49  j != factR_end && j.row() == col; ++j) {
50  DEBUGL(MatrixMultRowSort_D, "j = " << j);
51  dest(row, j.col()) += value * *j;
52  }
53  }
54  DEBUGL(MatrixMultRowSort_D, "done");
55  }
56 
57 } // namespace concepts
58 
59 #endif // matrixmult_hh
#define MatrixMultRowSort_D
Definition: matrixMult.hh:13
const uint nofRows() const
Number of rows.
Definition: matrix.hh:56
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
#define DEBUGL(doit, msg)
const uint nofCols() const
Number of columns.
Definition: matrix.hh:58
Exception class for assertions.
Definition: exceptions.hh:258
Abstract class for an operator.
Definition: compositions.hh:31
void matrixMultiplyRowSorting(const F &factL, const G &factR, Matrix< H > &dest)
Multiplies two matrices, which deliver at least a row sorted iterator, and adds (!...
Definition: matrixMult.hh:28
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich