22 #ifndef square_matrix_h 23 #define square_matrix_h 25 #include "general_matrix.h" 50 typedef AT value_type;
64 explicit SquareMatrix(
int m, Init ini=INIT,
const AT &a=AT()) : Matrix<General,Ref,Ref,AT>(m,m,ini,a) { }
65 explicit SquareMatrix(
int m, Eye ini,
const AT &a=1) : Matrix<General,Ref,Ref,AT>(m,m,ini,a) { }
87 template<
class Type,
class Row,
class Col>
89 FMATVEC_ASSERT(A.
rows() == A.
cols(), AT);
103 SquareMatrix<Ref,AT>& resize(
int m, Noinit) {
104 Matrix<General,Ref,Ref,AT>::resize(m,m,Noinit());
108 SquareMatrix<Ref,AT>& resize(
int m, Init ini=INIT,
const AT &a=AT()) {
109 Matrix<General,Ref,Ref,AT>::resize(m,m,ini,a);
113 SquareMatrix<Ref,AT>& resize(
int m, Eye ini,
const AT &a=1) {
114 Matrix<General,Ref,Ref,AT>::resize(m,m,ini,a);
122 throw std::runtime_error(
"Cannot resize a square matrix with different dimensions for rows and columns.");
144 FMATVEC_ASSERT(A.
rows() == A.
cols(), AT);
161 FMATVEC_ASSERT(A.
rows() == A.
cols(), AT);
173 FMATVEC_ASSERT(A.
rows() == A.
cols(), AT);
191 explicit inline operator std::vector<std::vector<AT>>()
const;
198 std::vector<std::vector<AT>> ret(size());
199 for(
int r=0; r<size(); r++) {
200 ret[r].resize(size());
201 for(
int c=0; c<size(); c++)
202 ret[r][c]= this->er(r,c);
210 for(
int i=0; i<m; i++)
211 for(
int j=0; j<m; j++)
SquareMatrix< Ref, AT > & operator=(const Matrix< Type, Row, Col, AT > &A)
Assignment operator.
Definition: square_matrix.h:143
This is the basic matrix class for arbitrary matrices.
Definition: fmatvec.h:41
int rows() const
Number of rows.
Definition: general_matrix.h:278
SquareMatrix(int m, AT *ele)
Regular Constructor.
Definition: square_matrix.h:99
SquareMatrix(const SquareMatrix< Row, AT > &A)
Copy Constructor.
Definition: square_matrix.h:80
SquareMatrix< Ref, AT > & operator=(const SquareMatrix< Ref, AT > &A)
Assignment operator.
Definition: square_matrix.h:132
int size() const
Size.
Definition: square_matrix.h:182
void resize(int m, int n)
Definition: square_matrix.h:120
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:88
Namespace fmatvec.
Definition: _memory.cc:28
int cols() const
Number of columns.
Definition: general_matrix.h:284
SquareMatrix()
Standard constructor.
Definition: square_matrix.h:58
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:72
SquareMatrix< Ref, AT > & operator&=(SquareMatrix< Ref, AT > &A)
Reference operator.
Definition: square_matrix.h:155
int rows() const
Number of rows.