Last active
August 29, 2015 14:15
-
-
Save clausecker/ea936084dd5038cc4c06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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