123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- #ifndef CERES_INTERNAL_INNER_PRODUCT_COMPUTER_H_
- #define CERES_INTERNAL_INNER_PRODUCT_COMPUTER_H_
- #include <memory>
- #include <vector>
- #include "ceres/block_sparse_matrix.h"
- #include "ceres/compressed_row_sparse_matrix.h"
- #include "ceres/internal/disable_warnings.h"
- #include "ceres/internal/export.h"
- namespace ceres::internal {
- class CERES_NO_EXPORT InnerProductComputer {
- public:
-
-
-
-
-
-
-
-
-
-
-
- static std::unique_ptr<InnerProductComputer> Create(
- const BlockSparseMatrix& m,
- CompressedRowSparseMatrix::StorageType storage_type);
-
-
-
-
-
- static std::unique_ptr<InnerProductComputer> Create(
- const BlockSparseMatrix& m,
- int start_row_block,
- int end_row_block,
- CompressedRowSparseMatrix::StorageType storage_type);
-
- void Compute();
-
-
-
-
- const CompressedRowSparseMatrix& result() const { return *result_; }
- CompressedRowSparseMatrix* mutable_result() const { return result_.get(); }
- private:
-
-
- struct ProductTerm {
- ProductTerm(const int row, const int col, const int index)
- : row(row), col(col), index(index) {}
- bool operator<(const ProductTerm& right) const {
- if (row == right.row) {
- if (col == right.col) {
- return index < right.index;
- }
- return col < right.col;
- }
- return row < right.row;
- }
- int row;
- int col;
- int index;
- };
- InnerProductComputer(const BlockSparseMatrix& m,
- int start_row_block,
- int end_row_block);
- void Init(CompressedRowSparseMatrix::StorageType storage_type);
- std::unique_ptr<CompressedRowSparseMatrix> CreateResultMatrix(
- const CompressedRowSparseMatrix::StorageType storage_type,
- int num_nonzeros);
- int ComputeNonzeros(const std::vector<ProductTerm>& product_terms,
- std::vector<int>* row_block_nnz);
- void ComputeOffsetsAndCreateResultMatrix(
- const CompressedRowSparseMatrix::StorageType storage_type,
- const std::vector<ProductTerm>& product_terms);
- const BlockSparseMatrix& m_;
- const int start_row_block_;
- const int end_row_block_;
- std::unique_ptr<CompressedRowSparseMatrix> result_;
-
-
-
-
-
-
- std::vector<int> result_offsets_;
- };
- }
- #include "ceres/internal/reenable_warnings.h"
- #endif
|