
      SUBROUTINE C_PR_PT_A(N,K,Matr_input,Matr_output)
C
C	########################################################################
C 
C	Valerio Cappellini                                         February 2007
C
C     USES :: None
C     COMPATIBILITY :: Fortran 90
C     VERSION :: 1.0.0
C
C     C_PR_PT_A.f :: it take as input the 2 INTEGER numbers N and K and a 
C                 (N*K)x(N*K) COMPLEX matrix M and return as output the KxK
C                 COMPLEX matrix "PARTIAL TRACE over A of M"
C
C	########################################################################
C
$	debug
	implicit none
       
      INTEGER N,K,emme,mu,nu
	COMPLEX Matr_input(N*K,N*K), Matr_NK(N,K,N,K), Matr_output(K,K)
	
      Matr_NK=RESHAPE(Matr_input,(/N,K,N,K/),(/(0.,0.)/),(/2,1,4,3/))
	
	Do 10 nu=1,K
		Do 10 mu=1,K
			Matr_output(mu,nu) = 0.
			Do 10 emme=1,N	
   10			Matr_output(mu,nu) = 
     &		Matr_output(mu,nu) + Matr_NK(emme,mu,emme,nu)
      RETURN
      END
