Skip to content

Instantly share code, notes, and snippets.

@clausecker
Last active August 29, 2015 14:15
Show Gist options
  • Select an option

  • Save clausecker/ea936084dd5038cc4c06 to your computer and use it in GitHub Desktop.

Select an option

Save clausecker/ea936084dd5038cc4c06 to your computer and use it in GitHub Desktop.
Note 'author'
The Computer Language Benchmarks Game
http://benchmarksgame.alioth.debian.org/
contributed by Robert Clausecker <[email protected]>
)
NB. entry at x,y of infinite matrix A
A =: >:@:[ %@:+ -:@:(* >:)@:+
NB. get the first y by y elements of A
subA =: A"0 _~&i. M.
MultiplyAv =: +/ .* subA@#
MultiplyAtv =: +/ .* |:@subA@#
MultiplyAtAv =: MultiplyAtv@MultiplyAv
Approximate =: 3 : 0
n =. y
v =. MultiplyAtAv^:19 n#1
u =. MultiplyAtAv v
vBv =. +/ u * v
vv =. +/ *: v
%: vBv % vv
)
n =: (2 ".@{:: ]) :: (100"_) ARGV
echo 0j9 ": Approximate n
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment