btk_vector.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, 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_VECTOR_HPP
00025 #define BTK_MATH_BTK_VECTOR_HPP
00026 
00027 #include <ostream>
00028 
00029 #include <boost/numeric/ublas/vector.hpp>
00030 #include <boost/numeric/ublas/io.hpp>
00031 
00032 #include <btk/core/math/common_functions.hpp>
00033 
00034 namespace uBLAS = boost::numeric::ublas;
00035 
00036 namespace BTK {
00037 namespace MATH {
00038 
00039 class BTKVector : public uBLAS::vector<double, uBLAS::bounded_array<double,3> >
00040 {
00041  public:
00042   typedef uBLAS::vector<double, uBLAS::bounded_array<double,3> > base_vector;
00043 
00045   BTKVector() : base_vector(3) {}
00046 
00048   BTKVector(double val) : base_vector(3)
00049   {
00050     this->operator[](0) = val;
00051     this->operator[](1) = val;
00052     this->operator[](2) = val;
00053   }
00054 
00056   BTKVector(BTKVector const & src) : base_vector(src) {}
00057 
00059   BTKVector(double x, double y, double z) : base_vector(3) {
00060     this->operator[](0) = x;
00061     this->operator[](1) = y;
00062     this->operator[](2) = z;
00063   }
00064 
00066   template <class E>
00067     BTKVector(uBLAS::vector_expression<E> const & e) : base_vector(e) {}
00068 
00069   virtual ~BTKVector() {}
00070 
00072   template <class E>
00073     BTKVector & operator=(uBLAS::vector_expression<E> const & e) {
00074     base_vector::operator=(e);
00075     return *this;
00076   }
00077 
00079   BTKVector & operator=(BTKVector const & rhs) {
00080     base_vector::operator=(static_cast<base_vector>(rhs));
00081     return *this;
00082   }
00083 
00084   bool operator==(BTKVector const & rhs) const {
00085     return (BTK::MATH::equivalent(this->operator[](0),rhs[0]) &&
00086             BTK::MATH::equivalent(this->operator[](1),rhs[1]) &&
00087             BTK::MATH::equivalent(this->operator[](2),rhs[2]));
00088   }
00089 
00090   bool operator!=(BTKVector const & rhs) const {
00091     return !(*this == rhs);
00092   }
00093 
00094 };
00095 
00096 } // namespace MATH
00097 } // namespace BTK
00098 
00099 #endif // BTK_MATH_BTK_VECTOR_HPP

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