Răsfoiți Sursa

still unstable, towards uint-support

Alexander Freytag 9 ani în urmă
părinte
comite
e6650e029e
3 a modificat fișierele cu 221 adăugiri și 213 ștergeri
  1. 29 29
      FeatureMatrixT.h
  2. 49 49
      FeatureMatrixT.tcc
  3. 143 135
      SortedVectorSparse.h

+ 29 - 29
FeatureMatrixT.h

@@ -115,7 +115,7 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     * @param examples set of example indices
     * @param examples set of example indices
     */
     */
     FeatureMatrixT(const sparse_t & _features, 
     FeatureMatrixT(const sparse_t & _features, 
-                   const std::map<int, int> & _examples , 
+                   const std::map<uint, uint> & _examples , 
                    const uint & _dim = 0);
                    const uint & _dim = 0);
 #endif
 #endif
 
 
@@ -193,8 +193,8 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 07-12-2011 (dd-mm-yyyy)
     * @date 07-12-2011 (dd-mm-yyyy)
     */
     */
-    inline T operator()(const int _row, 
-                        const int _col
+    inline T operator()(const uint _row, 
+                        const uint _col
                        ) const;
                        ) const;
     
     
     /** 
     /** 
@@ -202,16 +202,16 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 08-12-2011 (dd-mm-yyyy)
     * @date 08-12-2011 (dd-mm-yyyy)
     */
     */
-    inline T getUnsafe(const int _row,
-                       const int _col
+    inline T getUnsafe(const uint _row,
+                       const uint _col
                       ) const;
                       ) const;
 
 
     /** 
     /** 
     * @brief Element access of original values without validity check
     * @brief Element access of original values without validity check
     * @author Erik Rodner
     * @author Erik Rodner
     */
     */
-    inline T getOriginal(const int _row,
-                         const int _col
+    inline T getOriginal(const uint _row,
+                         const uint _col
                         ) const;
                         ) const;
 
 
     /** 
     /** 
@@ -219,8 +219,8 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 07-12-2011 (dd-mm-yyyy)
     * @date 07-12-2011 (dd-mm-yyyy)
     */
     */
-    inline void set (const int _row, 
-                     const int _col, 
+    inline void set (const uint _row, 
+                     const uint _col, 
                      const T & _newElement, 
                      const T & _newElement, 
                      bool _setTransformedValue = false
                      bool _setTransformedValue = false
                     );
                     );
@@ -230,8 +230,8 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 08-12-2011 (dd-mm-yyyy)
     * @date 08-12-2011 (dd-mm-yyyy)
     */
     */
-    inline void setUnsafe (const int _row, 
-                           const int _col, 
+    inline void setUnsafe (const uint _row, 
+                           const uint _col, 
                            const T & _newElement, 
                            const T & _newElement, 
                            bool _setTransformedValue = false
                            bool _setTransformedValue = false
                           );
                           );
@@ -261,7 +261,7 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     */
     */
     void findFirstInDimension(const uint & _dim, 
     void findFirstInDimension(const uint & _dim, 
                               const T & _elem, 
                               const T & _elem, 
-                              int & _position
+                              uint & _position
                              ) const;
                              ) const;
     
     
     /** 
     /** 
@@ -271,7 +271,7 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     */
     */
     void findLastInDimension(const uint & _dim, 
     void findLastInDimension(const uint & _dim, 
                              const T & _elem, 
                              const T & _elem, 
-                             int & _position
+                             uint & _position
                             ) const;
                             ) const;
     
     
     /** 
     /** 
@@ -281,7 +281,7 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     */
     */
     void findFirstLargerInDimension(const uint & _dim, 
     void findFirstLargerInDimension(const uint & _dim, 
                                     const T & elem, 
                                     const T & elem, 
-                                    int & position
+                                    uint & position
                                    ) const;
                                    ) const;
     
     
     /** 
     /** 
@@ -291,7 +291,7 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     */
     */
     void findLastSmallerInDimension(const uint & _dim, 
     void findLastSmallerInDimension(const uint & _dim, 
                                     const T & _elem, 
                                     const T & _elem, 
-                                    int & _position
+                                    uint & _position
                                    ) const;
                                    ) const;
     
     
     //------------------------------------------------------
     //------------------------------------------------------
@@ -344,11 +344,11 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     * @date 07-12-2011 (dd-mm-yyyy)
     * @date 07-12-2011 (dd-mm-yyyy)
     */
     */
     void set_features(const std::vector<std::vector<T> > & _features, 
     void set_features(const std::vector<std::vector<T> > & _features, 
-                      std::vector<std::vector<int> > & _permutations, 
+                      std::vector<std::vector<uint> > & _permutations, 
                       const uint & _dim = 0
                       const uint & _dim = 0
                      );
                      );
     void set_features(const std::vector<std::vector<T> > & _features, 
     void set_features(const std::vector<std::vector<T> > & _features, 
-                      std::vector<std::map<int,int> > & _permutations, 
+                      std::vector<std::map<uint,uint> > & _permutations, 
                       const uint & _dim = 0
                       const uint & _dim = 0
                      );
                      );
     void set_features(const std::vector<std::vector<T> > & _features, 
     void set_features(const std::vector<std::vector<T> > & _features, 
@@ -364,8 +364,8 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     *
     *
     * @param resulting permutation matrix
     * @param resulting permutation matrix
     */
     */
-    void getPermutations( std::vector<std::vector<int> > & _permutations) const;
-    void getPermutations( std::vector<std::map<int,int> > & _permutations) const;
+    void getPermutations( std::vector<std::vector<uint> > & _permutations) const;
+    void getPermutations( std::vector<std::map<uint,uint> > & _permutations) const;
       
       
     /** 
     /** 
     * @brief Prints the whole Matrix (outer loop over dimension, inner loop over features)
     * @brief Prints the whole Matrix (outer loop over dimension, inner loop over features)
@@ -397,10 +397,10 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 08-12-2011 (dd-mm-yyyy)
     * @date 08-12-2011 (dd-mm-yyyy)
     */
     */
-    void swap(const int & _row1, 
-              const int & _col1,
-              const int & _row2, 
-              const int & _col2
+    void swap(const uint & _row1, 
+              const uint & _col1,
+              const uint & _row2, 
+              const uint & _col2
              );
              );
     
     
     /** 
     /** 
@@ -408,10 +408,10 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 08-12-2011 (dd-mm-yyyy)
     * @date 08-12-2011 (dd-mm-yyyy)
     */
     */
-    void swapUnsafe(const int & _row1, 
-                    const int & _col1, 
-                    const int & _row2, 
-                    const int & _col2
+    void swapUnsafe(const uint & _row1, 
+                    const uint & _col1, 
+                    const uint & _row2, 
+                    const uint & _col2
                    );
                    );
 
 
     /**
     /**
@@ -452,14 +452,14 @@ template<class T> class FeatureMatrixT : public NICE::Persistent
     *
     *
     * @return number of nonzero elements on the specified dimension
     * @return number of nonzero elements on the specified dimension
     */ 
     */ 
-    int getNumberOfNonZeroElementsPerDimension(const uint & _dim) const;
+    uint getNumberOfNonZeroElementsPerDimension(const uint & _dim) const;
    
    
     /**
     /**
     * @brief Return the number of zero elements in a specified dimension, that are currently stored in the feature matrix
     * @brief Return the number of zero elements in a specified dimension, that are currently stored in the feature matrix
     *
     *
     * @return number of nonzero elements on the specified dimension
     * @return number of nonzero elements on the specified dimension
     */ 
     */ 
-    int getNumberOfZeroElementsPerDimension(const uint & _dim) const;
+    uint getNumberOfZeroElementsPerDimension(const uint & _dim) const;
     
     
     /** Persistent interface */
     /** Persistent interface */
     virtual void restore ( std::istream & _is, int _format = 0 );
     virtual void restore ( std::istream & _is, int _format = 0 );

+ 49 - 49
FeatureMatrixT.tcc

@@ -102,7 +102,7 @@ namespace NICE {
       else //we have examples x dimes (as usually done)
       else //we have examples x dimes (as usually done)
       {
       {
         //loop over every example to add its content
         //loop over every example to add its content
-        for (int nr = 0; nr < this->ui_n; nr++)
+        for (uint nr = 0; nr < this->ui_n; nr++)
         {
         {
           //loop over every dimension to add the specific value to the corresponding SortedVectorSparse
           //loop over every dimension to add the specific value to the corresponding SortedVectorSparse
           for (NICE::SparseVector::const_iterator elemIt = _X[nr]->begin(); elemIt != _X[nr]->end(); elemIt++)
           for (NICE::SparseVector::const_iterator elemIt = _X[nr]->begin(); elemIt != _X[nr]->end(); elemIt++)
@@ -131,7 +131,7 @@ namespace NICE {
       else
       else
         set_d( _dim );
         set_d( _dim );
       
       
-      int nMax(0);
+      uint nMax(0);
 
 
       for ( uint i = 0; i < _features.njc-1; i++ ) //walk over dimensions
       for ( uint i = 0; i < _features.njc-1; i++ ) //walk over dimensions
       {
       {
@@ -154,7 +154,7 @@ namespace NICE {
     template <typename T>
     template <typename T>
     FeatureMatrixT<T>::
     FeatureMatrixT<T>::
     FeatureMatrixT(const sparse_t & _features, 
     FeatureMatrixT(const sparse_t & _features, 
-                   const std::map<int, int> & _examples, 
+                   const std::map<uint, uint> & _examples, 
                    const uint & _dim)
                    const uint & _dim)
     {
     {
       if (_dim < 0)
       if (_dim < 0)
@@ -162,14 +162,14 @@ namespace NICE {
       else
       else
         set_d(_dim);
         set_d(_dim);
       
       
-      int nMax(0);
+      uint nMax(0);
 
 
       for ( uint i = 0; i < _features.njc-1; i++ ) //walk over dimensions
       for ( uint i = 0; i < _features.njc-1; i++ ) //walk over dimensions
       {
       {
         for ( uint j = _features.jc[i]; j < _features.jc[i+1] && j < _features.ndata; j++ ) //walk over single features, which are sparsely represented
         for ( uint j = _features.jc[i]; j < _features.jc[i+1] && j < _features.ndata; j++ ) //walk over single features, which are sparsely represented
         {
         {
-          int example_index = _features.ir[ j];
-          std::map<int, int>::const_iterator it = examples.find(example_index);
+          uint example_index = _features.ir[ j];
+          std::map<uint, uint>::const_iterator it = examples.find(example_index);
           if ( it != examples.end() ) {
           if ( it != examples.end() ) {
             this->features[i].insert(((T*)_features.data)[j], it->second /* new index */);
             this->features[i].insert(((T*)_features.data)[j], it->second /* new index */);
             if (it->second > nMax) 
             if (it->second > nMax) 
@@ -243,8 +243,8 @@ namespace NICE {
       
       
     //  Matrix-like operator for element access, performs validity check
     //  Matrix-like operator for element access, performs validity check
     template <typename T>
     template <typename T>
-    inline T FeatureMatrixT<T>::operator()(const int _row, 
-                                           const int _col
+    inline T FeatureMatrixT<T>::operator()(const uint _row, 
+                                           const uint _col
                                           ) const
                                           ) const
     {
     {
       if ( (_row < 0) || (_col < 0) || (_row > this->ui_d) || (_col > this->ui_n) )
       if ( (_row < 0) || (_col < 0) || (_row > this->ui_d) || (_col > this->ui_n) )
@@ -325,8 +325,8 @@ namespace NICE {
     
     
     //  Element access without validity check
     //  Element access without validity check
     template <typename T>
     template <typename T>
-    inline T FeatureMatrixT<T>::getUnsafe(const int _row, 
-                                          const int _col
+    inline T FeatureMatrixT<T>::getUnsafe(const uint _row, 
+                                          const uint _col
                                          ) const
                                          ) const
     {
     {
       return (this->features[_row]).access(_col);
       return (this->features[_row]).access(_col);
@@ -334,8 +334,8 @@ namespace NICE {
 
 
     //! Element access of original values without validity check
     //! Element access of original values without validity check
     template <typename T>
     template <typename T>
-    inline T FeatureMatrixT<T>::getOriginal(const int _row, 
-                                            const int _col
+    inline T FeatureMatrixT<T>::getOriginal(const uint _row, 
+                                            const uint _col
                                            ) const
                                            ) const
     {
     {
       return (this->features[_row]).accessOriginal(_col);
       return (this->features[_row]).accessOriginal(_col);
@@ -343,8 +343,8 @@ namespace NICE {
 
 
     //  Sets a specified element to the given value, performs validity check
     //  Sets a specified element to the given value, performs validity check
     template <typename T>
     template <typename T>
-    inline void FeatureMatrixT<T>::set (const int _row, 
-                                        const int _col, 
+    inline void FeatureMatrixT<T>::set (const uint _row, 
+                                        const uint _col, 
                                         const T & _newElement, 
                                         const T & _newElement, 
                                         bool _setTransformedValue
                                         bool _setTransformedValue
                                        )
                                        )
@@ -359,8 +359,8 @@ namespace NICE {
     
     
     //  Sets a specified element to the given value, without validity check
     //  Sets a specified element to the given value, without validity check
     template <typename T>
     template <typename T>
-    inline void FeatureMatrixT<T>::setUnsafe (const int _row, 
-                                              const int _col, 
+    inline void FeatureMatrixT<T>::setUnsafe (const uint _row, 
+                                              const uint _col, 
                                               const T & _newElement, 
                                               const T & _newElement, 
                                               bool _setTransformedValue
                                               bool _setTransformedValue
                                              )
                                              )
@@ -395,7 +395,7 @@ namespace NICE {
     template <typename T>
     template <typename T>
     void FeatureMatrixT<T>::findFirstInDimension(const uint & _dim, 
     void FeatureMatrixT<T>::findFirstInDimension(const uint & _dim, 
                                                  const T & _elem, 
                                                  const T & _elem, 
-                                                 int & _position
+                                                 uint & _position
                                                 ) const
                                                 ) const
     {
     {
       _position = 0;
       _position = 0;
@@ -416,7 +416,7 @@ namespace NICE {
     template <typename T>
     template <typename T>
     void FeatureMatrixT<T>::findLastInDimension(const uint & _dim, 
     void FeatureMatrixT<T>::findLastInDimension(const uint & _dim, 
                                                 const T & _elem, 
                                                 const T & _elem, 
-                                                int & _position
+                                                uint & _position
                                                ) const
                                                ) const
     {
     {
       _position = 0;
       _position = 0;
@@ -435,7 +435,7 @@ namespace NICE {
     template <typename T>
     template <typename T>
     void FeatureMatrixT<T>::findFirstLargerInDimension(const uint & _dim, 
     void FeatureMatrixT<T>::findFirstLargerInDimension(const uint & _dim, 
                                                        const T & _elem, 
                                                        const T & _elem, 
-                                                       int & _position
+                                                       uint & _position
                                                       ) const
                                                       ) const
     {
     {
       _position = 0;
       _position = 0;
@@ -482,7 +482,7 @@ namespace NICE {
     template <typename T>
     template <typename T>
     void FeatureMatrixT<T>::findLastSmallerInDimension(const uint & _dim, 
     void FeatureMatrixT<T>::findLastSmallerInDimension(const uint & _dim, 
                                                        const T & _elem, 
                                                        const T & _elem, 
-                                                       int & _position
+                                                       uint & _position
                                                       ) const
                                                       ) const
     {
     {
       _position = 0;
       _position = 0;
@@ -625,7 +625,7 @@ namespace NICE {
     
     
     template <typename T>
     template <typename T>
     void FeatureMatrixT<T>::set_features(const std::vector<std::vector<T> > & _features, 
     void FeatureMatrixT<T>::set_features(const std::vector<std::vector<T> > & _features, 
-                                         std::vector<std::vector<int> > & _permutations, 
+                                         std::vector<std::vector<uint> > & _permutations, 
                                          const uint & _dim 
                                          const uint & _dim 
                                         )
                                         )
     {
     {
@@ -649,7 +649,7 @@ namespace NICE {
 
 
     template <typename T>
     template <typename T>
     void FeatureMatrixT<T>::set_features(const std::vector<std::vector<T> > & _features, 
     void FeatureMatrixT<T>::set_features(const std::vector<std::vector<T> > & _features, 
-                                         std::vector<std::map<int,int> > & _permutations, 
+                                         std::vector<std::map<uint,uint> > & _permutations, 
                                          const uint & _dim
                                          const uint & _dim
                                         )
                                         )
     {
     {
@@ -754,7 +754,7 @@ namespace NICE {
         if ( this->b_debug )
         if ( this->b_debug )
           std::cerr << "FeatureMatrixT<T>::set_features " << this->ui_n << " new examples" << std::endl;
           std::cerr << "FeatureMatrixT<T>::set_features " << this->ui_n << " new examples" << std::endl;
         //loop over every example to add its content
         //loop over every example to add its content
-        for (int nr = 0; nr < this->ui_n; nr++)
+        for (iint nr = 0; nr < this->ui_n; nr++)
         {
         {
           if ( this->b_debug )
           if ( this->b_debug )
             std::cerr << "add feature nr. " << nr << " / " << _features.size() << " ";
             std::cerr << "add feature nr. " << nr << " / " << _features.size() << " ";
@@ -779,21 +779,21 @@ namespace NICE {
     }
     }
 
 
     template <typename T>
     template <typename T>
-    void FeatureMatrixT<T>::getPermutations( std::vector<std::vector<int> > & _permutations) const
+    void FeatureMatrixT<T>::getPermutations( std::vector<std::vector<uint> > & _permutations) const
     {
     {
       for (uint dim = 0; dim < this->ui_d; dim++)
       for (uint dim = 0; dim < this->ui_d; dim++)
       {
       {
-        std::vector<int> perm (  (this->features[dim]).getPermutation() );
+        std::vector<uint> perm (  (this->features[dim]).getPermutation() );
         _permutations.push_back(perm);
         _permutations.push_back(perm);
       }
       }
     }
     }
     
     
     template <typename T>
     template <typename T>
-    void FeatureMatrixT<T>::getPermutations( std::vector<std::map<int,int> > & _permutations) const
+    void FeatureMatrixT<T>::getPermutations( std::vector<std::map<uint,uint> > & _permutations) const
     {
     {
       for (uint dim = 0; dim < this->ui_d; dim++)
       for (uint dim = 0; dim < this->ui_d; dim++)
       {
       {
-        std::map<int,int> perm (  (this->features[dim]).getPermutationNonZeroReal() );
+        std::map<uint,uint> perm (  (this->features[dim]).getPermutationNonZeroReal() );
         _permutations.push_back(perm);
         _permutations.push_back(perm);
       }
       }
     }
     }
@@ -824,13 +824,13 @@ namespace NICE {
         _matrix.resize(this->get_d(),this->get_n());
         _matrix.resize(this->get_d(),this->get_n());
 
 
       _matrix.set((T)0.0);
       _matrix.set((T)0.0);
-      int dimIdx(0);
+      uint dimIdx(0);
       for (typename std::vector<NICE::SortedVectorSparse<T> >::const_iterator it = this->features.begin(); it != this->features.end(); it++, dimIdx++)
       for (typename std::vector<NICE::SortedVectorSparse<T> >::const_iterator it = this->features.begin(); it != this->features.end(); it++, dimIdx++)
       {
       {
-        std::map< int, typename NICE::SortedVectorSparse<T>::elementpointer>  nonzeroIndices= (*it).nonzeroIndices();
-        for (typename std::map< int, typename NICE::SortedVectorSparse<T>::elementpointer>::const_iterator inIt = nonzeroIndices.begin(); inIt != nonzeroIndices.end(); inIt++)
+        std::map< uint, typename NICE::SortedVectorSparse<T>::elementpointer>  nonzeroIndices= (*it).nonzeroIndices();
+        for (typename std::map< uint, typename NICE::SortedVectorSparse<T>::elementpointer>::const_iterator inIt = nonzeroIndices.begin(); inIt != nonzeroIndices.end(); inIt++)
         {
         {
-          int featIndex = ((*inIt).second)->second.first;
+          uint featIndex = ((*inIt).second)->second.first;
           if ( _transpose ) 
           if ( _transpose ) 
             _matrix(featIndex,dimIdx) =((*inIt).second)->second.second; 
             _matrix(featIndex,dimIdx) =((*inIt).second)->second.second; 
           else
           else
@@ -857,13 +857,13 @@ namespace NICE {
         else
         else
           _matrix[i] = std::vector<T>(this->get_n(), 0.0);
           _matrix[i] = std::vector<T>(this->get_n(), 0.0);
 
 
-      int dimIdx(0);
+      uint dimIdx(0);
       for (typename std::vector<NICE::SortedVectorSparse<T> >::const_iterator it = this->features.begin(); it != this->features.end(); it++, dimIdx++)
       for (typename std::vector<NICE::SortedVectorSparse<T> >::const_iterator it = this->features.begin(); it != this->features.end(); it++, dimIdx++)
       {
       {
-        std::map< int, typename NICE::SortedVectorSparse<T>::elementpointer>  nonzeroIndices= (*it).nonzeroIndices();
-        for (typename std::map< int, typename NICE::SortedVectorSparse<T>::elementpointer>::const_iterator inIt = nonzeroIndices.begin(); inIt != nonzeroIndices.end(); inIt++)
+        std::map< uint, typename NICE::SortedVectorSparse<T>::elementpointer>  nonzeroIndices= (*it).nonzeroIndices();
+        for (typename std::map< uint, typename NICE::SortedVectorSparse<T>::elementpointer>::const_iterator inIt = nonzeroIndices.begin(); inIt != nonzeroIndices.end(); inIt++)
         {
         {
-          int featIndex = ((*inIt).second)->second.first;
+          uint featIndex = ((*inIt).second)->second.first;
           if ( _transpose )
           if ( _transpose )
             _matrix[featIndex][dimIdx] =((*inIt).second)->second.second; 
             _matrix[featIndex][dimIdx] =((*inIt).second)->second.second; 
           else
           else
@@ -874,10 +874,10 @@ namespace NICE {
     
     
     // Swaps to specified elements, performing a validity check
     // Swaps to specified elements, performing a validity check
     template <typename T>
     template <typename T>
-    void FeatureMatrixT<T>::swap(const int & _row1, 
-                                 const int & _col1, 
-                                 const int & _row2, 
-                                 const int & _col2
+    void FeatureMatrixT<T>::swap(const uint & _row1, 
+                                 const uint & _col1, 
+                                 const uint & _row2, 
+                                 const uint & _col2
                                 )
                                 )
     {
     {
       if ( (_row1 < 0) || (_col1 < 0) || (_row1 > this->ui_d) || (_col1 > this->ui_n) || 
       if ( (_row1 < 0) || (_col1 < 0) || (_row1 > this->ui_d) || (_col1 > this->ui_n) || 
@@ -897,10 +897,10 @@ namespace NICE {
     
     
     //  Swaps to specified elements, without performing a validity check
     //  Swaps to specified elements, without performing a validity check
     template <typename T>
     template <typename T>
-    void FeatureMatrixT<T>::swapUnsafe(const int & _row1, 
-                                       const int & _col1, 
-                                       const int & _row2, 
-                                       const int & _col2
+    void FeatureMatrixT<T>::swapUnsafe(const uint & _row1, 
+                                       const uint & _col1, 
+                                       const uint & _row2, 
+                                       const uint & _col2
                                       )
                                       )
     {
     {
       //swap
       //swap
@@ -912,18 +912,18 @@ namespace NICE {
     template <typename T>
     template <typename T>
     void FeatureMatrixT<T>::hikDiagonalElements( Vector & _diagonalElements ) const
     void FeatureMatrixT<T>::hikDiagonalElements( Vector & _diagonalElements ) const
     {
     {
-      int dimIdx = 0;
+      uint dimIdx = 0;
       // the function calculates the diagonal elements of a HIK kernel matrix
       // the function calculates the diagonal elements of a HIK kernel matrix
       _diagonalElements.resize(this->ui_n);
       _diagonalElements.resize(this->ui_n);
       _diagonalElements.set(0.0);
       _diagonalElements.set(0.0);
       // loop through all dimensions
       // loop through all dimensions
       for (typename std::vector<NICE::SortedVectorSparse<T> >::const_iterator it = this->features.begin(); it != this->features.end(); it++, dimIdx++)
       for (typename std::vector<NICE::SortedVectorSparse<T> >::const_iterator it = this->features.begin(); it != this->features.end(); it++, dimIdx++)
       {
       {
-        std::map< int, typename NICE::SortedVectorSparse<T>::elementpointer>  nonzeroIndices= (*it).nonzeroIndices();
+        std::map< uint, typename NICE::SortedVectorSparse<T>::elementpointer>  nonzeroIndices= (*it).nonzeroIndices();
         // loop through all features
         // loop through all features
-        for (typename std::map< int, typename NICE::SortedVectorSparse<T>::elementpointer>::const_iterator inIt = nonzeroIndices.begin(); inIt != nonzeroIndices.end(); inIt++)
+        for (typename std::map< uint, typename NICE::SortedVectorSparse<T>::elementpointer>::const_iterator inIt = nonzeroIndices.begin(); inIt != nonzeroIndices.end(); inIt++)
         {
         {
-          int index = inIt->first;
+          uint index = inIt->first;
           typename NICE::SortedVectorSparse<T>::elementpointer p = inIt->second;
           typename NICE::SortedVectorSparse<T>::elementpointer p = inIt->second;
           typename NICE::SortedVectorSparse<T>::dataelement de = p->second;
           typename NICE::SortedVectorSparse<T>::dataelement de = p->second;
 
 
@@ -942,7 +942,7 @@ namespace NICE {
     }
     }
     
     
     template <typename T>
     template <typename T>
-    int FeatureMatrixT<T>::getNumberOfNonZeroElementsPerDimension(const uint & dim) const
+    uint FeatureMatrixT<T>::getNumberOfNonZeroElementsPerDimension(const uint & dim) const
     {
     {
       //FIXME we could return a boolean indicating success and return the actual number via call-by-reference
       //FIXME we could return a boolean indicating success and return the actual number via call-by-reference
       if ( (dim < 0) || (dim > this->ui_d))
       if ( (dim < 0) || (dim > this->ui_d))
@@ -951,7 +951,7 @@ namespace NICE {
     }
     }
 
 
     template <typename T>
     template <typename T>
-    int FeatureMatrixT<T>::getNumberOfZeroElementsPerDimension(const uint & dim) const
+    uint FeatureMatrixT<T>::getNumberOfZeroElementsPerDimension(const uint & dim) const
     {
     {
       if ( (dim < 0) || (dim > this->ui_d))
       if ( (dim < 0) || (dim > this->ui_d))
         return 0;
         return 0;

+ 143 - 135
SortedVectorSparse.h

@@ -296,56 +296,56 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
                T _newElement, 
                T _newElement, 
                bool _setTransformedValue = false )
                bool _setTransformedValue = false )
     {
     {
-      if ( _a >= this->ui_n || a < 0 )
+      if ( _a >= this->ui_n || _a < 0 )
         fthrow ( Exception, "SortedVectorSparse::set(): out of bounds" );
         fthrow ( Exception, "SortedVectorSparse::set(): out of bounds" );
 
 
-      typename std::map<int, elementpointer>::iterator i = nonzero_indices.find ( a );
+      typename std::map<int, elementpointer>::iterator i = this->nonzero_indices.find ( _a );
 
 
       // check whether the element was previously non-sparse
       // check whether the element was previously non-sparse
-      if ( i != nonzero_indices.end() ) {
+      if ( i != this->nonzero_indices.end() ) {
         elementpointer it = i->second;
         elementpointer it = i->second;
 
 
-        if ( checkSparsity ( newElement ) ) {
+        if ( checkSparsity ( _newElement ) ) {
           // old: non-sparse, new:sparse
           // old: non-sparse, new:sparse
           // delete the element
           // delete the element
-          nzData.erase ( it );
-          nonzero_indices.erase ( i );
+          this->nzData.erase ( it );
+          this->nonzero_indices.erase ( i );
         } else {
         } else {
           // old: non-sparse, new: non-sparse
           // old: non-sparse, new: non-sparse
           // The following statement would be nice, but it is not allowed.
           // The following statement would be nice, but it is not allowed.
           // This is also the reason why we implemented the transformed feature value ability.
           // This is also the reason why we implemented the transformed feature value ability.
           // it->first = newElement;
           // it->first = newElement;
-          if ( setTransformedValue ) {
+          if ( _setTransformedValue ) {
             // set the transformed value
             // set the transformed value
-            it->second.second = newElement;
+            it->second.second = _newElement;
           } else {
           } else {
             // the following is a weird tricky and expensive
             // the following is a weird tricky and expensive
-            set ( a, 0.0 );
+            this->set ( _a, 0.0 );
             //std::cerr << "Element after step 1: " << access(a) << std::endl;
             //std::cerr << "Element after step 1: " << access(a) << std::endl;
-            set ( a, newElement );
+            this->set ( _a, _newElement );
           }
           }
           //std::cerr << "Element after step 2: " << access(a) << std::endl;
           //std::cerr << "Element after step 2: " << access(a) << std::endl;
         }
         }
       } else {
       } else {
         // the element was previously sparse
         // the element was previously sparse
-        if ( !checkSparsity ( newElement ) )
+        if ( !checkSparsity ( _newElement ) )
         {
         {
           //std::cerr << "changing a zero value to a non-zero value " << newElement << std::endl;
           //std::cerr << "changing a zero value to a non-zero value " << newElement << std::endl;
           // old element is not sparse
           // old element is not sparse
-          dataelement de ( a, newElement );
-          std::pair<T, dataelement> p ( newElement, de );
-          elementpointer it = nzData.insert ( p );
-          nonzero_indices.insert ( std::pair<int, elementpointer> ( a, it ) );
+          dataelement de ( _a, _newElement );
+          std::pair<T, dataelement> p ( _newElement, de );
+          elementpointer it = this->nzData.insert ( p );
+          this->nonzero_indices.insert ( std::pair<uint, elementpointer> ( _a, it ) );
         }
         }
       }
       }
     }
     }
 
 
-    SortedVectorSparse<T> operator= ( const SortedVectorSparse<T> & F )
+    SortedVectorSparse<T> operator= ( const SortedVectorSparse<T> & _F )
     {
     {
-      this->tolerance = F.getTolerance();
-      this->n = F.getN();
-      this->nonzero_indices = F.nonzero_indices;
-      this->nzData = F.nzData;
+      this->tolerance = _F.getTolerance();
+      this->ui_n = _F.getN();
+      this->nonzero_indices = _F.nonzero_indices;
+      this->nzData = _F.nzData;
 
 
       return *this;
       return *this;
     }
     }
@@ -355,11 +355,11 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 10-01-2012 (dd-mm-yyyy)
     * @date 10-01-2012 (dd-mm-yyyy)
     */
     */
-    std::vector<int> getPermutationNonZero() const
+    std::vector<uint> getPermutationNonZero() const
     {
     {
-      std::vector<int> rv ( nzData.size() );
-      int idx = 0;
-      for ( typename std::multimap<T, dataelement>::const_iterator it = nzData.begin(); it != nzData.end(); it++, idx++ )
+      std::vector<uint> rv ( this->nzData.size() );
+      uint idx = 0;
+      for ( typename std::multimap<T, dataelement>::const_iterator it = this->nzData.begin(); it != this->nzData.end(); it++, idx++ )
       {
       {
         rv[idx] = it->second.first;
         rv[idx] = it->second.first;
       }
       }
@@ -370,11 +370,11 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
     * @brief Computes the permutation of the non-zero elements for a proper (ascending) ordering
     * @brief Computes the permutation of the non-zero elements for a proper (ascending) ordering
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 23-01-2012 (dd-mm-yyyy)
     * @date 23-01-2012 (dd-mm-yyyy)
-    * @return  std::map<int, int>, with the absolute feature numbers as key element and their permutation as second
+    * @return  std::map<uint, uint>, with the absolute feature numbers as key element and their permutation as second
     */
     */
-    std::map<int, int> getPermutationNonZeroReal() const
+    std::map<uint, uint> getPermutationNonZeroReal() const
     {
     {
-      std::map<int, int> rv;
+      std::map<uint, uint> rv;
 //         int idx = 0;
 //         int idx = 0;
 //         for (typename std::multimap<T, dataelement>::const_iterator it = nzData.begin(); it != nzData.end(); it++, idx++)
 //         for (typename std::multimap<T, dataelement>::const_iterator it = nzData.begin(); it != nzData.end(); it++, idx++)
 //         {
 //         {
@@ -386,13 +386,13 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
 //           //rv.insert(std::pair<int,int>(idx,it->second.first));
 //           //rv.insert(std::pair<int,int>(idx,it->second.first));
 //         }
 //         }
 
 
-      int nrZeros ( this->getZeros() );
+      uint nrZeros ( this->getZeros() );
 
 
-      int idx = 0;
-      for ( typename std::multimap<T, dataelement>::const_iterator it = nzData.begin(); it != nzData.end(); it++, idx++ )
+      uint idx = 0;
+      for ( typename std::multimap<T, dataelement>::const_iterator it = this->nzData.begin(); it != this->nzData.end(); it++, idx++ )
       {
       {
         //inserts the real feature number as key
         //inserts the real feature number as key
-        rv.insert ( std::pair<int, int> ( nrZeros + idx, it->second.first ) );
+        rv.insert ( std::pair<uint, uint> ( nrZeros + idx, it->second.first ) );
       }
       }
       return rv;
       return rv;
     };
     };
@@ -401,18 +401,18 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
     * @brief Computes the permutation of the non-zero elements for a proper (ascending) ordering
     * @brief Computes the permutation of the non-zero elements for a proper (ascending) ordering
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 23-01-2012 (dd-mm-yyyy)
     * @date 23-01-2012 (dd-mm-yyyy)
-    * @return  std::map<int, int>, with the relative feature numbers as key element  (realtive to non-zero elements) and their permutation as second
+    * @return  std::map<uint, uint>, with the relative feature numbers as key element  (realtive to non-zero elements) and their permutation as second
     */
     */
-    std::map<int, int> getPermutationNonZeroRelative() const
+    std::map<uint, uint> getPermutationNonZeroRelative() const
     {
     {
-      std::map<int, int> rv;
-      int idx = 0;
-      for ( typename std::multimap<T, dataelement>::const_iterator it = nzData.begin(); it != nzData.end(); it++, idx++ )
+      std::map<uint, uint> rv;
+      uint idx = 0;
+      for ( typename std::multimap<T, dataelement>::const_iterator it = this->nzData.begin(); it != this->nzData.end(); it++, idx++ )
       {
       {
         //inserts the real feature number as key
         //inserts the real feature number as key
         //rv.insert(std::pair<int,int>(it->second.first,it->second.first));
         //rv.insert(std::pair<int,int>(it->second.first,it->second.first));
         //if we want to use the relative feature number (realtive to non-zero elements), use the following
         //if we want to use the relative feature number (realtive to non-zero elements), use the following
-        rv.insert ( std::pair<int, int> ( idx, it->second.first ) );
+        rv.insert ( std::pair<uint, uint> ( idx, it->second.first ) );
       }
       }
       return rv;
       return rv;
     };
     };
@@ -422,25 +422,26 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
     /**
     /**
     * @brief Computes the permutation of the elements for a proper (ascending) ordering
     * @brief Computes the permutation of the elements for a proper (ascending) ordering
     */
     */
-    std::vector<int> getPermutation() const
+    std::vector<uint> getPermutation() const
     {
     {
-      std::vector<int> rv ( n );
+      std::vector<uint> rv ( this->ui_n );
 
 
-      int idx = n - 1;
+      uint idx = std::max( this->ui_n - 1, 0 );
       typename std::multimap<T, dataelement>::const_reverse_iterator it ;
       typename std::multimap<T, dataelement>::const_reverse_iterator it ;
-      for ( it = nzData.rbegin(); it != nzData.rend() && ( it->first > tolerance ); it++, idx-- )
+      for ( it = this->nzData.rbegin(); it != this->nzData.rend() && ( it->first > tolerance ); it++, idx-- )
       {
       {
         rv[ idx ] = it->second.first;
         rv[ idx ] = it->second.first;
       }
       }
 
 
-      for ( int i = n - 1 ; i >= 0 ; i-- )
+      uint i = std::max( this->ui_n - 1, 0 );
+      for ( int iCnt = this->ui_n - 1 ; iCnt >= 0 ; i--, iCnt-- )
         if ( nonzero_indices.find ( i ) == nonzero_indices.end() )
         if ( nonzero_indices.find ( i ) == nonzero_indices.end() )
         {
         {
           rv[ idx ] = i;
           rv[ idx ] = i;
           idx--;
           idx--;
         }
         }
 
 
-      for ( ; it != nzData.rend(); it++, idx-- )
+      for ( ; it != this->nzData.rend(); it++, idx-- )
       {
       {
         rv[ idx ] = it->second.first;
         rv[ idx ] = it->second.first;
       }
       }
@@ -453,12 +454,12 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 10-01-2012 (dd-mm-yyyy)
     * @date 10-01-2012 (dd-mm-yyyy)
     */
     */
-    std::vector<std::pair<int, T> > getOrderInSeparateVector() const
+    std::vector<std::pair<uint, T> > getOrderInSeparateVector() const
     {
     {
-      std::vector<std::pair<int, T> > rv;
-      rv.resize ( nzData.size() );
+      std::vector<std::pair<uint, T> > rv;
+      rv.resize ( this->nzData.size() );
       uint idx = 0;
       uint idx = 0;
-      for ( typename std::multimap<T, dataelement>::const_iterator it = nzData.begin(); it != nzData.end(); it++, idx++ )
+      for ( typename std::multimap<T, dataelement>::const_iterator it = this->nzData.begin(); it != this->nzData.end(); it++, idx++ )
       {
       {
         rv[idx].first = it->second.first;
         rv[idx].first = it->second.first;
         rv[idx].second = it->second.second;
         rv[idx].second = it->second.second;
@@ -473,24 +474,24 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
     */
     */
     T getMedian() const
     T getMedian() const
     {
     {
-      if ( n % 2 == 1 ) 
+      if ( this->ui_n % 2 == 1 ) 
       {
       {
         // even number of training examples
         // even number of training examples
-        int medianPosition = nzData.size() - (int)(n/2);
-        if ( medianPosition < 0 ) 
+        uint medianPosition = this->nzData.size() - this->ui_n/2;
+        if ( medianPosition < 0 ) //FIXME not possible with uint anymore
           return 0.0;
           return 0.0;
         else
         else
-          return accessNonZero(medianPosition); 
+          return this->accessNonZero(medianPosition); 
       } else {
       } else {
         // odd number of training examples
         // odd number of training examples
-        int medianA = nzData.size() - (int)(n/2);
-        int medianB = nzData.size() - (int)((n+1)/2);
+        uint medianA = this->nzData.size() - this->ui_n/2;
+        uint medianB = this->nzData.size() - (this->ui_n+1)/2;
         T a = 0.0;
         T a = 0.0;
         T b = 0.0;
         T b = 0.0;
         if ( medianA >= 0)
         if ( medianA >= 0)
-          a = accessNonZero( medianA );
+          a = this->accessNonZero( medianA );
         if ( medianB >= 0)
         if ( medianB >= 0)
-          b = accessNonZero( medianB );
+          b = this->accessNonZero( medianB );
         return (a + b)/2.0;
         return (a + b)/2.0;
       }
       }
     }
     }
@@ -502,8 +503,8 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
     */
     */
     T getMax() const
     T getMax() const
     {
     {
-      if (nzData.size() > 0)
-        return accessNonZero(nzData.size()-1);
+      if ( this->nzData.size() > 0 )
+        return this->accessNonZero( this->nzData.size()-1 );
       return (T) 0.0;
       return (T) 0.0;
     }
     }
     
     
@@ -514,9 +515,9 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
     */
     */
     T getMin() const
     T getMin() const
     {
     {
-      if (nzData.size() < (uint) n)
+      if ( this->nzData.size() < this->ui_n )
         return (T) 0.0;
         return (T) 0.0;
-      return accessNonZero(0);
+      return this->accessNonZero(0);
     }
     }
     
     
     
     
@@ -531,31 +532,34 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
     * @param elementCounts this vector contains the number of examples for each class, compute this using the labels
     * @param elementCounts this vector contains the number of examples for each class, compute this using the labels
     * for efficiency reasons
     * for efficiency reasons
     */
     */
-    void getClassMedians ( SparseVector & classMedians, const Vector & labels, const Vector & elementCounts ) const
+    void getClassMedians ( SparseVector & _classMedians, 
+                           const Vector & _labels, 
+                           const Vector & _elementCounts 
+                         ) const
     {
     {
-      if ( labels.size() != n )
+      if ( _labels.size() != this->ui_n )
         fthrow(Exception, "Label vector has to have the same size as the SortedVectorSparse structure");
         fthrow(Exception, "Label vector has to have the same size as the SortedVectorSparse structure");
-      Vector c ( elementCounts );
+      Vector c ( _elementCounts );
       for ( uint i = 0 ; i < c.size(); i++ )
       for ( uint i = 0 ; i < c.size(); i++ )
         c[i] /= 2;
         c[i] /= 2;
       // now we have in c the position of the current median
       // now we have in c the position of the current median
       typename std::multimap<T, dataelement>::const_reverse_iterator it;
       typename std::multimap<T, dataelement>::const_reverse_iterator it;
 
 
-      for ( it = nzData.rbegin(); it != nzData.rend(); it++ )
+      for ( it = this->nzData.rbegin(); it != this->nzData.rend(); it++ )
       {
       {
         const dataelement & de = it->second;
         const dataelement & de = it->second;
-        int origIndex = de.first;
+        uint origIndex = de.first;
         double value = de.second;
         double value = de.second;
-        int classno = labels[origIndex];
+        int classno = _labels[origIndex];
         c[ classno ]--;
         c[ classno ]--;
         if ( c[classno] == 0 )
         if ( c[classno] == 0 )
-          classMedians[classno] = value;
+          _classMedians[classno] = value;
       }
       }
 
 
       // remaining medians are zero!
       // remaining medians are zero!
       for ( uint classno = 0 ; classno < c.size(); classno++ )
       for ( uint classno = 0 ; classno < c.size(); classno++ )
         if ( c[classno] > 0 )
         if ( c[classno] > 0 )
-          classMedians[classno] = 0.0;
+          _classMedians[classno] = 0.0;
     }
     }
 
 
     /**
     /**
@@ -563,49 +567,51 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
     * @author Alexander Freytag
     * @author Alexander Freytag
     * @date 12-01-2012 (dd-mm-yyyy)
     * @date 12-01-2012 (dd-mm-yyyy)
     */
     */
-    void print(std::ostream & os) const
+    void print(std::ostream & _os) const
     {
     {
       typename std::multimap<T, dataelement>::const_iterator it = nzData.begin();
       typename std::multimap<T, dataelement>::const_iterator it = nzData.begin();
 
 
-      if (os.good())
+      if (_os.good())
       {
       {
         for ( ; it != nzData.end() ; it++ )
         for ( ; it != nzData.end() ; it++ )
         {
         {
           if ( it->first < ( T ) 0.0 )
           if ( it->first < ( T ) 0.0 )
-            os << it->first << " ";
+            _os << it->first << " ";
           else
           else
             break;
             break;
         }
         }
 
 
-        for ( int i = 0; i < getZeros(); i++ )
+        for ( int i = 0; i < this->getZer_os(); i++ )
         {
         {
-          os << ( T ) 0.0 << " " ;
+          _os << ( T ) 0.0 << " " ;
         }
         }
 
 
-        for ( ; ( it != nzData.end() ); it++ )
+        for ( ; ( it != this->nzData.end() ); it++ )
         {
         {
-          os << it->second.second << " ";
+          _os << it->second.second << " ";
         }
         }
-        os << std::endl;
+        _os << std::endl;
       }
       }
     }
     }
     
     
     /** set b_verbose flag used for restore-functionality*/
     /** set b_verbose flag used for restore-functionality*/
-    void setVerbose( const bool & _b_verbose) { b_verbose = _b_verbose;};
-    bool getVerbose( ) const { return b_verbose;};
+    void setVerbose( const bool & _b_verbose) { this->b_verbose = _b_verbose;};
+    bool getVerbose( ) const { this->return b_verbose;};
     
     
     
     
     /** Persistent interface */
     /** Persistent interface */
-    virtual void restore ( std::istream & is, int format = 0 )
+    virtual void restore ( std::istream & _is, 
+                           int _format = 0 
+                         )
     {
     {
       bool b_restoreVerbose ( false );
       bool b_restoreVerbose ( false );
-      if ( is.good() )
+      if ( _is.good() )
       {
       {
 	if ( b_restoreVerbose ) 
 	if ( b_restoreVerbose ) 
 	  std::cerr << " restore SortedVectorSparse" << std::endl;
 	  std::cerr << " restore SortedVectorSparse" << std::endl;
 	
 	
 	std::string tmp;
 	std::string tmp;
-	is >> tmp; //class name 
+	_is >> tmp; //class name 
 	
 	
 	if ( ! this->isStartTag( tmp, "SortedVectorSparse" ) )
 	if ( ! this->isStartTag( tmp, "SortedVectorSparse" ) )
 	{
 	{
@@ -613,13 +619,13 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
 	    throw;
 	    throw;
 	}   
 	}   
 	    
 	    
-	is.precision ( std::numeric_limits<double>::digits10 + 1);
+	_is.precision ( std::numeric_limits<double>::digits10 + 1);
 	
 	
 	bool b_endOfBlock ( false ) ;
 	bool b_endOfBlock ( false ) ;
 	
 	
 	while ( !b_endOfBlock )
 	while ( !b_endOfBlock )
 	{
 	{
-	  is >> tmp; // start of block 
+	  _is >> tmp; // start of block 
 	  
 	  
 	  if ( this->isEndTag( tmp, "SortedVectorSparse" ) )
 	  if ( this->isEndTag( tmp, "SortedVectorSparse" ) )
 	  {
 	  {
@@ -634,21 +640,21 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
 	  
 	  
 	  if ( tmp.compare("tolerance") == 0 )
 	  if ( tmp.compare("tolerance") == 0 )
 	  {
 	  {
-	    is >> tolerance;        
-	    is >> tmp; // end of block 
+	    _is >> this->tolerance;        
+	    _is >> tmp; // end of block 
 	    tmp = this->removeEndTag ( tmp );
 	    tmp = this->removeEndTag ( tmp );
 	  }
 	  }
-	  else if ( tmp.compare("n") == 0 )
+	  else if ( tmp.compare("ui_n") == 0 )
 	  {
 	  {
-	    is >> n;        
-	    is >> tmp; // end of block 
+	    _is >> this->ui_n;        
+	    _is >> tmp; // end of block 
 	    tmp = this->removeEndTag ( tmp );
 	    tmp = this->removeEndTag ( tmp );
 	  }
 	  }
 	  else if ( tmp.compare("underlying_data_(sorted)") == 0 )
 	  else if ( tmp.compare("underlying_data_(sorted)") == 0 )
 	  {
 	  {
-	    is >> tmp; // start of block 
+	    _is >> tmp; // start of block 
 	    
 	    
-	    int nonZeros;
+	    uint nonZeros;
 	    if ( ! this->isStartTag( tmp, "nonZeros" ) )
 	    if ( ! this->isStartTag( tmp, "nonZeros" ) )
 	    {
 	    {
 	      std::cerr << "Attempt to restore SortedVectorSparse, but found no information about nonZeros elements. Aborting..." << std::endl;
 	      std::cerr << "Attempt to restore SortedVectorSparse, but found no information about nonZeros elements. Aborting..." << std::endl;
@@ -656,12 +662,12 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
 	    }
 	    }
 	    else
 	    else
 	    {
 	    {
-	      is >> nonZeros;
-	      is >> tmp; // end of block 
+	      _is >> nonZeros;
+	      _is >> tmp; // end of block 
 	      tmp = this->removeEndTag ( tmp );     
 	      tmp = this->removeEndTag ( tmp );     
 	    }
 	    }
 	    
 	    
-	    is >> tmp; // start of block 
+	    _is >> tmp; // start of block 
 	    
 	    
 	    if ( ! this->isStartTag( tmp, "data" ) )
 	    if ( ! this->isStartTag( tmp, "data" ) )
 	    {
 	    {
@@ -671,28 +677,28 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
 	    else
 	    else
 	    {	    
 	    {	    
 	      T origValue;
 	      T origValue;
-	      int origIndex;
+	      _int origIndex;
 	      T transformedValue;
 	      T transformedValue;
 	      
 	      
-	      nzData.clear();
-	      for (int i = 0; i < nonZeros; i++)
+	      this->nzData.clear();
+	      for ( uint i = 0; i < nonZeros; i++)
 	      {
 	      {
 	      
 	      
-		is >> origValue;
-		is >> origIndex;
-		is >> transformedValue;
+		_is >> origValue;
+		_is >> origIndex;
+		_is >> transformedValue;
 	      
 	      
 		std::pair<T, dataelement > p ( origValue, dataelement ( origIndex, transformedValue ) );
 		std::pair<T, dataelement > p ( origValue, dataelement ( origIndex, transformedValue ) );
-		elementpointer it = nzData.insert ( p);
-		nonzero_indices.insert ( std::pair<int, elementpointer> ( origIndex, it ) );
+		elementpointer it = this->nzData.insert ( p);
+		this->nonzero_indices.insert ( std::pair<uint, elementpointer> ( origIndex, it ) );
 	      }
 	      }
 	      
 	      
-	      is >> tmp; // end of block 
+	      _is >> tmp; // end of block 
 	      tmp = this->removeEndTag ( tmp );  
 	      tmp = this->removeEndTag ( tmp );  
 	    }
 	    }
 	    
 	    
 	    
 	    
-	    is >> tmp; // end of block 
+	    _is >> tmp; // end of block 
 	    tmp = this->removeEndTag ( tmp );	    
 	    tmp = this->removeEndTag ( tmp );	    
 	  }
 	  }
 	  else
 	  else
@@ -706,43 +712,45 @@ template<class T> class SortedVectorSparse : NICE::Persistent{
       else
       else
       {
       {
         std::cerr << "SortedVectorSparse::restore -- InStream not initialized - restoring not possible!" << std::endl;
         std::cerr << "SortedVectorSparse::restore -- InStream not initialized - restoring not possible!" << std::endl;
-	throw;
+        throw;
       }      
       }      
     };
     };
-    virtual void store ( std::ostream & os, int format = 0 ) const
+    virtual void store ( std::ostream & _os, 
+                         int _format = 0 
+                       ) const
     {
     {
-      if (os.good())
+      if ( _os.good() )
       {
       {
-	// show starting point
-	os << this->createStartTag( "SortedVectorSparse" ) << std::endl;
-	
-        os.precision (std::numeric_limits<double>::digits10 + 1);
-	
-	os << this->createStartTag( "tolerance" ) << std::endl;
-	os << tolerance << std::endl;
-	os << this->createEndTag( "tolerance" ) << std::endl;
-	
-	os << this->createStartTag( "n" ) << std::endl;
-	os << n << std::endl;
-	os << this->createEndTag( "n" ) << std::endl;
-		
-
-        os << this->createStartTag( "underlying_data_(sorted)" ) << std::endl;
-	  os << this->createStartTag( "nonZeros" ) << std::endl;
-	  os << this->getNonZeros() << std::endl;
-	  os << this->createEndTag( "nonZeros" ) << std::endl;
-	  
-	  os << this->createStartTag( "data" ) << std::endl;  
-	  for (const_elementpointer elP = nzData.begin();  elP != nzData.end(); elP++)
-	  {
-	    os << elP->first << " " << elP->second.first << " " << elP->second.second << " ";
-	  }
-	  os << std::endl;
-	  os << this->createEndTag( "data" ) << std::endl;
-	os << this->createEndTag( "underlying_data_(sorted)" ) << std::endl;
-	
-	// done
-	os << this->createEndTag( "SortedVectorSparse" ) << std::endl;	
+        // show starting point
+        _os << this->createStartTag( "SortedVectorSparse" ) << std::endl;
+        
+        _os.precision (std::numeric_limits<double>::digits10 + 1);
+        
+        _os << this->createStartTag( "tolerance" ) << std::endl;
+        _os << tolerance << std::endl;
+        _os << this->createEndTag( "tolerance" ) << std::endl;
+        
+        _os << this->createStartTag( "ui_n" ) << std::endl;
+        _os << this->ui_n << std::endl;
+        _os << this->createEndTag( "ui_n" ) << std::endl;
+
+
+        _os << this->createStartTag( "underlying_data_(sorted)" ) << std::endl;
+        _os << this->createStartTag( "nonZeros" ) << std::endl;
+        _os << this->getNonZeros() << std::endl;
+        _os << this->createEndTag( "nonZeros" ) << std::endl;
+        
+        _os << this->createStartTag( "data" ) << std::endl;  
+        for (const_elementpointer elP = this->nzData.begin();  elP != this->nzData.end(); elP++)
+        {
+          _os << elP->first << " " << elP->second.first << " " << elP->second.second << " ";
+        }
+        _os << std::endl;
+        _os << this->createEndTag( "data" ) << std::endl;
+        _os << this->createEndTag( "underlying_data_(sorted)" ) << std::endl;
+      
+        // done
+        _os << this->createEndTag( "SortedVectorSparse" ) << std::endl;
       }
       }
       else
       else
       {
       {