<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Wei.<div><br></div><div>I know little of the routine regter, as it is now, but I know very well what it used to be, because I wrote a routine with this name long, long, ago. The routine name is a kind of awkward acronym, where the first "R" stands for real (as opposed to Cegter: guess why); TER stands for iTERative, and EG  for EiGen ... Admittedly, not a very informative name<div><br></div><div>1) a real matrix can be stored in a complex array: the computer will never know, because fortran arguments are passed to subprograms by reference (i.e. the compiler passes just the memory address of the first element of the array: it is the programmer's responsibility to make sure that what the subroutine receives is what the he/she intends). It is admittedly not good programming practice to pass a complex array instead of a real one (or vice versa), but I can assure that this was common practice when I was young (long, long ago).</div><div><br></div><div>2) the eigenvectors of a real symmetric matrix can ALWAYS be chosen to be real, as you can easily convince yourself by simply thinking of the definition of eiegenvectors.</div><div><br></div><div>Hope this helps the peace of your mind.</div><div><br></div><div>Cheers - Stefano Baroni</div><div><br></div><div>PS: I do appreciate that some people take the luxury of digging into the codes. This is the only way to learn the art of scientific computing. Bravo!</div><div><br><div><html>On Apr 2, 2008, at 10:43 PM, willy kohn wrote:</html><br class="Apple-interchange-newline"><blockquote type="cite">Hi, there:<br><br>I was stucked again in the subroutine regterg in the file regterg.f90 when I read the pwscf code. There are two things bothering me. <br><br>One is in the subroutine, the variables psi and hpsi are declared as complex(dp), however, they are used as parameters to call the  Lapack subroutine DGEMM, which requires real numbers. For example, in the line 136, <br> <br> CALL DGEMM( 'T', 'N', nbase, nbase, ndim2, 2.D0 , &<br>               psi, ndmx2, hpsi, ndmx2, 0.D0, hr, nvecx )<br><br>The other one is about the diagonalization of the reduced hamiltonian hr, which is declared as a real symmetric matrix in the subroutine. But in general, the wavefunction psi is complex, how can we guarentee all the elements in the matrix is real? Can the matrix hr be a Hermitian one?<br> <br><br>Best,<br><br>Wei<br> _______________________________________________<br>Pw_forum mailing list<br><a href="mailto:Pw_forum@pwscf.org">Pw_forum@pwscf.org</a><br>http://www.democritos.it/mailman/listinfo/pw_forum<br></blockquote></div><br><div> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">---</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">Stefano Baroni - SISSA</span></font><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">  </span></font><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">&</span></font><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">  </span></font><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">DEMOCRITOS National Simulation Center - Trieste</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">[+39] 040 3787 406 (tel) -528 (fax) / stefanobaroni (skype)</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; font-size: 12px; "><br style="font-size: 12px; "></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">Please, if possible, don't</span></font><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">  </span></font><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">send me MS Word or PowerPoint attachments</span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">Why? See:</span></font><font class="Apple-style-span" size="3"><span class="Apple-style-span" style="font-size: 12px; ">  </span></font><font class="Apple-style-span" color="#0023E9" size="3"><span class="Apple-style-span" style="font-size: 12px; "><a href="http://www.gnu.org/philosophy/no-word-attachments.html">http://www.gnu.org/philosophy/no-word-attachments.html</a></span></font></div><div><font class="Apple-style-span" color="#0023E9" size="3"><span class="Apple-style-span" style="font-size: 12px; "><br class="webkit-block-placeholder"></span></font></div></div></div></span><br class="Apple-interchange-newline"> </div><br></div></div></body></html>