Minkowski question-mark function: Difference between revisions
Content deleted Content added
J: it's not ieee 754 representation, it's the algorithm |
m J: make it easier to experiment with longer continued fractions (though it's not clear that this length should match for minkowski and its inverse) |
||
Line 469:
Implementation:
<lang J>
minkowski=: {{
f=. 1|y
node=. *i.2 2 NB. node of Stern-Brocot tree
B=.''
for.i.
B=.B, b=. f>:%/t=. +/node
node=. t (1-b)} node
end.
(<.y)+B+/ .*
}}
Line 485 ⟶ 487:
cur=. 0 NB. 1 if generating "top" side of cf
cnt=. 1 NB. bits
for.i.
if. f=<. f do.
cf=. cf,%cnt break.
|