Пример #1
0
int main(int argc, char** argv) {
  cout << "> Creating sm <" << endl;
  SparseMatrix<int> sm;
  cin >> sm;
  cout << sm << endl;
  sm.Output(cout);

  SparseMatrix<int> tsm;
  sm.Transpose(tsm);
  cout << tsm << endl;
  tsm.Output(cout);

  //-------------------------------------------------------
  cout << "> Creating sm2 <" << endl;
  SparseMatrix<int> sm2;
  cin >> sm2;
  cout << sm2 << endl;
  sm2.Output(cout);

  SparseMatrix<int> sm3;
  sm.Add(sm2, sm3);
  cout << sm3 << endl;
  sm3.Output(cout);

  return 0;
}
Пример #2
0
int main()
{
   int val[8] = {15, 22, -15, 11, 3, -6, 91, 28};
   int val2[5] = {1, 2, 1, 3, 1};
   int val3[3] = {1, 1, 1};
   SparseMatrix a;
   a.Init2(val2);
   SparseMatrix b;
   b.Init3(val3);
   a.Output();
   b.Output();
   SparseMatrix c = a.Multiply(b);
   c.Output();
}