btk_matrix.hpp

Go to the documentation of this file.
00001 // -*- mode: c++; indent-tabs-mode: nil; -*-
00002 //
00003 //The Biomolecule Toolkit (BTK) is a C++ library for use in the
00004 //modeling, analysis, and design of biological macromolecules.
00005 //Copyright (C) 2004-2006, Tim Robertson <kid50@users.sourceforge.net>
00006 //
00007 //This program is free software; you can redistribute it and/or modify
00008 //it under the terms of the GNU Lesser General Public License as published
00009 //by the Free Software Foundation; either version 2.1 of the License, or (at
00010 //your option) any later version.
00011 //
00012 //This program is distributed in the hope that it will be useful,  but
00013 //WITHOUT ANY WARRANTY; without even the implied warranty of'
00014 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 //Lesser General Public License for more details.
00016 //
00017 //You should have received a copy of the GNU Lesser General Public License
00018 //along with this program; if not, write to the Free Software Foundation,
00019 //Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00020 
00023 
00024 #ifndef BTK_MATH_BTK_MATRIX_HPP
00025 #define BTK_MATH_BTK_MATRIX_HPP
00026 
00027 #include <ostream>
00028 
00029 #include <boost/numeric/ublas/matrix.hpp>
00030 #include <boost/numeric/ublas/matrix_proxy.hpp>
00031 #include <boost/numeric/ublas/io.hpp>
00032 
00033 #include <btk/core/math/common_functions.hpp>
00034 
00035 namespace uBLAS = boost::numeric::ublas;
00036 
00037 namespace BTK {
00038 namespace MATH {
00039 
00040 class BTKMatrix : public uBLAS::matrix<double>
00041 {
00042  public:
00043   typedef uBLAS::matrix<double> base_matrix;
00044 
00046   BTKMatrix(size_type x = 3, size_type y = 3) : base_matrix(x,y) {}
00047 
00049   BTKMatrix(size_type x, size_type y, double val) : base_matrix(x,y)
00050   {
00051     for (size_type i = 0; i < x; ++i)
00052       for (size_type j = 0; j < y; ++j)
00053         this->operator()(i,j) = val;
00054   }
00055 
00057   BTKMatrix(BTKMatrix const & src) : base_matrix(src) {}
00058 
00060   template <class E>
00061     BTKMatrix(uBLAS::matrix_expression<E> const & e) : base_matrix(e) {}
00062 
00063   virtual ~BTKMatrix() {}
00064 
00066   template <class E>
00067     BTKMatrix & operator=(uBLAS::matrix_expression<E> const & e) {
00068     base_matrix::assign(e);
00069     return *this;
00070   }
00071 
00073   bool operator==(BTKMatrix const & rhs) const {
00074     base_matrix::size_type x,y;
00075     for (x = 0; x < 3; ++x) {
00076       for (y = 0; y < 3; ++y) {
00077         if (!BTK::MATH::equivalent(this->operator()(x,y),rhs(x,y))) 
00078           return false;
00079       }
00080     }
00081     return true;
00082   }
00083 
00085   bool operator!=(BTKMatrix const & rhs) const {
00086     return !(*this == rhs);
00087   }
00088 };
00089 
00090 } // namespace MATH
00091 } // namespace BTK
00092 
00093 #endif // BTK_MATH_BTK_MATRIX_HPP

Generated on Sun Jul 15 20:46:24 2007 for BTK Core by  doxygen 1.5.1