Point Cloud Library (PCL)  1.12.1
0010-Repair-sparse-matrix.hpp
1 Backport of
2 
3 ---
4 From d253f645f0bfbcd2c818fa5d0a6970c61f39c6b5 Mon Sep 17 00:00:00 2001
5 From: Thomas Dickerson <elfprince13@gmail.com>
6 Date: Thu, 12 May 2022 14:28:41 -0400
7 Subject: [PATCH] Repair sparse_matrix.hpp
8 
9 Unclear why nobody has noticed for a decade that this code was just totally uncompilable. `SparseMatrix` does not have methods `Columns()` or `Rows()`, and `m_ppElements[i]` is a pointer so can't possibly have anything called with `.`.
10 ---
11  .../3rdparty/poisson4/sparse_matrix.hpp | 18 +++++++++---------
12  1 file changed, 9 insertions(+), 9 deletions(-)
13 
14 Index: pcl-1.12.1+dfsg/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp
15 ===================================================================
16 --- pcl-1.12.1+dfsg.orig/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp
17 +++ pcl-1.12.1+dfsg/surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp
18 @@ -250,9 +250,9 @@ namespace pcl
19  template<class T>
20  SparseMatrix<T>& SparseMatrix<T>::operator *= (const T& V)
21  {
22 - for (int i=0; i<this->Rows(); i++)
23 + for (int i=0; i<rows; i++)
24  {
25 - for(int ii=0;ii<m_ppElements[i].size();ii++){m_ppElements[i][ii].Value*=V;}
26 + for(int ii=0;ii<rowSizes[i];ii++){m_ppElements[i][ii].Value*=V;}
27  }
28  return *this;
29  }
30 @@ -260,12 +260,12 @@ namespace pcl
31  template<class T>
32  SparseMatrix<T> SparseMatrix<T>::Multiply( const SparseMatrix<T>& M ) const
33  {
34 - SparseMatrix<T> R( this->Rows(), M.Columns() );
35 - for(int i=0; i<R.Rows(); i++){
36 - for(int ii=0;ii<m_ppElements[i].size();ii++){
37 + SparseMatrix<T> R( rows, M._maxEntriesPerRow );
38 + for(int i=0; i<rows; i++){
39 + for(int ii=0;ii<rowSizes[i];ii++){
40  int N=m_ppElements[i][ii].N;
41  T Value=m_ppElements[i][ii].Value;
42 - for(int jj=0;jj<M.m_ppElements[N].size();jj++){
43 + for(int jj=0;jj<M.rowSizes[N];jj++){
44  R(i,M.m_ppElements[N][jj].N) += Value * M.m_ppElements[N][jj].Value;
45  }
46  }
47 @@ -319,11 +319,11 @@ namespace pcl
48  template<class T>
49  SparseMatrix<T> SparseMatrix<T>::Transpose() const
50  {
51 - SparseMatrix<T> M( this->Columns(), this->Rows() );
52 + SparseMatrix<T> M( _maxEntriesPerRow, rows );
53 
54 - for (int i=0; i<this->Rows(); i++)
55 + for (int i=0; i<rows; i++)
56  {
57 - for(int ii=0;ii<m_ppElements[i].size();ii++){
58 + for(int ii=0;ii<rowSizes[i];ii++){
59  M(m_ppElements[i][ii].N,i) = m_ppElements[i][ii].Value;
60  }
61  }
Definition: inftrees.h:24