Matrix generation cleanup

1. Convert a CompressedRowSparseMatrix constructor which
takes a TripletSparseMatrix as input into a factory method
which allows the input to be transposed.

2. Move the random matrix creation routine for CompressedRowSparseMatrix
from being a standalone function to a static method.

3. Add a corresponding random matrix generation static method to
TripletSparseMatrix.

4. Add a new constructor to TripletSparseMatrix, which takes as input
the row, col and values arrays.

Change-Id: Iec7b184646818f432a5e6822bea3b2f3128a82aa
This commit is contained in:
Sameer Agarwal
2017-05-01 17:24:22 -07:00
parent d72e19d985
commit 086ff01aca
8 changed files with 371 additions and 130 deletions
+8 -7
View File
@@ -547,15 +547,16 @@ SparseSchurComplementSolver::SolveReducedLinearSystemUsingEigen(
}
// This is an upper triangular matrix.
CompressedRowSparseMatrix crsm(*tsm);
scoped_ptr<CompressedRowSparseMatrix> crsm(
CompressedRowSparseMatrix::FromTripletSparseMatrix(*tsm));
// Map this to a column major, lower triangular matrix.
Eigen::MappedSparseMatrix<double, Eigen::ColMajor> eigen_lhs(
crsm.num_rows(),
crsm.num_rows(),
crsm.num_nonzeros(),
crsm.mutable_rows(),
crsm.mutable_cols(),
crsm.mutable_values());
crsm->num_rows(),
crsm->num_rows(),
crsm->num_nonzeros(),
crsm->mutable_rows(),
crsm->mutable_cols(),
crsm->mutable_values());
event_logger.AddEvent("ToCompressedRowSparseMatrix");
// Compute symbolic factorization if one does not exist.