update2: there is something weird in the bath-fit procedure now: for
some values of the parameters the first call to the fit is different from the
second one (i.e. for a restart after 1loop) with identical bath....

update: code cleaned. H*v products have been regrouped so to have a two routines (each with
 _d and _c cases): the routine spHtimesV_x perform matrix-vector product within arpack
diagonalization to get the spectrum of H, using small blocks vectors in parallel mode.
the routine lanc_spHtimesV_x perform matrix-vector product withing plain lanczos
algorithm for green's function evaluation, using large vectors and reshuffling where
necessary.

Code was tested at 1st loop against serial case and F77 code (M.Capone) with perfect
agreement.

MPI_UPDATE: mpi version of the code updated.
STORING (hash-table) of the Hamiltonian has been REINTRODUCED.
To keep memeory low the hash-table is allocated to Nchunk row on each node (previously
all nodes allocated the full sparse matrix!).
This required a modified version of the matrix mpi vector-product and to introduce a
parallel version of the matrix-vector product for the plain lanczos too (used for GF).
In addtion the building up of the Hamiltonian now (ed_geth) needs to explicitly
construct hermitian-conjugate parts of the Hamiltonian rather then obtaining them
by symmetry, in order to respect locality of the rows.

note: the products of operators needs to be normal ordered so that c-operators apply BEFORE cdg-operators.

hint: it should be possible to clean out the code by simplifying a little the definition of the matrix vector products
so to have same routines name, with same arguments!, but different behavior exploiting pre-compilation.

note2: it would be interesting to implement the nup-ndw scheme for the Hilbert space construction, while keeping
the Hamiltonian structure identical (this is a trick just for the vectors).
complex p_arpack driver, ed_type--> ed_method (full or lanc) and ed_type is now used to choose between real or cmplx structure
simplification in observable print out.
intermediate commitment: still debuggin the MIXGF code, but I need to access the
fullED in the master branch
update: some bugs fixed
complex p_arpack driver, ed_type--> ed_method (full or lanc) and ed_type is now used to choose between real or cmplx structure
simplification in observable print out.
debug code with mixed gf.
find the last two bugs:
1. the norm in lanczos gf accumulation was not declared as complex in the routine
(it is passed as complex because we need to accumulate the mixed GF with some
complex constant on front) [norm2,cnorm2].
2. the application of two operators required two independent loops over the
components of the target states [state_vec].

Cleaning and more testing to come. YUPPIE!!
some cleaning after manual diff w/ respect to +devel branch

mixgf code: test go on.
more results on HM-2bands show convincing data.
test PAM against 1-band solution with old code (which indeed gave results identical to new code 1-band).
the results for PAM are very very good, practically on top. tested for Mott Ins and Correlated metal.

Ready to merge into devel and test back normal bath_type and full_ed calculations.
Merge branch 'devel_multi-orbital_mixgf' into devel

Conflicts:
	DMFT_ED.f90
	ED_AUX_FUNX.f90
	ED_GREENS_FUNCTIONS.f90
	ED_OBSERVABLES.f90
	ED_VARS_GLOBAL.f90
	Makefile
UPDATE: bath shape updated to simplify some routines (now bath=array(:,:)).
First dimension is Nspin, second dimension depends on the bath_type.
CG fit updated with Weiss Field flag, to be tested G_0^{-1} rather than Delta_anderson.
This should improve the fit near band-insulating state.

UPDATE: multi-band AND complex version of the code.

Code extended to multi-band case, with and without hybridizations,
for both real symmetric and hermitian Hamiltonian.

- test of the hermitian PAM with real components is successful, indicating
that the hermitian multi-band solution works.

TODO: the FULL ED branch must be extended too, both for mixed-gf and hermitian models.
UPDATE: fit of the G_0(iw) added.

The flag cg_scheme has been added to select which function to fit (delta for \Delta function,
weiss for G_0). The fit scheme weiss DOES NOT rely on analytic calculation of the gradient.
While this is in princple easy to do, my implementation was kind of unstable so I decided to
rely on numerical differentiation.

Actually I extended the fmin_cg routine in SCIFOR so to behave like in scipy: it the gradient
function is optional now. If not provided is evaluated numerically.

Tests for the Hubbard model give good results, though performed for small number of Bath sites.
The Matsubara functions are almost identical, the spectral function have some differences probably
caused by the small cluster size and the different fit scheme.

Massimo noted that it is in principle more meaningful to fit the Green's function G_0, though
the \Delta function can be more sensible in some circumstances.
For the time being I will stick to \Delta fit scheme, unless the fit becomes unstable, such as
near band insulators.
Merge branch 'devel'

Conflicts:
	ARPACK_LANCZOS.f90
	ED_AUX_FUNX.f90
	ED_CHI2FIT.f90
	ED_DIAG.f90
	ED_GREENS_FUNCTIONS.f90
	ED_HAMILTONIAN.f90
	ED_OBSERVABLES.f90
	MATRIX_SPARSE.f90
	Makefile
	ed_HtimesV_direct.f90
	ed_HtimesV_direct_mpi.f90
	lanczos_arpack_c.f90