Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extern/ceres/internal/ceres/triplet_sparse_matrix.cc')
-rw-r--r--extern/ceres/internal/ceres/triplet_sparse_matrix.cc26
1 files changed, 11 insertions, 15 deletions
diff --git a/extern/ceres/internal/ceres/triplet_sparse_matrix.cc b/extern/ceres/internal/ceres/triplet_sparse_matrix.cc
index 54b588ba466..5dbf0e7cd3a 100644
--- a/extern/ceres/internal/ceres/triplet_sparse_matrix.cc
+++ b/extern/ceres/internal/ceres/triplet_sparse_matrix.cc
@@ -43,11 +43,7 @@ namespace ceres {
namespace internal {
TripletSparseMatrix::TripletSparseMatrix()
- : num_rows_(0),
- num_cols_(0),
- max_num_nonzeros_(0),
- num_nonzeros_(0) {}
-
+ : num_rows_(0), num_cols_(0), max_num_nonzeros_(0), num_nonzeros_(0) {}
TripletSparseMatrix::~TripletSparseMatrix() {}
@@ -111,9 +107,11 @@ TripletSparseMatrix& TripletSparseMatrix::operator=(
bool TripletSparseMatrix::AllTripletsWithinBounds() const {
for (int i = 0; i < num_nonzeros_; ++i) {
+ // clang-format off
if ((rows_[i] < 0) || (rows_[i] >= num_rows_) ||
(cols_[i] < 0) || (cols_[i] >= num_cols_))
return false;
+ // clang-format on
}
return true;
}
@@ -123,8 +121,7 @@ void TripletSparseMatrix::Reserve(int new_max_num_nonzeros) {
<< "Reallocation will cause data loss";
// Nothing to do if we have enough space already.
- if (new_max_num_nonzeros <= max_num_nonzeros_)
- return;
+ if (new_max_num_nonzeros <= max_num_nonzeros_) return;
int* new_rows = new int[new_max_num_nonzeros];
int* new_cols = new int[new_max_num_nonzeros];
@@ -168,15 +165,15 @@ void TripletSparseMatrix::CopyData(const TripletSparseMatrix& orig) {
}
}
-void TripletSparseMatrix::RightMultiply(const double* x, double* y) const {
+void TripletSparseMatrix::RightMultiply(const double* x, double* y) const {
for (int i = 0; i < num_nonzeros_; ++i) {
- y[rows_[i]] += values_[i]*x[cols_[i]];
+ y[rows_[i]] += values_[i] * x[cols_[i]];
}
}
void TripletSparseMatrix::LeftMultiply(const double* x, double* y) const {
for (int i = 0; i < num_nonzeros_; ++i) {
- y[cols_[i]] += values_[i]*x[rows_[i]];
+ y[cols_[i]] += values_[i] * x[rows_[i]];
}
}
@@ -226,10 +223,9 @@ void TripletSparseMatrix::AppendCols(const TripletSparseMatrix& B) {
num_cols_ = num_cols_ + B.num_cols();
}
-
void TripletSparseMatrix::Resize(int new_num_rows, int new_num_cols) {
if ((new_num_rows >= num_rows_) && (new_num_cols >= num_cols_)) {
- num_rows_ = new_num_rows;
+ num_rows_ = new_num_rows;
num_cols_ = new_num_cols;
return;
}
@@ -245,9 +241,9 @@ void TripletSparseMatrix::Resize(int new_num_rows, int new_num_cols) {
for (int i = 0; i < num_nonzeros_; ++i) {
if ((r_ptr[i] < num_rows_) && (c_ptr[i] < num_cols_)) {
if (dropped_terms) {
- r_ptr[i-dropped_terms] = r_ptr[i];
- c_ptr[i-dropped_terms] = c_ptr[i];
- v_ptr[i-dropped_terms] = v_ptr[i];
+ r_ptr[i - dropped_terms] = r_ptr[i];
+ c_ptr[i - dropped_terms] = c_ptr[i];
+ v_ptr[i - dropped_terms] = v_ptr[i];
}
} else {
++dropped_terms;