grad ( hash v -- gradient )


Vocabulary
noise

Inputs
hashan object
van object


Outputs
gradientan object


Definition


:: grad ( hash v -- gradient )
hash 8 bitand zero? [ v first ] [ v second ] if
:> u hash 12 bitand zero?
[ v second ]
[ hash 13 bitand 12 = [ v first ] [ v third ] if ] if
:> v hash 1 bitand zero? [ u ] [ u neg ] if hash 2 bitand
zero? [ v ] [ v neg ] if + ; inline