All Classes Namespaces Functions Variables Typedefs Enumerations Pages
fixed_square_matrix.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_square_matrix_h
23 #define fixed_square_matrix_h
24 
25 #include "fixed_general_matrix.h"
26 
27 namespace fmatvec {
28 
38  template <int M, class AT> class SquareMatrix<Fixed<M>,AT> : public Matrix<General,Fixed<M>,Fixed<M>,AT> {
39 
40  public:
41  typedef AT AtomicType;
42 
43 // template<class Ini=All<AT> >
44 // SquareMatrix(Ini ini=All<AT>()) : Matrix<General,Fixed<M>,Fixed<M>,AT>(ini) { }
45 // template<class Ini=All<AT> >
46 // SquareMatrix(int m, Ini ini=All<AT>()) : Matrix<General,Fixed<M>,Fixed<M>,AT>(ini) { }
47 
49  SquareMatrix(Init ini=INIT, const AT &a=0) : Matrix<General,Fixed<M>,Fixed<M>,AT>(ini,a) { }
50  SquareMatrix(Eye ini, const AT &a=1) : Matrix<General,Fixed<M>,Fixed<M>,AT>(ini,a) { }
51  SquareMatrix(int m, Noinit ini) : Matrix<General,Fixed<M>,Fixed<M>,AT>(ini) { }
52  SquareMatrix(int m, Init ini=INIT, const AT &a=0) : Matrix<General,Fixed<M>,Fixed<M>,AT>(ini,a) { }
53  SquareMatrix(int m, Eye ini, const AT &a=1) : Matrix<General,Fixed<M>,Fixed<M>,AT>(ini,a) { }
54 
55  SquareMatrix(const char *str) : Matrix<General,Fixed<M>,Fixed<M>,AT>(str) { }
56 
61  template<class Type, class Row, class Col>
62  explicit SquareMatrix(const Matrix<Type,Row,Col,AT>& A) : Matrix<General,Fixed<M>,Fixed<M>,AT>(A) {
63  }
64 
65  template<class Row>
66  SquareMatrix(const SquareMatrix<Row,AT> &A) : Matrix<General,Fixed<M>,Fixed<M>,AT>(A) {
67  }
68 
75  template <class Type, class Row, class Col> SquareMatrix<Fixed<M>,AT>& operator=(const Matrix<Type,Row,Col,AT> &A) {
76  Matrix<General,Fixed<M>,Fixed<M>,AT>::operator=(A);
77  return *this;
78  }
79 
84  int size() const {return M;};
85 
86  using Matrix<General,Fixed<M>,Fixed<M>,AT>::operator();
87  using Matrix<General,Fixed<M>,Fixed<M>,AT>::e;
88 
93  inline operator std::vector<std::vector<AT> >();
94 
95  inline const SquareMatrix<Fixed<M>,AT> T() const;
96 
97  };
98 
99  template <int M, class AT>
100  inline const SquareMatrix<Fixed<M>,AT> SquareMatrix<Fixed<M>,AT>::T() const {
101  SquareMatrix<Fixed<M>,AT> A(NONINIT);
102  for(int i=0; i<M; i++)
103  for(int j=0; j<M; j++)
104  A.e(i,j) = e(j,i);
105  return A;
106  }
107 
108  template <int M, class AT>
109  inline SquareMatrix<Fixed<M>,AT>::operator std::vector<std::vector<AT> >() {
110  std::vector<std::vector<AT> > ret(size());
111  for(int r=0; r<size(); r++) {
112  ret[r].resize(size());
113  for(int c=0; c<size(); c++)
114  ret[r][c]= e(r,c);
115  }
116  return ret;
117  }
118 
119 }
120 
121 #endif
Definition: fmatvec.h:38
SquareMatrix(const Matrix< Type, Row, Col, AT > &A)
Copy Constructor.
Definition: fixed_square_matrix.h:62
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:41
Definition: matrix.h:39
SquareMatrix< Fixed< M >, AT > & operator=(const Matrix< Type, Row, Col, AT > &A)
Copy operator.
Definition: fixed_square_matrix.h:75
Definition: fmatvec.h:44
int size() const
Size.
Definition: fixed_square_matrix.h:84
Definition: matrix.h:38
Basic shape class for matrices.
Definition: types.h:100
Definition: matrix.h:40

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML