getE()

function E=getE(W)

Input:

Global variables:

Output:

Using the expressions in Eq. (8) and your diagouter() operator above, produce a function of the above prototype in the file ``getE.m''.

As a quick test, although you will generally find machine-precision sized imaginary parts due to rounding, your output should always be real. You may verify this behavior with

setup; sch; %# Make sure your global variables are all set
W=randn(prod(S),4)+i*randn(prod(S),4); %# Put 4 random wavefunctions in W
getE(W)
After verifying that your output is indeed real to machine precision for a few different random input $W$'s, it is best to modify your code to take the real part of E using real() before returning, so as to avoid dealing with complex numbers in inappropriate places later.

Tomas Arias 2005-04-03