Changeset 611


Ignore:
Timestamp:
Aug 30, 2006, 2:39:20 PM (15 years ago)
Author:
Markus Ringnér
Message:

Fixes #100

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/c++_tools/classifier/MatrixLookupWeighted.cc

    r608 r611  
    148148    for(size_t i=0;i<(*data_).columns();i++)
    149149      column_index_.push_back(i);
    150     // Peter, a lot of copying in this line
    151     weights_ = new gslapi::matrix(data_->nan());
     150    gslapi::matrix weights;
     151    data_->nan(weights);   
     152    weights_= new gslapi::matrix(weights);
    152153  }
    153154 
  • trunk/c++_tools/gslapi/matrix.cc

    r593 r611  
    161161
    162162
    163   matrix matrix::nan(void) const
    164   {
    165     matrix m(rows(),columns(),1.0);
     163  bool matrix::nan(matrix &m) const
     164  {
     165    m=matrix(rows(),columns(),1.0);
     166    bool nan=false;
    166167    for (size_t i=0; i<rows(); i++)
    167168      for (size_t j=0; j<columns(); j++)
    168         if (std::isnan(operator()(i,j)))
     169        if (std::isnan(operator()(i,j))) {
    169170          m(i,j)=0;
    170     return m;
     171          nan=true;
     172        }
     173    return nan;
    171174  }
    172175
  • trunk/c++_tools/gslapi/matrix.h

    r597 r611  
    250250
    251251    ///
    252     /// @return matrix containing 1 and 0 only. 1 means element in
    253     /// matrix is valid and a zero means element is a NaN.
    254     ///
    255     matrix nan(void) const;
     252    /// The argument is changed into a matrix containing 1's and 0's
     253    /// only. 1 means element in matrix is valid and a zero means
     254    /// element is a NaN.
     255    ///
     256    /// @return true if matrix contains at least one NaN.
     257    ///
     258    bool nan(matrix&) const;
    256259
    257260    ///
  • trunk/test/matrix_test.cc

    r516 r611  
    197197  is.open("data/sorlie_centroids.txt");
    198198  gslapi::matrix* m_nan = new gslapi::matrix(is,'\t');
    199   gslapi::matrix m_weight = m_nan->nan();
     199  gslapi::matrix m_weight;
     200  m_nan->nan(m_weight);
    200201  is.close();
    201202  if (m_weight(0,0)!=1){
Note: See TracChangeset for help on using the changeset viewer.