All Classes Namespaces Functions Typedefs Enumerations Pages
var_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 var_square_matrix_h
23 #define var_square_matrix_h
24 
25 #include "fixed_general_matrix.h"
26 
27 namespace fmatvec {
28 
38  template <class AT> class SquareMatrix<Var,AT> : public Matrix<General,Var,Var,AT> {
39 
41 
42  public:
43 
49 
50 // template<class Ini=All<AT> >
51 // SquareMatrix(int m, Ini ini=All<AT>()) : Matrix<General,Var,Var,AT>(m,m,ini) { }
52 
53  SquareMatrix(int m, Noinit ini) : Matrix<General,Var,Var,AT>(m,m,ini) { }
54  SquareMatrix(int m, Init ini=INIT, const AT &a=0) : Matrix<General,Var,Var,AT>(m,m,ini,a) { }
55  SquareMatrix(int m, Eye ini, const AT &a=1) : Matrix<General,Var,Var,AT>(m,m,ini,a) { }
56 
57  SquareMatrix(const char *str) : Matrix<General,Var,Var,AT>(str) { }
58 
63  template<class Type, class Row, class Col>
64  explicit SquareMatrix(const Matrix<Type,Row,Col,AT>& A) : Matrix<General,Var,Var,AT>(A) {
65  }
66 
67  template<class Row>
69  }
70 
71  SquareMatrix<Var,AT>& resize() {
72  Matrix<General,Var,Var,AT>::resize();
73  return *this;
74  }
75 
76  SquareMatrix<Var,AT>& resize(int m, Noinit) {
77  Matrix<General,Var,Var,AT>::resize(m,m,Noinit());
78  return *this;
79  }
80 
81  SquareMatrix<Var,AT>& resize(int m, Init ini=INIT, const AT &a=0) {
82  Matrix<General,Var,Var,AT>::resize(m,m,ini,a);
83  return *this;
84  }
85 
86  SquareMatrix<Var,AT>& resize(int m, Eye ini, const AT &a=1) {
87  Matrix<General,Var,Var,AT>::resize(m,m,ini,a);
88  return *this;
89  }
90 
97  template <class Type, class Row, class Col> SquareMatrix<Var,AT>& operator=(const Matrix<Type,Row,Col,AT> &A) {
99  return *this;
100  }
101 
106  int size() const {return M;};
107 
110 
115  inline operator std::vector<std::vector<AT> >();
116 
117  inline const SquareMatrix<Var,AT> T() const;
118 
119  };
120 
121  template <class AT>
122  inline const SquareMatrix<Var,AT> SquareMatrix<Var,AT>::T() const {
123  SquareMatrix<Var,AT> A(size(),NONINIT);
124  for(int i=0; i<M; i++)
125  for(int j=0; j<M; j++)
126  A.e(i,j) = e(j,i);
127  return A;
128  }
129 
130  template <class AT>
131  inline SquareMatrix<Var,AT>::operator std::vector<std::vector<AT> >() {
132  std::vector<std::vector<AT> > ret(size());
133  for(int r=0; r<size(); r++) {
134  ret[r].resize(size());
135  for(int c=0; c<size(); c++)
136  ret[r][c]= e(r,c);
137  }
138  return ret;
139  }
140 
141 }
142 
143 #endif
This is the basic matrix class for arbitrary matrices.
Definition: matrix.h:56
SquareMatrix(const Matrix< Type, Row, Col, AT > &A)
Copy Constructor.
Definition: var_square_matrix.h:64
Definition: types.h:65
SquareMatrix()
Standard constructor.
Definition: var_square_matrix.h:48
SquareMatrix< Var, AT > & operator=(const Matrix< Type, Row, Col, AT > &A)
Copy operator.
Definition: var_square_matrix.h:97
Definition: matrix.h:212
This is a matrix class of general quadratic matrices.
Definition: var_square_matrix.h:38
Definition: matrix.h:38
Basic shape class for matrices.
Definition: types.h:100
int size() const
Size.
Definition: var_square_matrix.h:106

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML