Ejemplo n.º 1
0
Matrix mult(const SpMatrix &lhs, const SpMatrix &rhs, int row, int col) {
  Matrix res(row, Array(col, 0));
  for (auto& l:lhs) {
    for (auto& v:l.second){
      int i=l.first;
      int k=v.first;
      if (!rhs.count(k)) continue;
      for (auto& r:rhs.find(k)->second){
        int j=r.first;
        res[i][j] = res[i][j] + v.second * r.second;
      }
    }
  }
  return res;
}