Repair sparse_matrix.hpp
authorThomas Dickerson <elfprince13@gmail.com>
Thu, 12 May 2022 18:28:41 +0000 (14:28 -0400)
committerJochen Sprickerhof <jspricke@debian.org>
Sun, 25 Sep 2022 10:41:19 +0000 (11:41 +0100)
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 `.`.

Gbp-Pq: Name 0009-Repair-sparse_matrix.hpp.patch

surface/include/pcl/surface/3rdparty/poisson4/sparse_matrix.hpp

index e6564cdc5bb729265e8f4baced67c6aa7ed7bf8f..02c2db5bd556099b53f9920d14b7bc795766e617 100644 (file)
@@ -250,9 +250,9 @@ namespace pcl
     template<class T>
     SparseMatrix<T>& SparseMatrix<T>::operator *= (const T& V)
     {
-      for (int i=0; i<this->Rows(); i++)
+      for (int i=0; i<rows; i++)
       {
-        for(int ii=0;ii<m_ppElements[i].size();i++){m_ppElements[i][ii].Value*=V;}
+        for(int ii=0;ii<rowSizes[i];i++){m_ppElements[i][ii].Value*=V;}
       }
       return *this;
     }
@@ -260,12 +260,12 @@ namespace pcl
     template<class T>
     SparseMatrix<T> SparseMatrix<T>::Multiply( const SparseMatrix<T>& M ) const
     {
-      SparseMatrix<T> R( this->Rows(), M.Columns() );
-      for(int i=0; i<R.Rows(); i++){
-        for(int ii=0;ii<m_ppElements[i].size();ii++){
+      SparseMatrix<T> R( rows, M._maxEntriesPerRow );
+      for(int i=0; i<R.rows; i++){
+        for(int ii=0;ii<rowSizes[i];ii++){
           int N=m_ppElements[i][ii].N;
           T Value=m_ppElements[i][ii].Value;
-          for(int jj=0;jj<M.m_ppElements[N].size();jj++){
+          for(int jj=0;jj<M.rowSizes[N];jj++){
             R(i,M.m_ppElements[N][jj].N) += Value * M.m_ppElements[N][jj].Value;
           }
         }
@@ -319,11 +319,11 @@ namespace pcl
     template<class T>
     SparseMatrix<T> SparseMatrix<T>::Transpose() const
     {
-      SparseMatrix<T> M( this->Columns(), this->Rows() );
+      SparseMatrix<T> M( _maxEntriesPerRow, rows );
 
-      for (int i=0; i<this->Rows(); i++)
+      for (int i=0; i<rows; i++)
       {
-        for(int ii=0;ii<m_ppElements[i].size();ii++){
+        for(int ii=0;ii<rowSizes[i];ii++){
           M(m_ppElements[i][ii].N,i) = m_ppElements[i][ii].Value;
         }
       }