Alright. I’ve had my bus ride. Only screwed up my diagram of the Hamiltonian two or three times, so what do I know? But, at any rate, here I go, racing in where angels fear to tread…
hyp_img={sqrt(sqr(w)+sqr(h))}
n={int(sqrt(($hyp_img^2)/2))}
Bit roundabout. Consider that seed images are square, that w=h
. Thus, hyp_img=(2w^2)^0.5
. To get to n
, you first square hyp_img
: now you have 2w^2
. You divide that by two: now you have w^2
. You take the square root: now you have w
, which you set to n.
You’ve taken the scenic route. Most cads would have set n=w
(or n=h
, seed images being square) right off the dime - and then would have been done with it. They have no sense of romance, of poetry. Pox on them.
One way or another the first key metric, N=n=w
(or h
) has been set to the length of the side of the seed image. This N
is a key measure of your Hamiltonian matrix image, for its sides and diagonal are N*N
.
npts={sqr($n)}
npts_n={$npts-$n}
npts_1={$npts-1}
You’ve got the pixel count, based on N*N
, which, after seed map unroll, is also the length of the main Hamiltonian diagonal: npts=N*N
. You’ve got the length of the immediate off-diagonal: npts_1=N*N-1
. And you’ve got the length of the diagonal offset from the main by N
: npts_n=N*N-N
, or N*(N-1)
, to be undistributive about it.
So far, so good.
200,1,1,1,":begin(const ww=w-1);lerp(0,1,x/ww)"
You are starting to go into the weeds: making use of a derelict intensity ramp based - at some obscure point in @weightt_an’s script development - on a fixed N=200
, which is (most likely) not your N
.
About the derelict ramp: Your code quite nicely reproduces the numpy function np.linspace()
, but - Alas!! - on the Python side, in @weightt_an’s script, the use of that function and the ramp it creates effectively goes unused: debris left over from an aborted experimental direction. Note that @weightt_an is self-studying Python and fooling around with quantum mechanics. Some people just have all of the fun. But in the course of having all of the fun, @weightt_an is trying this out, and trying that out, and leaving the debris of old experiments lying around. One piece of debris makes for yet another bit of roundaboutism. That is, making an entire 200 step linear intensity ramp just to take one step, which works out to 1/(N-1) for an N-step ramp - squares it, and sets it equal to increment
. Most cads would have just written:
increment=1/(N-1)^2
incrementValue=-(N-1)^2
zeroV=4*(N-1)^2
and be done with the ramp entirely. But they have no poetry in their souls. In contrast, @weightt_an builds an entire derelict ramp, you drive up onto it, and we all have a good jolly laugh as you go off the top end and into the Hudson - or whatever dank, urban river serves in your locale. Because in taking a one delta step sample from a ramp based on N=200:
increment='{sqr(i(#-1,1))}'
incrementValue='{-1/$increment}'
zeroV='{4/$increment}'
diag0='{vector(#$npts,$zeroV)}'
are now all based on a Hamiltonian matrix for N=200, which is (probably) not the N of your Hamilton matrix, based as it is on the length of the seed image side and from which npts
, npts_n
and npts_1
derive.
Mismatch. And that, as we Americans say, is the ball game.