fixed_row_vector.h
00001 /* Copyright (C) 2003-2005  Martin Förg
00002 
00003  * This library is free software; you can redistribute it and/or
00004  * modify it under the terms of the GNU Lesser General Public
00005  * License as published by the Free Software Foundation; either
00006  * version 2.1 of the License, or (at your option) any later version.
00007  * 
00008  * This library is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * Lesser General Public License for more details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public
00014  * License along with this library; if not, write to the Free Software
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00016  *
00017  * Contact:
00018  *   martin.o.foerg@googlemail.com
00019  *
00020  */
00021 
00022 #ifndef fixed_row_vector_h
00023 #define fixed_row_vector_h
00024 
00025 #include "fixed_general_matrix.h"
00026 
00027 namespace fmatvec {
00028 
00037   template <int N, class AT> class RowVector<Fixed<N>,AT> : public Matrix<General,Fixed<1>,Fixed<N>,AT> {
00038 
00039     using Matrix<General,Fixed<1>,Fixed<N>,AT>::ele;
00040 
00041     public:
00042 
00044     
00045     protected:
00046 
00047     template<class Col> inline void deepCopy(const RowVector<Col,AT> &x);
00048 
00050 
00051     public:
00052 
00053 //      template<class Ini=All<AT> >
00054 //        RowVector(Ini ini=All<AT>()) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini) { }
00055 //      template<class Ini=All<AT> >
00056 //        RowVector(int n, Ini ini=All<AT>()) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini) { }
00057 
00058       RowVector(Noinit ini) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini) { }
00059       RowVector(Init ini=INIT, const AT &a=0) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini,a) { }
00060       RowVector(int n, Noinit ini) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini) { }
00061       RowVector(int n, Init ini=INIT, const AT &a=0) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini,a) { }
00062 
00075       RowVector(const char *str) : Matrix<General,Fixed<1>,Fixed<N>,AT>(str) {
00076       }
00077 
00082       template<class Col>
00083       RowVector(const RowVector<Col,AT> &A) : Matrix<General,Fixed<1>,Fixed<N>,AT>(A) {
00084       }
00085 
00090       template<class Type, class Row, class Col>
00091       explicit RowVector(const Matrix<Type,Row,Col,AT> &A) : Matrix<General,Fixed<1>,Fixed<N>,AT>(A) {
00092       }
00093 
00104       AT& operator()(int i) {
00105 #ifndef FMATVEC_NO_BOUNDS_CHECK
00106         assert(i>=0);
00107         assert(i<N);
00108 #endif
00109         return e(i);
00110       };
00111 
00116       const AT& operator()(int i) const {
00117 #ifndef FMATVEC_NO_BOUNDS_CHECK
00118         assert(i>=0);
00119         assert(i<N);
00120 #endif
00121         return e(i);
00122       };
00123 
00124       AT& e(int i) {
00125         return ele[0][i];
00126       };
00127 
00132       const AT& e(int i) const {
00133         return ele[0][i];
00134       };
00135 
00143       inline RowVector<Fixed<N>,AT>& init(const AT &a=0); 
00144       inline RowVector<Fixed<N>,AT>& init(Init, const AT &a=0) { return init(a); }
00145       inline RowVector<Fixed<N>,AT>& init(Noinit, const AT &a=0) { return *this; }
00146 
00151       int size() const {return N;};
00152 
00159       int inc() const {return 1;};
00160 
00161       using Matrix<General,Fixed<1>,Fixed<N>,AT>::operator();
00162 
00163       inline const Vector<Fixed<N>,AT> T() const;
00164   };
00165 
00166   template <int N, class AT>
00167     inline RowVector<Fixed<N>,AT>& RowVector<Fixed<N>,AT>::init(const AT &val) {
00168       for(int i=0; i<N; i++) 
00169         e(i) = val; 
00170       return *this;
00171     }
00172 
00173   template <int N, class AT>
00174     inline const Vector<Fixed<N>,AT> RowVector<Fixed<N>,AT>::T() const {
00175       Vector<Fixed<N>,AT> x(NONINIT);
00176       for(int i=0; i<N; i++)
00177         x.e(i) = e(i);
00178       return x;
00179     }
00180 
00182  
00183   template <int N, class AT> template <class Col>
00184     inline void RowVector<Fixed<N>,AT>::deepCopy(const RowVector<Col,AT> &x) {
00185       for(int i=0; i<N; i++)
00186         e(i) = x.e(i);
00187     }
00188 
00190 
00191 }
00192 #endif