| 1431 | } |
| 1432 | |
| 1433 | shared_ptr<SparseMatrixSymmetric<double,double>> |
| 1434 | GetSymmetricMatrix (SparseMatrixTM<double> & mat) |
| 1435 | { |
| 1436 | Array<int> cnt(mat.Width()); |
| 1437 | cnt = 0; |
| 1438 | for (int i = 0; i < mat.Height(); i++) |
| 1439 | for (int c : mat.GetRowIndices(i)) |
| 1440 | if (c <= i) |
| 1441 | cnt[i]++; |
| 1442 | |
| 1443 | auto symm = make_shared<SparseMatrixSymmetric<double>>(cnt); |
| 1444 | |
| 1445 | for (int i = 0; i < mat.Height(); i++) |
| 1446 | for (int ci : Range(symm->GetRowIndices(i))) |
| 1447 | { |
| 1448 | symm -> GetRowIndices(i)[ci] = mat.GetRowIndices(i)[ci]; |
| 1449 | symm -> GetRowValues(i)[ci] = mat.GetRowValues(i)[ci]; |
| 1450 | } |
| 1451 | |
| 1452 | return symm; |
| 1453 | } |
| 1454 | |
| 1455 | |
| 1456 | template <typename T> |