Basic Image AlgorithmS Library 2.8.0

SymmetricMatrix3x3.hh

00001 /* This file is part of the BIAS library (Basic ImageAlgorithmS).
00002 
00003    Copyright (C) 2003-2009    (see file CONTACT for details)
00004    Multimediale Systeme der Informationsverarbeitung
00005    Institut fuer Informatik
00006    Christian-Albrechts-Universitaet Kiel
00007    
00008    
00009    BIAS is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU Lesser General Public License as published by
00011    the Free Software Foundation; either version 2.1 of the License, or
00012    (at your option) any later version.
00013    
00014    BIAS is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU Lesser General Public License for more details.
00018    
00019    You should have received a copy of the GNU Lesser General Public License
00020    along with BIAS; if not, write to the Free Software
00021    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/
00022 #ifndef __SymmetricMatrix3x3_hh__
00023 #define __SymmetricMatrix3x3_hh__
00024 
00025 #include "bias_config.h" 
00026 #include <iostream>
00027 
00028 namespace BIAS {
00029 
00030   // forward declarations
00031   template <class T> class Matrix3x3;
00032   template <class T> class Matrix;
00033 
00034   // forward declaration for stream operator
00035   template <class T> class BIASMathBase_EXPORT SymmetricMatrix3x3;
00036 
00037   // stream operators
00038   template <class T> BIASMathBase_EXPORT
00039   std::ostream& operator<<(std::ostream& os, const SymmetricMatrix3x3<T>& mat);
00040 
00041   template <class T> BIASMathBase_EXPORT
00042   std::istream& operator>>(std::istream& is, SymmetricMatrix3x3<T>& mat);
00043 
00044   /** @class SymmetricMatrix3x3
00045       @ingroup g_math
00046       @brief is a 'fixed size' symmetric quadratic matrix of dim. 3 x 3 which 
00047       is templated over the element-type. The class is memory efficient,
00048       storing only the necessary 6 independent elements of the symmetric matrix.
00049      
00050       @author woelk 11/2007 (c) www.vision-n.de */
00051   template <class T=double>
00052   class BIASMathBase_EXPORT SymmetricMatrix3x3 
00053   {
00054   public:
00055     SymmetricMatrix3x3() {};
00056 
00057     SymmetricMatrix3x3(const SymmetricMatrix3x3<T>& src);
00058 
00059     SymmetricMatrix3x3(const Matrix3x3<T>& src);
00060 
00061     SymmetricMatrix3x3(const Matrix<T>& src);
00062 
00063     ~SymmetricMatrix3x3();
00064 
00065     SymmetricMatrix3x3<T>& operator=(const SymmetricMatrix3x3<T>& src);
00066 
00067     /// element access
00068     T&       operator()(const unsigned row, const unsigned col);
00069     const T& operator()(const unsigned row, const unsigned col) const;
00070 
00071     /// conversion to full matrix
00072     void GetMatrix(Matrix3x3<T>& dst) const;
00073     Matrix3x3<T> GetMatrix() const;
00074     
00075     /// binary io
00076     int Write(std::ostream& os) const;
00077     int Read(std::istream& is);
00078 
00079     /// stream operators are declared as friends
00080     friend BIASMathBase_EXPORT std::ostream&
00081       operator<<<T>(std::ostream& os, const SymmetricMatrix3x3<T>& mat);
00082     friend BIASMathBase_EXPORT std::istream&
00083       operator>><T>(std::istream& is, SymmetricMatrix3x3<T>& mat);
00084 
00085     T* GetData() { return Data_; };
00086     const T* GetData() const { return Data_; }
00087   protected:
00088     
00089     unsigned SymMatrix3x3ToIndex_(const unsigned row, const unsigned col) const;
00090     
00091     /// The matrix data is stored as follows
00092     /// | Data_[0] Data_[1] Data_[2] |
00093     /// | Data_[1] Data_[3] Data_[4] |
00094     /// | Data_[2] Data_[4] Data_[5] |
00095     T Data_[6];
00096     
00097   }; // class
00098 
00099 
00100 } // namespace
00101 
00102 
00103 #endif // __SymmetricMatrix3x3_hh__
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends