123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- #include <memory>
- #include "ceres/linear_solver.h"
- #include "ceres/partitioned_matrix_view.h"
- namespace ceres::internal {
- PartitionedMatrixViewBase::~PartitionedMatrixViewBase() = default;
- std::unique_ptr<PartitionedMatrixViewBase> PartitionedMatrixViewBase::Create(
- const LinearSolver::Options& options, const BlockSparseMatrix& matrix) {
- #ifndef CERES_RESTRICT_SCHUR_SPECIALIZATION
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 2) &&
- (options.f_block_size == 2)) {
- return std::make_unique<PartitionedMatrixView<2,2, 2>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 2) &&
- (options.f_block_size == 3)) {
- return std::make_unique<PartitionedMatrixView<2,2, 3>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 2) &&
- (options.f_block_size == 4)) {
- return std::make_unique<PartitionedMatrixView<2,2, 4>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 2)) {
- return std::make_unique<PartitionedMatrixView<2,2, Eigen::Dynamic>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 3) &&
- (options.f_block_size == 3)) {
- return std::make_unique<PartitionedMatrixView<2,3, 3>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 3) &&
- (options.f_block_size == 4)) {
- return std::make_unique<PartitionedMatrixView<2,3, 4>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 3) &&
- (options.f_block_size == 6)) {
- return std::make_unique<PartitionedMatrixView<2,3, 6>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 3) &&
- (options.f_block_size == 9)) {
- return std::make_unique<PartitionedMatrixView<2,3, 9>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 3)) {
- return std::make_unique<PartitionedMatrixView<2,3, Eigen::Dynamic>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 4) &&
- (options.f_block_size == 3)) {
- return std::make_unique<PartitionedMatrixView<2,4, 3>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 4) &&
- (options.f_block_size == 4)) {
- return std::make_unique<PartitionedMatrixView<2,4, 4>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 4) &&
- (options.f_block_size == 6)) {
- return std::make_unique<PartitionedMatrixView<2,4, 6>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 4) &&
- (options.f_block_size == 8)) {
- return std::make_unique<PartitionedMatrixView<2,4, 8>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 4) &&
- (options.f_block_size == 9)) {
- return std::make_unique<PartitionedMatrixView<2,4, 9>>(
- options, matrix);
- }
- if ((options.row_block_size == 2) &&
- (options.e_block_size == 4)) {
- return std::make_unique<PartitionedMatrixView<2,4, Eigen::Dynamic>>(
- options, matrix);
- }
- if (options.row_block_size == 2) {
- return std::make_unique<PartitionedMatrixView<2,Eigen::Dynamic, Eigen::Dynamic>>(
- options, matrix);
- }
- if ((options.row_block_size == 3) &&
- (options.e_block_size == 3) &&
- (options.f_block_size == 3)) {
- return std::make_unique<PartitionedMatrixView<3,3, 3>>(
- options, matrix);
- }
- if ((options.row_block_size == 4) &&
- (options.e_block_size == 4) &&
- (options.f_block_size == 2)) {
- return std::make_unique<PartitionedMatrixView<4,4, 2>>(
- options, matrix);
- }
- if ((options.row_block_size == 4) &&
- (options.e_block_size == 4) &&
- (options.f_block_size == 3)) {
- return std::make_unique<PartitionedMatrixView<4,4, 3>>(
- options, matrix);
- }
- if ((options.row_block_size == 4) &&
- (options.e_block_size == 4) &&
- (options.f_block_size == 4)) {
- return std::make_unique<PartitionedMatrixView<4,4, 4>>(
- options, matrix);
- }
- if ((options.row_block_size == 4) &&
- (options.e_block_size == 4)) {
- return std::make_unique<PartitionedMatrixView<4,4, Eigen::Dynamic>>(
- options, matrix);
- }
- #endif
- VLOG(1) << "Template specializations not found for <"
- << options.row_block_size << "," << options.e_block_size << ","
- << options.f_block_size << ">";
- return std::make_unique<PartitionedMatrixView<Eigen::Dynamic,
- Eigen::Dynamic,
- Eigen::Dynamic>>(
- options, matrix);
- };
- }
|