22 #ifndef square_matrix_h 23 #define square_matrix_h 25 #include "general_matrix.h" 50 static constexpr
bool isVector {
false};
51 typedef AT value_type;
66 explicit SquareMatrix(
int m, Init ini=INIT,
const AT &a=AT()) : Matrix<General,Ref,Ref,AT>(m,m,ini,a) { }
67 explicit SquareMatrix(
int m, Eye ini,
const AT &a=1) : Matrix<General,Ref,Ref,AT>(m,m,ini,a) { }
89 template<
class Type,
class Row,
class Col>
91 FMATVEC_ASSERT(A.
rows() == A.
cols(), AT);
105 SquareMatrix<Ref,AT>& resize(
int m, Noinit) {
106 Matrix<General,Ref,Ref,AT>::resize(m,m,Noinit());
110 SquareMatrix<Ref,AT>& resize(
int m, Init ini=INIT,
const AT &a=AT()) {
111 Matrix<General,Ref,Ref,AT>::resize(m,m,ini,a);
115 SquareMatrix<Ref,AT>& resize(
int m, Eye ini,
const AT &a=1) {
116 Matrix<General,Ref,Ref,AT>::resize(m,m,ini,a);
124 throw std::runtime_error(
"Cannot resize a square matrix with different dimensions for rows and columns.");
146 FMATVEC_ASSERT(A.
rows() == A.
cols(), AT);
163 FMATVEC_ASSERT(A.
rows() == A.
cols(), AT);
175 FMATVEC_ASSERT(A.
rows() == A.
cols(), AT);
185 int rows()
const {
return m;}
186 int cols()
const {
return m;}
188 using Matrix<General,Ref,Ref,AT>::operator();
189 using Matrix<General,Ref,Ref,AT>::e;
195 explicit inline operator std::vector<std::vector<AT>>()
const;
197 const SquareMatrix<Ref,AT> T()
const;
202 std::vector<std::vector<AT>> ret(size());
203 for(
int r=0; r<size(); r++) {
204 ret[r].resize(size());
205 for(
int c=0; c<size(); c++)
206 ret[r][c]= this->er(r,c);
214 for(
int i=0; i<m; i++)
215 for(
int j=0; j<m; j++)
SquareMatrix< Ref, AT > & operator=(const Matrix< Type, Row, Col, AT > &A)
Assignment operator.
Definition: square_matrix.h:145
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:41
int rows() const
Number of rows.
Definition: general_matrix.h:304
SquareMatrix(int m, AT *ele)
Regular Constructor.
Definition: square_matrix.h:101
Dummy shape class for square matrices.
Definition: types.h:181
SquareMatrix(const SquareMatrix< Row, AT > &A)
Copy Constructor.
Definition: square_matrix.h:82
SquareMatrix< Ref, AT > & operator=(const SquareMatrix< Ref, AT > &A)
Assignment operator.
Definition: square_matrix.h:134
int size() const
Size.
Definition: square_matrix.h:184
void resize(int m, int n)
Definition: square_matrix.h:122
int cols() const
Number of columns.
This is a matrix class for general matrices.
Definition: general_matrix.h:41
SquareMatrix(const Matrix< Type, Row, Col, AT > &A)
Copy Constructor.
Definition: square_matrix.h:90
Namespace fmatvec.
Definition: _memory.cc:28
int cols() const
Number of columns.
Definition: general_matrix.h:310
SquareMatrix()
Standard constructor.
Definition: square_matrix.h:60
Basic shape class for matrices.
Definition: types.h:132
This is a matrix class of general quadratic matrices.
Definition: square_matrix.h:39
SquareMatrix(const SquareMatrix< Ref, AT > &A)
Copy Constructor.
Definition: square_matrix.h:74
SquareMatrix< Ref, AT > & operator&=(SquareMatrix< Ref, AT > &A)
Reference operator.
Definition: square_matrix.h:157
int rows() const
Number of rows.