22#ifndef square_matrix_h
23#define square_matrix_h
25#include "general_matrix.h"
50 static constexpr bool isVector {
false};
51 using value_type = AT;
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;
202 explicit SquareMatrix(
const std::vector<std::vector<AT>> &m);
204 const SquareMatrix<Ref,AT> T()
const;
209 std::vector<std::vector<AT>> ret(rows(),std::vector<AT>(cols()));
210 for(
int r=0; r<size(); r++) {
211 for(
int c=0; c<size(); c++)
219 for(
int r=0; r<rows(); r++) {
220 if(
static_cast<int>(m[r].size())!=cols())
221 throw std::runtime_error(
"The rows of the input have different length.");
222 for(
int c=0; c<cols(); c++)
230 for(
int i=0; i<m; i++)
231 for(
int j=0; j<m; j++)
Shape class for general matrices.
Definition: types.h:116
This is a matrix class for general matrices.
Definition: general_matrix.h:42
int cols() const
Number of columns.
Definition: general_matrix.h:313
int rows() const
Number of rows.
Definition: general_matrix.h:307
This is the basic matrix class for arbitrary matrices.
Definition: matrix.h:52
int rows() const
Number of rows.
int cols() const
Number of columns.
This is a matrix class of general quadratic matrices.
Definition: square_matrix.h:39
SquareMatrix()
Standard constructor.
Definition: square_matrix.h:60
SquareMatrix(const Matrix< Type, Row, Col, AT > &A)
Copy Constructor.
Definition: square_matrix.h:90
SquareMatrix< Ref, AT > & operator=(const Matrix< Type, Row, Col, AT > &A)
Assignment operator.
Definition: square_matrix.h:145
void resize(int m, int n)
Definition: square_matrix.h:122
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
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
SquareMatrix(int m, AT *ele)
Regular Constructor.
Definition: square_matrix.h:101
int size() const
Size.
Definition: square_matrix.h:184
Dummy shape class for square matrices.
Definition: types.h:173
Namespace fmatvec.
Definition: _memory.cc:28