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