22 #ifndef square_matrix_h
23 #define square_matrix_h
25 #include "general_matrix.h"
59 SquareMatrix(
int n,
int lda,
int tp, Memory<AT> memory,
const AT* ele) :
Matrix<General,Ref,Ref,AT>(n, n, lda, tp, memory, ele) {
76 SquareMatrix(
int m, Init ini=INIT,
const AT &a=0) : Matrix<General,Ref,Ref,AT>(m,m,ini,a) { }
77 SquareMatrix(
int m, Eye ini,
const AT &a=1) : Matrix<General,Ref,Ref,AT>(m,m,ini,a) { }
104 #ifndef FMATVEC_NO_SIZE_CHECK
109 template<
class Type,
class Row,
class Col>
113 SquareMatrix<Ref,AT>& resize() {
114 Matrix<General,Ref,Ref,AT>::resize();
118 SquareMatrix<Ref,AT>& resize(
int m, Noinit) {
119 Matrix<General,Ref,Ref,AT>::resize(m,m,Noinit());
123 SquareMatrix<Ref,AT>& resize(
int m, Init ini=INIT,
const AT &a=0) {
124 Matrix<General,Ref,Ref,AT>::resize(m,m,ini,a);
128 SquareMatrix<Ref,AT>& resize(
int m, Eye ini,
const AT &a=1) {
129 Matrix<General,Ref,Ref,AT>::resize(m,m,ini,a);
152 template<
class Type,
class Row,
class Col>
SquareMatrix<Ref,AT>& operator<<(const Matrix<Type,Row,Col,AT> &A) {
153 #ifndef FMATVEC_NO_SIZE_CHECK
154 assert(A.rows() == A.cols());
172 #ifndef FMATVEC_NO_SIZE_CHECK
198 inline operator std::vector<std::vector<AT> >();
204 const SquareMatrix<Ref,AT> T()
const {
205 return SquareMatrix<Ref,AT>(n, lda, tp?
false:
true, memory, ele);
220 std::vector<std::vector<AT> > ret(size());
222 for(
int r=0; r<size(); r++) {
223 ret[r].resize(size());
224 for(
int c=0; c<size(); c++)
225 ret[r][c]= this->et(r,c);
229 for(
int r=0; r<size(); r++) {
230 ret[r].resize(size());
231 for(
int c=0; c<size(); c++)
232 ret[r][c]= this->er(r,c);
This is the basic matrix class for arbitrary matrices.
Definition: matrix.h:56
SquareMatrix(int m, AT *ele)
Regular Constructor.
Definition: square_matrix.h:86
AT & operator()(int i, int j)
Standard constructor.
Definition: matrix.h:85
int rows() const
Number of rows.
Definition: general_matrix.h:270
SquareMatrix< Ref, AT > & operator=(const SquareMatrix< Ref, AT > &A)
Assignment operator.
Definition: square_matrix.h:141
int size() const
Size.
Definition: square_matrix.h:183
This is a matrix class for general matrices.
Definition: general_matrix.h:40
std::istream & operator>>(std::istream &is, Matrix< Type, Row, Col, AT > &A)
Matrix input.
Definition: matrix.h:170
SquareMatrix()
Standard constructor.
Definition: square_matrix.h:70
SquareMatrix(const Matrix< General, Ref, Ref, AT > &A)
Copy Constructor.
Definition: square_matrix.h:103
This is an index class for creating submatrices.
Definition: index.h:34
RowVector< Ref, AT > trans(const Vector< Ref, AT > &x)
Transpose of a vector.
Definition: linear_algebra.h:1470
Basic shape class for matrices.
Definition: types.h:100
This is a matrix class of general quadratic matrices.
Definition: square_matrix.h:38
SquareMatrix(const SquareMatrix< Ref, AT > &A)
Copy Constructor.
Definition: square_matrix.h:97
SquareMatrix< Ref, AT > & operator>>(const SquareMatrix< Ref, AT > &A)
Reference operator.
Definition: square_matrix.h:166
int cols() const
Number of columns.
Definition: general_matrix.h:276