Changeset 272


Ignore:
Timestamp:
Apr 14, 2005, 4:26:50 PM (18 years ago)
Author:
Peter
Message:

soft equal function added and equality and non-equality operators added

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/matrix.cc

    r242 r272  
    112112  }
    113113
    114 
     114  bool matrix::equal(const matrix& other, const double d) const
     115  {
     116    if (columns()!=other.columns() || rows()!=other.rows())
     117      return false;
     118    for (size_t i=0; i<rows(); i++)
     119      for (size_t j=0; j<columns(); j++)
     120        if ((*this)(i,j)>other(i,j)+d || (*this)(i,j)<other(i,j)-d )
     121          return false;
     122
     123    return true;
     124  }
    115125
    116126  vector matrix::TEMP_col_return(size_t column) const
  • trunk/src/matrix.h

    r242 r272  
    6868
    6969    ///
     70    /// @return true if each element deviates less or equal than \a d
     71    ///
     72    bool equal(const matrix&, const double d=0) const;
     73
     74    ///
    7075    /// Create a new copy of the internal GSL matrix.
    7176    ///
     
    200205    /// Comparison operator.
    201206    ///
    202     /// @return True if ... (to be defined) ... otherwise false.
    203     ///
    204     bool operator==( const matrix &other ) const;
     207    /// @return True if all elements are equal otherwise False.
     208    ///
     209    inline bool operator==( const matrix& other ) const { return equal(other);}
    205210
    206211    ///
    207212    /// Comparison operator.
    208213    ///
    209     /// @return True if ... (to be defined) ... otherwise false.
    210     ///
    211     bool operator!=( const matrix &other ) const;
     214    /// @return False if all elements are equal otherwise True.
     215    ///
     216    inline bool operator!=( const matrix& other ) const {return !equal(other);}
    212217
    213218    ///
Note: See TracChangeset for help on using the changeset viewer.