All Classes Namespaces Functions Typedefs Enumerations Pages
fixed_row_vector.h
1 /* Copyright (C) 2003-2005 Martin Förg
2 
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact:
18  * martin.o.foerg@googlemail.com
19  *
20  */
21 
22 #ifndef fixed_row_vector_h
23 #define fixed_row_vector_h
24 
25 #include "fixed_general_matrix.h"
26 
27 namespace fmatvec {
28 
37  template <int N, class AT> class RowVector<Fixed<N>,AT> : public Matrix<General,Fixed<1>,Fixed<N>,AT> {
38 
39  using Matrix<General,Fixed<1>,Fixed<N>,AT>::ele;
40 
41  public:
42 
44 
45  protected:
46 
47  template<class Col> inline void deepCopy(const RowVector<Col,AT> &x);
48 
50 
51  public:
52 
53 // template<class Ini=All<AT> >
54 // RowVector(Ini ini=All<AT>()) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini) { }
55 // template<class Ini=All<AT> >
56 // RowVector(int n, Ini ini=All<AT>()) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini) { }
57 
59  RowVector(Init ini=INIT, const AT &a=0) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini,a) { }
60  RowVector(int n, Noinit ini) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini) { }
61  RowVector(int n, Init ini=INIT, const AT &a=0) : Matrix<General,Fixed<1>,Fixed<N>,AT>(ini,a) { }
62 
75  RowVector(const char *str) : Matrix<General,Fixed<1>,Fixed<N>,AT>(str) {
76  }
77 
82  template<class Col>
83  RowVector(const RowVector<Col,AT> &A) : Matrix<General,Fixed<1>,Fixed<N>,AT>(A) {
84  }
85 
90  template<class Type, class Row, class Col>
91  explicit RowVector(const Matrix<Type,Row,Col,AT> &A) : Matrix<General,Fixed<1>,Fixed<N>,AT>(A) {
92  }
93 
104  AT& operator()(int i) {
105 #ifndef FMATVEC_NO_BOUNDS_CHECK
106  assert(i>=0);
107  assert(i<N);
108 #endif
109  return e(i);
110  };
111 
116  const AT& operator()(int i) const {
117 #ifndef FMATVEC_NO_BOUNDS_CHECK
118  assert(i>=0);
119  assert(i<N);
120 #endif
121  return e(i);
122  };
123 
124  AT& e(int i) {
125  return ele[0][i];
126  };
127 
132  const AT& e(int i) const {
133  return ele[0][i];
134  };
135 
143  inline RowVector<Fixed<N>,AT>& init(const AT &a=0);
144  inline RowVector<Fixed<N>,AT>& init(Init, const AT &a=0) { return init(a); }
145  inline RowVector<Fixed<N>,AT>& init(Noinit, const AT &a=0) { return *this; }
146 
151  int size() const {return N;};
152 
159  int inc() const {return 1;};
160 
161  using Matrix<General,Fixed<1>,Fixed<N>,AT>::operator();
162 
163  inline const Vector<Fixed<N>,AT> T() const;
164  };
165 
166  template <int N, class AT>
167  inline RowVector<Fixed<N>,AT>& RowVector<Fixed<N>,AT>::init(const AT &val) {
168  for(int i=0; i<N; i++)
169  e(i) = val;
170  return *this;
171  }
172 
173  template <int N, class AT>
174  inline const Vector<Fixed<N>,AT> RowVector<Fixed<N>,AT>::T() const {
175  Vector<Fixed<N>,AT> x(NONINIT);
176  for(int i=0; i<N; i++)
177  x.e(i) = e(i);
178  return x;
179  }
180 
182 
183  template <int N, class AT> template <class Col>
184  inline void RowVector<Fixed<N>,AT>::deepCopy(const RowVector<Col,AT> &x) {
185  for(int i=0; i<N; i++)
186  e(i) = x.e(i);
187  }
188 
190 
191 }
192 #endif
Definition: types.h:68
This is the basic matrix class for arbitrary matrices.
Definition: matrix.h:56
Definition: matrix.h:39
Definition: matrix.h:218
RowVector(const RowVector< Col, AT > &A)
Copy Constructor.
Definition: fixed_row_vector.h:83
Definition: matrix.h:215
int size() const
Size.
Definition: fixed_row_vector.h:151
RowVector(const Matrix< Type, Row, Col, AT > &A)
Copy Constructor.
Definition: fixed_row_vector.h:91
Definition: matrix.h:38
int inc() const
Increment.
Definition: fixed_row_vector.h:159
Basic shape class for matrices.
Definition: types.h:100
AT & operator()(int i)
Element operator.
Definition: fixed_row_vector.h:104
const AT & operator()(int i) const
Element operator.
Definition: fixed_row_vector.h:116
const AT & e(int i) const
Element operator.
Definition: fixed_row_vector.h:132
RowVector(const char *str)
String Constructor.
Definition: fixed_row_vector.h:75

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML