/************************************************************************************* Grid physics library, www.github.com/paboyle/Grid Source file: ./lib/algorithms/iterative/DenseMatrix.h Copyright (C) 2015 Author: Peter Boyle Author: paboyle This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. See the full license in the file "LICENSE" in the top level distribution directory *************************************************************************************/ /* END LEGAL */ #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(DenseVector & mat, int N) { mat.resize(N); } 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