toon-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Toon-members] TooN/internal vector.hh matrix.hh


From: Georg Klein
Subject: [Toon-members] TooN/internal vector.hh matrix.hh
Date: Sat, 02 May 2009 17:28:27 +0000

CVSROOT:        /sources/toon
Module name:    TooN
Changes by:     Georg Klein <georgklein>        09/05/02 17:28:27

Modified files:
        internal       : vector.hh matrix.hh 

Log message:
        Added == and != tests for vector and matrix

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/vector.hh?cvsroot=toon&r1=1.46&r2=1.47
http://cvs.savannah.gnu.org/viewcvs/TooN/internal/matrix.hh?cvsroot=toon&r1=1.33&r2=1.34

Patches:
Index: vector.hh
===================================================================
RCS file: /sources/toon/TooN/internal/vector.hh,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- vector.hh   1 May 2009 09:47:16 -0000       1.46
+++ vector.hh   2 May 2009 17:28:27 -0000       1.47
@@ -310,6 +310,31 @@
 
        /// @}
 
+       /// @name Comparison
+       /// @{
+
+       /// Test for equality with another vector
+       template<int Size2, class Precision2, class Base2>
+       bool operator==(const Vector<Size2, Precision2, Base2>& rhs) {
+               SizeMismatch<Size,Size2>::test(size(),rhs.size());
+               for(int i=0; i<size(); i++)
+                 if((*this)[i]!=rhs[i])
+                   return 0;
+               return 1;
+       }
+
+       /// Test for inequality with another vector
+       template<int Size2, class Precision2, class Base2>
+       bool operator!=(const Vector<Size2, Precision2, Base2>& rhs) {
+               SizeMismatch<Size,Size2>::test(size(),rhs.size());
+               for(int i=0; i<size(); i++)
+                 if((*this)[i]!=rhs[i])
+                   return 1;
+               return 0;
+       }
+
+       /// @}
+
        /// @name Misc
        /// @{
 

Index: matrix.hh
===================================================================
RCS file: /sources/toon/TooN/internal/matrix.hh,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- matrix.hh   1 May 2009 09:47:16 -0000       1.33
+++ matrix.hh   2 May 2009 17:28:27 -0000       1.34
@@ -184,6 +184,33 @@
            return *this;
        }
 
+       template<int Rows2, int Cols2, typename Precision2, typename Base2>
+       bool operator== (const Matrix<Rows2, Cols2, Precision2, Base2>& rhs)
+       {
+               SizeMismatch<Rows, Rows2>::test(num_rows(), rhs.num_rows());
+               SizeMismatch<Cols, Cols2>::test(num_cols(), rhs.num_cols());
+
+           for(int r=0; r < num_rows(); r++)
+                 for(int c=0; c < num_cols(); c++)
+                   if((*this)[r][c] != rhs[r][c])
+                     return 0;
+           return 1;
+       }
+
+       template<int Rows2, int Cols2, typename Precision2, typename Base2>
+       bool operator!= (const Matrix<Rows2, Cols2, Precision2, Base2>& rhs)
+       {
+               SizeMismatch<Rows, Rows2>::test(num_rows(), rhs.num_rows());
+               SizeMismatch<Cols, Cols2>::test(num_cols(), rhs.num_cols());
+
+           for(int r=0; r < num_rows(); r++)
+                 for(int c=0; c < num_cols(); c++)
+                   if((*this)[r][c] != rhs[r][c])
+                     return 1;
+           return 0;
+       }
+
+
        Matrix& ref()
        {
                return *this;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]