123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- #ifndef CERES_INTERNAL_BLOCK_STRUCTURE_H_
- #define CERES_INTERNAL_BLOCK_STRUCTURE_H_
- #include <cstdint>
- #include <vector>
- #include "ceres/internal/export.h"
- namespace ceres {
- namespace internal {
- using BlockSize = int32_t;
- struct CERES_NO_EXPORT Block {
- Block() = default;
- Block(int size_, int position_) noexcept : size(size_), position(position_) {}
- BlockSize size{-1};
- int position{-1};
- };
- inline bool operator==(const Block& left, const Block& right) noexcept {
- return (left.size == right.size) && (left.position == right.position);
- }
- struct CERES_NO_EXPORT Cell {
- Cell() = default;
- Cell(int block_id_, int position_) noexcept
- : block_id(block_id_), position(position_) {}
-
- int block_id{-1};
-
- int position{-1};
- };
- CERES_NO_EXPORT bool CellLessThan(const Cell& lhs, const Cell& rhs);
- struct CERES_NO_EXPORT CompressedList {
- CompressedList() = default;
-
-
- explicit CompressedList(int num_cells) noexcept : cells(num_cells) {}
- Block block;
- std::vector<Cell> cells;
-
- int nnz{-1};
-
-
- int cumulative_nnz{-1};
- };
- using CompressedRow = CompressedList;
- using CompressedColumn = CompressedList;
- struct CERES_NO_EXPORT CompressedRowBlockStructure {
- std::vector<Block> cols;
- std::vector<CompressedRow> rows;
- };
- struct CERES_NO_EXPORT CompressedColumnBlockStructure {
- std::vector<Block> rows;
- std::vector<CompressedColumn> cols;
- };
- inline int NumScalarEntries(const std::vector<Block>& blocks) {
- if (blocks.empty()) {
- return 0;
- }
- auto& block = blocks.back();
- return block.position + block.size;
- }
- std::vector<Block> Tail(const std::vector<Block>& blocks, int n);
- int SumSquaredSizes(const std::vector<Block>& blocks);
- }
- }
- #endif
|