function y=tenergy(h)
%calculates the unrenormalized energy of a function h on the tetrahedral
%sierpinski gasket (h should be a vector of length 4^m for some m).
y=0;
for n=1:1:max(size(h))/4
    v=h(4*n-3:4*n);
    y=y+(v(1)-v(2))^2+(v(1)-v(3))^2+(v(1)-v(4))^2+(v(2)-v(3))^2+(v(2)-v(4))^2+(v(3)-v(4))^2;
end
