#ifndef GRID_DENSE_MATRIX_H #define GRID_DENSE_MATRIX_H namespace Grid { ///////////////////////////////////////////////////////////// // Matrix untils ///////////////////////////////////////////////////////////// template using DenseVector = std::vector; template using DenseMatrix = DenseVector >; template void Size(DenseVector & vec, int &N) { N= vec.size(); } template void Size(DenseMatrix & mat, int &N,int &M) { N= mat.size(); M= mat[0].size(); } template void SizeSquare(DenseMatrix & mat, int &N) { int M; Size(mat,N,M); assert(N==M); } template void Resize(DenseMatrix & mat, int N, int M) { mat.resize(N); for(int i=0;i void Fill(DenseMatrix & mat, T&val) { int N,M; Size(mat,N,M); for(int i=0;i DenseMatrix Transpose(DenseMatrix & mat){ int N,M; Size(mat,N,M); DenseMatrix C; Resize(C,M,N); for(int i=0;i void Unity(DenseMatrix &A){ int N; SizeSquare(A,N); for(int i=0;i void PlusUnit(DenseMatrix & A,T c){ int dim; SizeSquare(A,dim); for(int i=0;i DenseMatrix HermitianConj(DenseMatrix &mat){ int dim; SizeSquare(mat,dim); DenseMatrix C; Resize(C,dim,dim); for(int i=0;i DenseMatrix GetSubMtx(DenseMatrix &A,int row_st, int row_end, int col_st, int col_end) { DenseMatrix H; Resize(H,row_end - row_st,col_end-col_st); for(int i = row_st; i #include #endif