ruby_on_ruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (493) hide show
  1. data/.gitignore +18 -0
  2. data/.rvmrc +1 -0
  3. data/Gemfile +6 -0
  4. data/LICENSE +22 -0
  5. data/README.md +66 -0
  6. data/Rakefile +1 -0
  7. data/lib/ruby_on_ruby.rb +5 -0
  8. data/lib/ruby_on_ruby/console.rb +7 -0
  9. data/lib/ruby_on_ruby/context.rb +33 -0
  10. data/lib/ruby_on_ruby/file_loader.rb +31 -0
  11. data/lib/ruby_on_ruby/ruby_stream.rb +27 -0
  12. data/lib/ruby_on_ruby/version.rb +3 -0
  13. data/lib/rubyonruby.rb +1 -0
  14. data/ruby_in_ruby.gemspec +19 -0
  15. data/vendor/javascripts/emscripted-ruby/lib/.document +106 -0
  16. data/vendor/javascripts/emscripted-ruby/lib/English.rb +155 -0
  17. data/vendor/javascripts/emscripted-ruby/lib/Env.rb +18 -0
  18. data/vendor/javascripts/emscripted-ruby/lib/README +96 -0
  19. data/vendor/javascripts/emscripted-ruby/lib/abbrev.rb +103 -0
  20. data/vendor/javascripts/emscripted-ruby/lib/base64.rb +133 -0
  21. data/vendor/javascripts/emscripted-ruby/lib/benchmark.rb +572 -0
  22. data/vendor/javascripts/emscripted-ruby/lib/cgi-lib.rb +272 -0
  23. data/vendor/javascripts/emscripted-ruby/lib/cgi.rb +2308 -0
  24. data/vendor/javascripts/emscripted-ruby/lib/cgi/.document +2 -0
  25. data/vendor/javascripts/emscripted-ruby/lib/cgi/session.rb +498 -0
  26. data/vendor/javascripts/emscripted-ruby/lib/cgi/session/pstore.rb +111 -0
  27. data/vendor/javascripts/emscripted-ruby/lib/complex.rb +663 -0
  28. data/vendor/javascripts/emscripted-ruby/lib/csv.rb +992 -0
  29. data/vendor/javascripts/emscripted-ruby/lib/date.rb +1767 -0
  30. data/vendor/javascripts/emscripted-ruby/lib/date/format.rb +1190 -0
  31. data/vendor/javascripts/emscripted-ruby/lib/date2.rb +5 -0
  32. data/vendor/javascripts/emscripted-ruby/lib/debug.rb +947 -0
  33. data/vendor/javascripts/emscripted-ruby/lib/delegate.rb +337 -0
  34. data/vendor/javascripts/emscripted-ruby/lib/drb.rb +2 -0
  35. data/vendor/javascripts/emscripted-ruby/lib/drb/acl.rb +146 -0
  36. data/vendor/javascripts/emscripted-ruby/lib/drb/drb.rb +1782 -0
  37. data/vendor/javascripts/emscripted-ruby/lib/drb/eq.rb +16 -0
  38. data/vendor/javascripts/emscripted-ruby/lib/drb/extserv.rb +64 -0
  39. data/vendor/javascripts/emscripted-ruby/lib/drb/extservm.rb +89 -0
  40. data/vendor/javascripts/emscripted-ruby/lib/drb/gw.rb +122 -0
  41. data/vendor/javascripts/emscripted-ruby/lib/drb/invokemethod.rb +36 -0
  42. data/vendor/javascripts/emscripted-ruby/lib/drb/observer.rb +22 -0
  43. data/vendor/javascripts/emscripted-ruby/lib/drb/ssl.rb +190 -0
  44. data/vendor/javascripts/emscripted-ruby/lib/drb/timeridconv.rb +91 -0
  45. data/vendor/javascripts/emscripted-ruby/lib/drb/unix.rb +108 -0
  46. data/vendor/javascripts/emscripted-ruby/lib/e2mmap.rb +195 -0
  47. data/vendor/javascripts/emscripted-ruby/lib/erb.rb +880 -0
  48. data/vendor/javascripts/emscripted-ruby/lib/eregex.rb +37 -0
  49. data/vendor/javascripts/emscripted-ruby/lib/fileutils.rb +1591 -0
  50. data/vendor/javascripts/emscripted-ruby/lib/finalize.rb +193 -0
  51. data/vendor/javascripts/emscripted-ruby/lib/find.rb +79 -0
  52. data/vendor/javascripts/emscripted-ruby/lib/forwardable.rb +218 -0
  53. data/vendor/javascripts/emscripted-ruby/lib/ftools.rb +261 -0
  54. data/vendor/javascripts/emscripted-ruby/lib/generator.rb +418 -0
  55. data/vendor/javascripts/emscripted-ruby/lib/getoptlong.rb +621 -0
  56. data/vendor/javascripts/emscripted-ruby/lib/getopts.rb +127 -0
  57. data/vendor/javascripts/emscripted-ruby/lib/gserver.rb +253 -0
  58. data/vendor/javascripts/emscripted-ruby/lib/importenv.rb +33 -0
  59. data/vendor/javascripts/emscripted-ruby/lib/ipaddr.rb +814 -0
  60. data/vendor/javascripts/emscripted-ruby/lib/irb.rb +346 -0
  61. data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/chws.rb +33 -0
  62. data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/fork.rb +39 -0
  63. data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/help.rb +34 -0
  64. data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/load.rb +67 -0
  65. data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/nop.rb +39 -0
  66. data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/pushws.rb +39 -0
  67. data/vendor/javascripts/emscripted-ruby/lib/irb/cmd/subirb.rb +43 -0
  68. data/vendor/javascripts/emscripted-ruby/lib/irb/completion.rb +205 -0
  69. data/vendor/javascripts/emscripted-ruby/lib/irb/context.rb +255 -0
  70. data/vendor/javascripts/emscripted-ruby/lib/irb/ext/change-ws.rb +62 -0
  71. data/vendor/javascripts/emscripted-ruby/lib/irb/ext/history.rb +110 -0
  72. data/vendor/javascripts/emscripted-ruby/lib/irb/ext/loader.rb +120 -0
  73. data/vendor/javascripts/emscripted-ruby/lib/irb/ext/math-mode.rb +37 -0
  74. data/vendor/javascripts/emscripted-ruby/lib/irb/ext/multi-irb.rb +241 -0
  75. data/vendor/javascripts/emscripted-ruby/lib/irb/ext/save-history.rb +85 -0
  76. data/vendor/javascripts/emscripted-ruby/lib/irb/ext/tracer.rb +61 -0
  77. data/vendor/javascripts/emscripted-ruby/lib/irb/ext/use-loader.rb +65 -0
  78. data/vendor/javascripts/emscripted-ruby/lib/irb/ext/workspaces.rb +56 -0
  79. data/vendor/javascripts/emscripted-ruby/lib/irb/extend-command.rb +264 -0
  80. data/vendor/javascripts/emscripted-ruby/lib/irb/frame.rb +67 -0
  81. data/vendor/javascripts/emscripted-ruby/lib/irb/help.rb +33 -0
  82. data/vendor/javascripts/emscripted-ruby/lib/irb/init.rb +259 -0
  83. data/vendor/javascripts/emscripted-ruby/lib/irb/input-method.rb +120 -0
  84. data/vendor/javascripts/emscripted-ruby/lib/irb/lc/error.rb +30 -0
  85. data/vendor/javascripts/emscripted-ruby/lib/irb/lc/help-message +35 -0
  86. data/vendor/javascripts/emscripted-ruby/lib/irb/lc/ja/error.rb +27 -0
  87. data/vendor/javascripts/emscripted-ruby/lib/irb/lc/ja/help-message +36 -0
  88. data/vendor/javascripts/emscripted-ruby/lib/irb/locale.rb +184 -0
  89. data/vendor/javascripts/emscripted-ruby/lib/irb/notifier.rb +145 -0
  90. data/vendor/javascripts/emscripted-ruby/lib/irb/output-method.rb +85 -0
  91. data/vendor/javascripts/emscripted-ruby/lib/irb/ruby-lex.rb +1149 -0
  92. data/vendor/javascripts/emscripted-ruby/lib/irb/ruby-token.rb +273 -0
  93. data/vendor/javascripts/emscripted-ruby/lib/irb/slex.rb +285 -0
  94. data/vendor/javascripts/emscripted-ruby/lib/irb/version.rb +16 -0
  95. data/vendor/javascripts/emscripted-ruby/lib/irb/workspace.rb +107 -0
  96. data/vendor/javascripts/emscripted-ruby/lib/irb/ws-for-case-2.rb +15 -0
  97. data/vendor/javascripts/emscripted-ruby/lib/irb/xmp.rb +86 -0
  98. data/vendor/javascripts/emscripted-ruby/lib/jcode.rb +220 -0
  99. data/vendor/javascripts/emscripted-ruby/lib/logger.rb +703 -0
  100. data/vendor/javascripts/emscripted-ruby/lib/mailread.rb +62 -0
  101. data/vendor/javascripts/emscripted-ruby/lib/mathn.rb +308 -0
  102. data/vendor/javascripts/emscripted-ruby/lib/matrix.rb +1278 -0
  103. data/vendor/javascripts/emscripted-ruby/lib/mkmf.rb +1811 -0
  104. data/vendor/javascripts/emscripted-ruby/lib/monitor.rb +352 -0
  105. data/vendor/javascripts/emscripted-ruby/lib/mutex_m.rb +122 -0
  106. data/vendor/javascripts/emscripted-ruby/lib/net/ftp.rb +927 -0
  107. data/vendor/javascripts/emscripted-ruby/lib/net/http.rb +2277 -0
  108. data/vendor/javascripts/emscripted-ruby/lib/net/https.rb +173 -0
  109. data/vendor/javascripts/emscripted-ruby/lib/net/imap.rb +3371 -0
  110. data/vendor/javascripts/emscripted-ruby/lib/net/pop.rb +999 -0
  111. data/vendor/javascripts/emscripted-ruby/lib/net/protocol.rb +392 -0
  112. data/vendor/javascripts/emscripted-ruby/lib/net/smtp.rb +1014 -0
  113. data/vendor/javascripts/emscripted-ruby/lib/net/telnet.rb +756 -0
  114. data/vendor/javascripts/emscripted-ruby/lib/observer.rb +192 -0
  115. data/vendor/javascripts/emscripted-ruby/lib/open-uri.rb +678 -0
  116. data/vendor/javascripts/emscripted-ruby/lib/open3.rb +101 -0
  117. data/vendor/javascripts/emscripted-ruby/lib/optparse.rb +1790 -0
  118. data/vendor/javascripts/emscripted-ruby/lib/optparse/date.rb +17 -0
  119. data/vendor/javascripts/emscripted-ruby/lib/optparse/shellwords.rb +6 -0
  120. data/vendor/javascripts/emscripted-ruby/lib/optparse/time.rb +10 -0
  121. data/vendor/javascripts/emscripted-ruby/lib/optparse/uri.rb +6 -0
  122. data/vendor/javascripts/emscripted-ruby/lib/optparse/version.rb +70 -0
  123. data/vendor/javascripts/emscripted-ruby/lib/ostruct.rb +146 -0
  124. data/vendor/javascripts/emscripted-ruby/lib/parsearg.rb +87 -0
  125. data/vendor/javascripts/emscripted-ruby/lib/parsedate.rb +53 -0
  126. data/vendor/javascripts/emscripted-ruby/lib/pathname.rb +1062 -0
  127. data/vendor/javascripts/emscripted-ruby/lib/ping.rb +64 -0
  128. data/vendor/javascripts/emscripted-ruby/lib/pp.rb +654 -0
  129. data/vendor/javascripts/emscripted-ruby/lib/prettyprint.rb +896 -0
  130. data/vendor/javascripts/emscripted-ruby/lib/profile.rb +6 -0
  131. data/vendor/javascripts/emscripted-ruby/lib/profiler.rb +59 -0
  132. data/vendor/javascripts/emscripted-ruby/lib/pstore.rb +395 -0
  133. data/vendor/javascripts/emscripted-ruby/lib/racc/parser.rb +442 -0
  134. data/vendor/javascripts/emscripted-ruby/lib/rational.rb +564 -0
  135. data/vendor/javascripts/emscripted-ruby/lib/readbytes.rb +41 -0
  136. data/vendor/javascripts/emscripted-ruby/lib/resolv-replace.rb +62 -0
  137. data/vendor/javascripts/emscripted-ruby/lib/resolv.rb +2210 -0
  138. data/vendor/javascripts/emscripted-ruby/lib/rexml/attlistdecl.rb +62 -0
  139. data/vendor/javascripts/emscripted-ruby/lib/rexml/attribute.rb +185 -0
  140. data/vendor/javascripts/emscripted-ruby/lib/rexml/cdata.rb +67 -0
  141. data/vendor/javascripts/emscripted-ruby/lib/rexml/child.rb +96 -0
  142. data/vendor/javascripts/emscripted-ruby/lib/rexml/comment.rb +80 -0
  143. data/vendor/javascripts/emscripted-ruby/lib/rexml/doctype.rb +271 -0
  144. data/vendor/javascripts/emscripted-ruby/lib/rexml/document.rb +208 -0
  145. data/vendor/javascripts/emscripted-ruby/lib/rexml/dtd/attlistdecl.rb +10 -0
  146. data/vendor/javascripts/emscripted-ruby/lib/rexml/dtd/dtd.rb +51 -0
  147. data/vendor/javascripts/emscripted-ruby/lib/rexml/dtd/elementdecl.rb +17 -0
  148. data/vendor/javascripts/emscripted-ruby/lib/rexml/dtd/entitydecl.rb +56 -0
  149. data/vendor/javascripts/emscripted-ruby/lib/rexml/dtd/notationdecl.rb +39 -0
  150. data/vendor/javascripts/emscripted-ruby/lib/rexml/element.rb +1227 -0
  151. data/vendor/javascripts/emscripted-ruby/lib/rexml/encoding.rb +71 -0
  152. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/CP-1252.rb +103 -0
  153. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/EUC-JP.rb +35 -0
  154. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/ICONV.rb +22 -0
  155. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/ISO-8859-1.rb +7 -0
  156. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/ISO-8859-15.rb +72 -0
  157. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/SHIFT-JIS.rb +37 -0
  158. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/SHIFT_JIS.rb +1 -0
  159. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/UNILE.rb +34 -0
  160. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/US-ASCII.rb +30 -0
  161. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/UTF-16.rb +35 -0
  162. data/vendor/javascripts/emscripted-ruby/lib/rexml/encodings/UTF-8.rb +18 -0
  163. data/vendor/javascripts/emscripted-ruby/lib/rexml/entity.rb +165 -0
  164. data/vendor/javascripts/emscripted-ruby/lib/rexml/formatters/default.rb +109 -0
  165. data/vendor/javascripts/emscripted-ruby/lib/rexml/formatters/pretty.rb +137 -0
  166. data/vendor/javascripts/emscripted-ruby/lib/rexml/formatters/transitive.rb +56 -0
  167. data/vendor/javascripts/emscripted-ruby/lib/rexml/functions.rb +382 -0
  168. data/vendor/javascripts/emscripted-ruby/lib/rexml/instruction.rb +70 -0
  169. data/vendor/javascripts/emscripted-ruby/lib/rexml/light/node.rb +196 -0
  170. data/vendor/javascripts/emscripted-ruby/lib/rexml/namespace.rb +47 -0
  171. data/vendor/javascripts/emscripted-ruby/lib/rexml/node.rb +75 -0
  172. data/vendor/javascripts/emscripted-ruby/lib/rexml/output.rb +24 -0
  173. data/vendor/javascripts/emscripted-ruby/lib/rexml/parent.rb +166 -0
  174. data/vendor/javascripts/emscripted-ruby/lib/rexml/parseexception.rb +51 -0
  175. data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/baseparser.rb +503 -0
  176. data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/lightparser.rb +60 -0
  177. data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/pullparser.rb +196 -0
  178. data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/sax2parser.rb +238 -0
  179. data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/streamparser.rb +46 -0
  180. data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/treeparser.rb +97 -0
  181. data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/ultralightparser.rb +56 -0
  182. data/vendor/javascripts/emscripted-ruby/lib/rexml/parsers/xpathparser.rb +698 -0
  183. data/vendor/javascripts/emscripted-ruby/lib/rexml/quickpath.rb +266 -0
  184. data/vendor/javascripts/emscripted-ruby/lib/rexml/rexml.rb +32 -0
  185. data/vendor/javascripts/emscripted-ruby/lib/rexml/sax2listener.rb +97 -0
  186. data/vendor/javascripts/emscripted-ruby/lib/rexml/source.rb +251 -0
  187. data/vendor/javascripts/emscripted-ruby/lib/rexml/streamlistener.rb +92 -0
  188. data/vendor/javascripts/emscripted-ruby/lib/rexml/syncenumerator.rb +33 -0
  189. data/vendor/javascripts/emscripted-ruby/lib/rexml/text.rb +344 -0
  190. data/vendor/javascripts/emscripted-ruby/lib/rexml/undefinednamespaceexception.rb +8 -0
  191. data/vendor/javascripts/emscripted-ruby/lib/rexml/validation/relaxng.rb +559 -0
  192. data/vendor/javascripts/emscripted-ruby/lib/rexml/validation/validation.rb +155 -0
  193. data/vendor/javascripts/emscripted-ruby/lib/rexml/validation/validationexception.rb +9 -0
  194. data/vendor/javascripts/emscripted-ruby/lib/rexml/xmldecl.rb +119 -0
  195. data/vendor/javascripts/emscripted-ruby/lib/rexml/xmltokens.rb +18 -0
  196. data/vendor/javascripts/emscripted-ruby/lib/rexml/xpath.rb +66 -0
  197. data/vendor/javascripts/emscripted-ruby/lib/rexml/xpath_parser.rb +792 -0
  198. data/vendor/javascripts/emscripted-ruby/lib/rinda/rinda.rb +283 -0
  199. data/vendor/javascripts/emscripted-ruby/lib/rinda/ring.rb +271 -0
  200. data/vendor/javascripts/emscripted-ruby/lib/rinda/tuplespace.rb +642 -0
  201. data/vendor/javascripts/emscripted-ruby/lib/rss.rb +19 -0
  202. data/vendor/javascripts/emscripted-ruby/lib/rss/0.9.rb +428 -0
  203. data/vendor/javascripts/emscripted-ruby/lib/rss/1.0.rb +452 -0
  204. data/vendor/javascripts/emscripted-ruby/lib/rss/2.0.rb +111 -0
  205. data/vendor/javascripts/emscripted-ruby/lib/rss/atom.rb +749 -0
  206. data/vendor/javascripts/emscripted-ruby/lib/rss/content.rb +31 -0
  207. data/vendor/javascripts/emscripted-ruby/lib/rss/content/1.0.rb +10 -0
  208. data/vendor/javascripts/emscripted-ruby/lib/rss/content/2.0.rb +12 -0
  209. data/vendor/javascripts/emscripted-ruby/lib/rss/converter.rb +162 -0
  210. data/vendor/javascripts/emscripted-ruby/lib/rss/dublincore.rb +161 -0
  211. data/vendor/javascripts/emscripted-ruby/lib/rss/dublincore/1.0.rb +13 -0
  212. data/vendor/javascripts/emscripted-ruby/lib/rss/dublincore/2.0.rb +13 -0
  213. data/vendor/javascripts/emscripted-ruby/lib/rss/dublincore/atom.rb +17 -0
  214. data/vendor/javascripts/emscripted-ruby/lib/rss/image.rb +193 -0
  215. data/vendor/javascripts/emscripted-ruby/lib/rss/itunes.rb +410 -0
  216. data/vendor/javascripts/emscripted-ruby/lib/rss/maker.rb +44 -0
  217. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/0.9.rb +467 -0
  218. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/1.0.rb +434 -0
  219. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/2.0.rb +223 -0
  220. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/atom.rb +172 -0
  221. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/base.rb +868 -0
  222. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/content.rb +21 -0
  223. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/dublincore.rb +124 -0
  224. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/entry.rb +163 -0
  225. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/feed.rb +429 -0
  226. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/image.rb +111 -0
  227. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/itunes.rb +242 -0
  228. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/slash.rb +33 -0
  229. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/syndication.rb +18 -0
  230. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/taxonomy.rb +118 -0
  231. data/vendor/javascripts/emscripted-ruby/lib/rss/maker/trackback.rb +61 -0
  232. data/vendor/javascripts/emscripted-ruby/lib/rss/parser.rb +541 -0
  233. data/vendor/javascripts/emscripted-ruby/lib/rss/rexmlparser.rb +54 -0
  234. data/vendor/javascripts/emscripted-ruby/lib/rss/rss.rb +1312 -0
  235. data/vendor/javascripts/emscripted-ruby/lib/rss/slash.rb +49 -0
  236. data/vendor/javascripts/emscripted-ruby/lib/rss/syndication.rb +67 -0
  237. data/vendor/javascripts/emscripted-ruby/lib/rss/taxonomy.rb +145 -0
  238. data/vendor/javascripts/emscripted-ruby/lib/rss/trackback.rb +288 -0
  239. data/vendor/javascripts/emscripted-ruby/lib/rss/utils.rb +111 -0
  240. data/vendor/javascripts/emscripted-ruby/lib/rss/xml-stylesheet.rb +105 -0
  241. data/vendor/javascripts/emscripted-ruby/lib/rss/xml.rb +71 -0
  242. data/vendor/javascripts/emscripted-ruby/lib/rss/xmlparser.rb +93 -0
  243. data/vendor/javascripts/emscripted-ruby/lib/rss/xmlscanner.rb +121 -0
  244. data/vendor/javascripts/emscripted-ruby/lib/rubyunit.rb +6 -0
  245. data/vendor/javascripts/emscripted-ruby/lib/runit/assert.rb +73 -0
  246. data/vendor/javascripts/emscripted-ruby/lib/runit/cui/testrunner.rb +51 -0
  247. data/vendor/javascripts/emscripted-ruby/lib/runit/error.rb +9 -0
  248. data/vendor/javascripts/emscripted-ruby/lib/runit/testcase.rb +45 -0
  249. data/vendor/javascripts/emscripted-ruby/lib/runit/testresult.rb +44 -0
  250. data/vendor/javascripts/emscripted-ruby/lib/runit/testsuite.rb +26 -0
  251. data/vendor/javascripts/emscripted-ruby/lib/runit/topublic.rb +8 -0
  252. data/vendor/javascripts/emscripted-ruby/lib/scanf.rb +702 -0
  253. data/vendor/javascripts/emscripted-ruby/lib/securerandom.rb +137 -0
  254. data/vendor/javascripts/emscripted-ruby/lib/set.rb +1233 -0
  255. data/vendor/javascripts/emscripted-ruby/lib/shell.rb +269 -0
  256. data/vendor/javascripts/emscripted-ruby/lib/shell/builtin-command.rb +154 -0
  257. data/vendor/javascripts/emscripted-ruby/lib/shell/command-processor.rb +592 -0
  258. data/vendor/javascripts/emscripted-ruby/lib/shell/error.rb +26 -0
  259. data/vendor/javascripts/emscripted-ruby/lib/shell/filter.rb +110 -0
  260. data/vendor/javascripts/emscripted-ruby/lib/shell/process-controller.rb +260 -0
  261. data/vendor/javascripts/emscripted-ruby/lib/shell/system-command.rb +168 -0
  262. data/vendor/javascripts/emscripted-ruby/lib/shell/version.rb +16 -0
  263. data/vendor/javascripts/emscripted-ruby/lib/shellwords.rb +172 -0
  264. data/vendor/javascripts/emscripted-ruby/lib/singleton.rb +360 -0
  265. data/vendor/javascripts/emscripted-ruby/lib/soap/attachment.rb +107 -0
  266. data/vendor/javascripts/emscripted-ruby/lib/soap/baseData.rb +942 -0
  267. data/vendor/javascripts/emscripted-ruby/lib/soap/element.rb +258 -0
  268. data/vendor/javascripts/emscripted-ruby/lib/soap/encodingstyle/aspDotNetHandler.rb +213 -0
  269. data/vendor/javascripts/emscripted-ruby/lib/soap/encodingstyle/handler.rb +100 -0
  270. data/vendor/javascripts/emscripted-ruby/lib/soap/encodingstyle/literalHandler.rb +226 -0
  271. data/vendor/javascripts/emscripted-ruby/lib/soap/encodingstyle/soapHandler.rb +582 -0
  272. data/vendor/javascripts/emscripted-ruby/lib/soap/generator.rb +268 -0
  273. data/vendor/javascripts/emscripted-ruby/lib/soap/header/handler.rb +57 -0
  274. data/vendor/javascripts/emscripted-ruby/lib/soap/header/handlerset.rb +70 -0
  275. data/vendor/javascripts/emscripted-ruby/lib/soap/header/simplehandler.rb +44 -0
  276. data/vendor/javascripts/emscripted-ruby/lib/soap/httpconfigloader.rb +119 -0
  277. data/vendor/javascripts/emscripted-ruby/lib/soap/mapping.rb +10 -0
  278. data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/factory.rb +355 -0
  279. data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/mapping.rb +381 -0
  280. data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/registry.rb +541 -0
  281. data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/rubytypeFactory.rb +475 -0
  282. data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/typeMap.rb +50 -0
  283. data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/wsdlencodedregistry.rb +280 -0
  284. data/vendor/javascripts/emscripted-ruby/lib/soap/mapping/wsdlliteralregistry.rb +418 -0
  285. data/vendor/javascripts/emscripted-ruby/lib/soap/marshal.rb +59 -0
  286. data/vendor/javascripts/emscripted-ruby/lib/soap/mimemessage.rb +240 -0
  287. data/vendor/javascripts/emscripted-ruby/lib/soap/netHttpClient.rb +190 -0
  288. data/vendor/javascripts/emscripted-ruby/lib/soap/parser.rb +251 -0
  289. data/vendor/javascripts/emscripted-ruby/lib/soap/processor.rb +66 -0
  290. data/vendor/javascripts/emscripted-ruby/lib/soap/property.rb +333 -0
  291. data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/cgistub.rb +206 -0
  292. data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/driver.rb +254 -0
  293. data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/element.rb +325 -0
  294. data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/httpserver.rb +129 -0
  295. data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/proxy.rb +497 -0
  296. data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/router.rb +594 -0
  297. data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/rpc.rb +25 -0
  298. data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/soaplet.rb +162 -0
  299. data/vendor/javascripts/emscripted-ruby/lib/soap/rpc/standaloneServer.rb +43 -0
  300. data/vendor/javascripts/emscripted-ruby/lib/soap/soap.rb +140 -0
  301. data/vendor/javascripts/emscripted-ruby/lib/soap/streamHandler.rb +229 -0
  302. data/vendor/javascripts/emscripted-ruby/lib/soap/wsdlDriver.rb +575 -0
  303. data/vendor/javascripts/emscripted-ruby/lib/sync.rb +311 -0
  304. data/vendor/javascripts/emscripted-ruby/lib/tempfile.rb +209 -0
  305. data/vendor/javascripts/emscripted-ruby/lib/test/unit.rb +280 -0
  306. data/vendor/javascripts/emscripted-ruby/lib/test/unit/assertionfailederror.rb +14 -0
  307. data/vendor/javascripts/emscripted-ruby/lib/test/unit/assertions.rb +622 -0
  308. data/vendor/javascripts/emscripted-ruby/lib/test/unit/autorunner.rb +220 -0
  309. data/vendor/javascripts/emscripted-ruby/lib/test/unit/collector.rb +43 -0
  310. data/vendor/javascripts/emscripted-ruby/lib/test/unit/collector/dir.rb +107 -0
  311. data/vendor/javascripts/emscripted-ruby/lib/test/unit/collector/objectspace.rb +34 -0
  312. data/vendor/javascripts/emscripted-ruby/lib/test/unit/error.rb +56 -0
  313. data/vendor/javascripts/emscripted-ruby/lib/test/unit/failure.rb +51 -0
  314. data/vendor/javascripts/emscripted-ruby/lib/test/unit/testcase.rb +160 -0
  315. data/vendor/javascripts/emscripted-ruby/lib/test/unit/testresult.rb +80 -0
  316. data/vendor/javascripts/emscripted-ruby/lib/test/unit/testsuite.rb +76 -0
  317. data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/console/testrunner.rb +127 -0
  318. data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/fox/testrunner.rb +268 -0
  319. data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/gtk/testrunner.rb +416 -0
  320. data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/gtk2/testrunner.rb +465 -0
  321. data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/testrunnermediator.rb +68 -0
  322. data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/testrunnerutilities.rb +46 -0
  323. data/vendor/javascripts/emscripted-ruby/lib/test/unit/ui/tk/testrunner.rb +260 -0
  324. data/vendor/javascripts/emscripted-ruby/lib/test/unit/util/backtracefilter.rb +40 -0
  325. data/vendor/javascripts/emscripted-ruby/lib/test/unit/util/observable.rb +90 -0
  326. data/vendor/javascripts/emscripted-ruby/lib/test/unit/util/procwrapper.rb +48 -0
  327. data/vendor/javascripts/emscripted-ruby/lib/thread.rb +479 -0
  328. data/vendor/javascripts/emscripted-ruby/lib/thwait.rb +169 -0
  329. data/vendor/javascripts/emscripted-ruby/lib/time.rb +797 -0
  330. data/vendor/javascripts/emscripted-ruby/lib/timeout.rb +122 -0
  331. data/vendor/javascripts/emscripted-ruby/lib/tmpdir.rb +130 -0
  332. data/vendor/javascripts/emscripted-ruby/lib/tracer.rb +167 -0
  333. data/vendor/javascripts/emscripted-ruby/lib/tsort.rb +290 -0
  334. data/vendor/javascripts/emscripted-ruby/lib/un.rb +235 -0
  335. data/vendor/javascripts/emscripted-ruby/lib/uri.rb +29 -0
  336. data/vendor/javascripts/emscripted-ruby/lib/uri/common.rb +611 -0
  337. data/vendor/javascripts/emscripted-ruby/lib/uri/ftp.rb +198 -0
  338. data/vendor/javascripts/emscripted-ruby/lib/uri/generic.rb +1122 -0
  339. data/vendor/javascripts/emscripted-ruby/lib/uri/http.rb +100 -0
  340. data/vendor/javascripts/emscripted-ruby/lib/uri/https.rb +20 -0
  341. data/vendor/javascripts/emscripted-ruby/lib/uri/ldap.rb +190 -0
  342. data/vendor/javascripts/emscripted-ruby/lib/uri/ldaps.rb +12 -0
  343. data/vendor/javascripts/emscripted-ruby/lib/uri/mailto.rb +266 -0
  344. data/vendor/javascripts/emscripted-ruby/lib/weakref.rb +100 -0
  345. data/vendor/javascripts/emscripted-ruby/lib/webrick.rb +29 -0
  346. data/vendor/javascripts/emscripted-ruby/lib/webrick/accesslog.rb +67 -0
  347. data/vendor/javascripts/emscripted-ruby/lib/webrick/cgi.rb +257 -0
  348. data/vendor/javascripts/emscripted-ruby/lib/webrick/compat.rb +15 -0
  349. data/vendor/javascripts/emscripted-ruby/lib/webrick/config.rb +97 -0
  350. data/vendor/javascripts/emscripted-ruby/lib/webrick/cookie.rb +110 -0
  351. data/vendor/javascripts/emscripted-ruby/lib/webrick/htmlutils.rb +25 -0
  352. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth.rb +45 -0
  353. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/authenticator.rb +79 -0
  354. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/basicauth.rb +65 -0
  355. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/digestauth.rb +343 -0
  356. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/htdigest.rb +91 -0
  357. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/htgroup.rb +61 -0
  358. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/htpasswd.rb +83 -0
  359. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpauth/userdb.rb +29 -0
  360. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpproxy.rb +254 -0
  361. data/vendor/javascripts/emscripted-ruby/lib/webrick/httprequest.rb +365 -0
  362. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpresponse.rb +327 -0
  363. data/vendor/javascripts/emscripted-ruby/lib/webrick/https.rb +63 -0
  364. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpserver.rb +210 -0
  365. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet.rb +22 -0
  366. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/abstract.rb +71 -0
  367. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/cgi_runner.rb +47 -0
  368. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/cgihandler.rb +108 -0
  369. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/erbhandler.rb +54 -0
  370. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/filehandler.rb +435 -0
  371. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpservlet/prochandler.rb +33 -0
  372. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpstatus.rb +126 -0
  373. data/vendor/javascripts/emscripted-ruby/lib/webrick/httputils.rb +399 -0
  374. data/vendor/javascripts/emscripted-ruby/lib/webrick/httpversion.rb +49 -0
  375. data/vendor/javascripts/emscripted-ruby/lib/webrick/log.rb +88 -0
  376. data/vendor/javascripts/emscripted-ruby/lib/webrick/server.rb +200 -0
  377. data/vendor/javascripts/emscripted-ruby/lib/webrick/ssl.rb +126 -0
  378. data/vendor/javascripts/emscripted-ruby/lib/webrick/utils.rb +100 -0
  379. data/vendor/javascripts/emscripted-ruby/lib/webrick/version.rb +13 -0
  380. data/vendor/javascripts/emscripted-ruby/lib/wsdl/binding.rb +65 -0
  381. data/vendor/javascripts/emscripted-ruby/lib/wsdl/data.rb +64 -0
  382. data/vendor/javascripts/emscripted-ruby/lib/wsdl/definitions.rb +250 -0
  383. data/vendor/javascripts/emscripted-ruby/lib/wsdl/documentation.rb +32 -0
  384. data/vendor/javascripts/emscripted-ruby/lib/wsdl/import.rb +80 -0
  385. data/vendor/javascripts/emscripted-ruby/lib/wsdl/importer.rb +38 -0
  386. data/vendor/javascripts/emscripted-ruby/lib/wsdl/info.rb +39 -0
  387. data/vendor/javascripts/emscripted-ruby/lib/wsdl/message.rb +54 -0
  388. data/vendor/javascripts/emscripted-ruby/lib/wsdl/operation.rb +130 -0
  389. data/vendor/javascripts/emscripted-ruby/lib/wsdl/operationBinding.rb +108 -0
  390. data/vendor/javascripts/emscripted-ruby/lib/wsdl/param.rb +85 -0
  391. data/vendor/javascripts/emscripted-ruby/lib/wsdl/parser.rb +163 -0
  392. data/vendor/javascripts/emscripted-ruby/lib/wsdl/part.rb +52 -0
  393. data/vendor/javascripts/emscripted-ruby/lib/wsdl/port.rb +84 -0
  394. data/vendor/javascripts/emscripted-ruby/lib/wsdl/portType.rb +73 -0
  395. data/vendor/javascripts/emscripted-ruby/lib/wsdl/service.rb +61 -0
  396. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/address.rb +40 -0
  397. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/binding.rb +49 -0
  398. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/body.rb +56 -0
  399. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/cgiStubCreator.rb +76 -0
  400. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/classDefCreator.rb +314 -0
  401. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/classDefCreatorSupport.rb +126 -0
  402. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/clientSkeltonCreator.rb +78 -0
  403. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/complexType.rb +161 -0
  404. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/data.rb +42 -0
  405. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/definitions.rb +149 -0
  406. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/driverCreator.rb +95 -0
  407. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/element.rb +28 -0
  408. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/fault.rb +56 -0
  409. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/header.rb +86 -0
  410. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/headerfault.rb +56 -0
  411. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/mappingRegistryCreator.rb +92 -0
  412. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/methodDefCreator.rb +228 -0
  413. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/operation.rb +122 -0
  414. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/servantSkeltonCreator.rb +67 -0
  415. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/standaloneServerStubCreator.rb +85 -0
  416. data/vendor/javascripts/emscripted-ruby/lib/wsdl/soap/wsdl2ruby.rb +176 -0
  417. data/vendor/javascripts/emscripted-ruby/lib/wsdl/types.rb +43 -0
  418. data/vendor/javascripts/emscripted-ruby/lib/wsdl/wsdl.rb +23 -0
  419. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/all.rb +69 -0
  420. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/annotation.rb +34 -0
  421. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/any.rb +56 -0
  422. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/attribute.rb +127 -0
  423. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/choice.rb +69 -0
  424. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/complexContent.rb +92 -0
  425. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/complexType.rb +139 -0
  426. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/content.rb +96 -0
  427. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/data.rb +80 -0
  428. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/element.rb +154 -0
  429. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/enumeration.rb +36 -0
  430. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/import.rb +65 -0
  431. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/importer.rb +87 -0
  432. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/include.rb +54 -0
  433. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/length.rb +35 -0
  434. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/parser.rb +166 -0
  435. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/pattern.rb +36 -0
  436. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/schema.rb +143 -0
  437. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/sequence.rb +69 -0
  438. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/simpleContent.rb +65 -0
  439. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/simpleExtension.rb +54 -0
  440. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/simpleRestriction.rb +73 -0
  441. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/simpleType.rb +73 -0
  442. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/unique.rb +34 -0
  443. data/vendor/javascripts/emscripted-ruby/lib/wsdl/xmlSchema/xsd2ruby.rb +107 -0
  444. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/.document +1 -0
  445. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/README.txt +31 -0
  446. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/base64.rb +81 -0
  447. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/client.rb +624 -0
  448. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/config.rb +40 -0
  449. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/create.rb +290 -0
  450. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/datetime.rb +142 -0
  451. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/httpserver.rb +178 -0
  452. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/marshal.rb +76 -0
  453. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/parser.rb +813 -0
  454. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/server.rb +780 -0
  455. data/vendor/javascripts/emscripted-ruby/lib/xmlrpc/utils.rb +165 -0
  456. data/vendor/javascripts/emscripted-ruby/lib/xsd/charset.rb +187 -0
  457. data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen.rb +12 -0
  458. data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen/classdef.rb +203 -0
  459. data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen/commentdef.rb +34 -0
  460. data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen/gensupport.rb +166 -0
  461. data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen/methoddef.rb +63 -0
  462. data/vendor/javascripts/emscripted-ruby/lib/xsd/codegen/moduledef.rb +191 -0
  463. data/vendor/javascripts/emscripted-ruby/lib/xsd/datatypes.rb +1269 -0
  464. data/vendor/javascripts/emscripted-ruby/lib/xsd/datatypes1999.rb +20 -0
  465. data/vendor/javascripts/emscripted-ruby/lib/xsd/iconvcharset.rb +33 -0
  466. data/vendor/javascripts/emscripted-ruby/lib/xsd/mapping.rb +42 -0
  467. data/vendor/javascripts/emscripted-ruby/lib/xsd/namedelements.rb +95 -0
  468. data/vendor/javascripts/emscripted-ruby/lib/xsd/ns.rb +140 -0
  469. data/vendor/javascripts/emscripted-ruby/lib/xsd/qname.rb +78 -0
  470. data/vendor/javascripts/emscripted-ruby/lib/xsd/xmlparser.rb +61 -0
  471. data/vendor/javascripts/emscripted-ruby/lib/xsd/xmlparser/parser.rb +96 -0
  472. data/vendor/javascripts/emscripted-ruby/lib/xsd/xmlparser/rexmlparser.rb +54 -0
  473. data/vendor/javascripts/emscripted-ruby/lib/xsd/xmlparser/xmlparser.rb +50 -0
  474. data/vendor/javascripts/emscripted-ruby/lib/xsd/xmlparser/xmlscanner.rb +147 -0
  475. data/vendor/javascripts/emscripted-ruby/lib/yaml.rb +440 -0
  476. data/vendor/javascripts/emscripted-ruby/lib/yaml/baseemitter.rb +247 -0
  477. data/vendor/javascripts/emscripted-ruby/lib/yaml/basenode.rb +216 -0
  478. data/vendor/javascripts/emscripted-ruby/lib/yaml/constants.rb +45 -0
  479. data/vendor/javascripts/emscripted-ruby/lib/yaml/dbm.rb +111 -0
  480. data/vendor/javascripts/emscripted-ruby/lib/yaml/encoding.rb +33 -0
  481. data/vendor/javascripts/emscripted-ruby/lib/yaml/error.rb +34 -0
  482. data/vendor/javascripts/emscripted-ruby/lib/yaml/loader.rb +14 -0
  483. data/vendor/javascripts/emscripted-ruby/lib/yaml/rubytypes.rb +408 -0
  484. data/vendor/javascripts/emscripted-ruby/lib/yaml/store.rb +43 -0
  485. data/vendor/javascripts/emscripted-ruby/lib/yaml/stream.rb +40 -0
  486. data/vendor/javascripts/emscripted-ruby/lib/yaml/stringio.rb +83 -0
  487. data/vendor/javascripts/emscripted-ruby/lib/yaml/syck.rb +19 -0
  488. data/vendor/javascripts/emscripted-ruby/lib/yaml/tag.rb +91 -0
  489. data/vendor/javascripts/emscripted-ruby/lib/yaml/types.rb +192 -0
  490. data/vendor/javascripts/emscripted-ruby/lib/yaml/yamlnode.rb +54 -0
  491. data/vendor/javascripts/emscripted-ruby/lib/yaml/ypath.rb +52 -0
  492. data/vendor/javascripts/emscripted-ruby/ruby.closure.js +7201 -0
  493. metadata +554 -0
@@ -0,0 +1,62 @@
1
+ # The Mail class represents an internet mail message (as per RFC822, RFC2822)
2
+ # with headers and a body.
3
+ class Mail
4
+
5
+ # Create a new Mail where +f+ is either a stream which responds to gets(),
6
+ # or a path to a file. If +f+ is a path it will be opened.
7
+ #
8
+ # The whole message is read so it can be made available through the #header,
9
+ # #[] and #body methods.
10
+ #
11
+ # The "From " line is ignored if the mail is in mbox format.
12
+ def initialize(f)
13
+ unless defined? f.gets
14
+ f = open(f, "r")
15
+ opened = true
16
+ end
17
+
18
+ @header = {}
19
+ @body = []
20
+ begin
21
+ while line = f.gets()
22
+ line.chop!
23
+ next if /^From /=~line # skip From-line
24
+ break if /^$/=~line # end of header
25
+
26
+ if /^(\S+?):\s*(.*)/=~line
27
+ (attr = $1).capitalize!
28
+ @header[attr] = $2
29
+ elsif attr
30
+ line.sub!(/^\s*/, '')
31
+ @header[attr] += "\n" + line
32
+ end
33
+ end
34
+
35
+ return unless line
36
+
37
+ while line = f.gets()
38
+ break if /^From /=~line
39
+ @body.push(line)
40
+ end
41
+ ensure
42
+ f.close if opened
43
+ end
44
+ end
45
+
46
+ # Return the headers as a Hash.
47
+ def header
48
+ return @header
49
+ end
50
+
51
+ # Return the message body as an Array of lines
52
+ def body
53
+ return @body
54
+ end
55
+
56
+ # Return the header corresponding to +field+.
57
+ #
58
+ # Matching is case-insensitive.
59
+ def [](field)
60
+ @header[field.capitalize]
61
+ end
62
+ end
@@ -0,0 +1,308 @@
1
+ #
2
+ # mathn.rb -
3
+ # $Release Version: 0.5 $
4
+ # $Revision: 1.1.1.1.4.1 $
5
+ # $Date: 1998/01/16 12:36:05 $
6
+ # by Keiju ISHITSUKA(SHL Japan Inc.)
7
+ #
8
+ # --
9
+ #
10
+ #
11
+ #
12
+
13
+ require "complex.rb"
14
+ require "rational.rb"
15
+ require "matrix.rb"
16
+
17
+ class Integer
18
+
19
+ def gcd2(int)
20
+ a = self.abs
21
+ b = int.abs
22
+ a, b = b, a if a < b
23
+
24
+ pd_a = a.prime_division
25
+ pd_b = b.prime_division
26
+
27
+ gcd = 1
28
+ for pair in pd_a
29
+ as = pd_b.assoc(pair[0])
30
+ if as
31
+ gcd *= as[0] ** [as[1], pair[1]].min
32
+ end
33
+ end
34
+ return gcd
35
+ end
36
+
37
+ def Integer.from_prime_division(pd)
38
+ value = 1
39
+ for prime, index in pd
40
+ value *= prime**index
41
+ end
42
+ value
43
+ end
44
+
45
+ def prime_division
46
+ raise ZeroDivisionError if self == 0
47
+ ps = Prime.new
48
+ value = self
49
+ pv = []
50
+ for prime in ps
51
+ count = 0
52
+ while (value1, mod = value.divmod(prime)
53
+ mod) == 0
54
+ value = value1
55
+ count += 1
56
+ end
57
+ if count != 0
58
+ pv.push [prime, count]
59
+ end
60
+ break if prime * prime >= value
61
+ end
62
+ if value > 1
63
+ pv.push [value, 1]
64
+ end
65
+ return pv
66
+ end
67
+ end
68
+
69
+ class Prime
70
+ include Enumerable
71
+
72
+ def initialize
73
+ @seed = 1
74
+ @primes = []
75
+ @counts = []
76
+ end
77
+
78
+ def succ
79
+ i = -1
80
+ size = @primes.size
81
+ while i < size
82
+ if i == -1
83
+ @seed += 1
84
+ i += 1
85
+ else
86
+ while @seed > @counts[i]
87
+ @counts[i] += @primes[i]
88
+ end
89
+ if @seed != @counts[i]
90
+ i += 1
91
+ else
92
+ i = -1
93
+ end
94
+ end
95
+ end
96
+ @primes.push @seed
97
+ @counts.push @seed + @seed
98
+ return @seed
99
+ end
100
+ alias next succ
101
+
102
+ def each
103
+ loop do
104
+ yield succ
105
+ end
106
+ end
107
+ end
108
+
109
+ class Fixnum
110
+ alias / quo
111
+ end
112
+
113
+ class Bignum
114
+ alias / quo
115
+ end
116
+
117
+ class Rational
118
+ Unify = true
119
+
120
+ def inspect
121
+ format "%s/%s", numerator.inspect, denominator.inspect
122
+ end
123
+
124
+ alias power! **
125
+
126
+ def ** (other)
127
+ if other.kind_of?(Rational)
128
+ other2 = other
129
+ if self < 0
130
+ return Complex.new!(self, 0) ** other
131
+ elsif other == 0
132
+ return Rational(1,1)
133
+ elsif self == 0
134
+ return Rational(0,1)
135
+ elsif self == 1
136
+ return Rational(1,1)
137
+ end
138
+
139
+ npd = numerator.prime_division
140
+ dpd = denominator.prime_division
141
+ if other < 0
142
+ other = -other
143
+ npd, dpd = dpd, npd
144
+ end
145
+
146
+ for elm in npd
147
+ elm[1] = elm[1] * other
148
+ if !elm[1].kind_of?(Integer) and elm[1].denominator != 1
149
+ return Float(self) ** other2
150
+ end
151
+ elm[1] = elm[1].to_i
152
+ end
153
+
154
+ for elm in dpd
155
+ elm[1] = elm[1] * other
156
+ if !elm[1].kind_of?(Integer) and elm[1].denominator != 1
157
+ return Float(self) ** other2
158
+ end
159
+ elm[1] = elm[1].to_i
160
+ end
161
+
162
+ num = Integer.from_prime_division(npd)
163
+ den = Integer.from_prime_division(dpd)
164
+
165
+ Rational(num,den)
166
+
167
+ elsif other.kind_of?(Integer)
168
+ if other > 0
169
+ num = numerator ** other
170
+ den = denominator ** other
171
+ elsif other < 0
172
+ num = denominator ** -other
173
+ den = numerator ** -other
174
+ elsif other == 0
175
+ num = 1
176
+ den = 1
177
+ end
178
+ Rational.new!(num, den)
179
+ elsif other.kind_of?(Float)
180
+ Float(self) ** other
181
+ else
182
+ x , y = other.coerce(self)
183
+ x ** y
184
+ end
185
+ end
186
+
187
+ def power2(other)
188
+ if other.kind_of?(Rational)
189
+ if self < 0
190
+ return Complex(self, 0) ** other
191
+ elsif other == 0
192
+ return Rational(1,1)
193
+ elsif self == 0
194
+ return Rational(0,1)
195
+ elsif self == 1
196
+ return Rational(1,1)
197
+ end
198
+
199
+ dem = nil
200
+ x = self.denominator.to_f.to_i
201
+ neard = self.denominator.to_f ** (1.0/other.denominator.to_f)
202
+ loop do
203
+ if (neard**other.denominator == self.denominator)
204
+ dem = neaed
205
+ break
206
+ end
207
+ end
208
+ nearn = self.numerator.to_f ** (1.0/other.denominator.to_f)
209
+ Rational(num,den)
210
+
211
+ elsif other.kind_of?(Integer)
212
+ if other > 0
213
+ num = numerator ** other
214
+ den = denominator ** other
215
+ elsif other < 0
216
+ num = denominator ** -other
217
+ den = numerator ** -other
218
+ elsif other == 0
219
+ num = 1
220
+ den = 1
221
+ end
222
+ Rational.new!(num, den)
223
+ elsif other.kind_of?(Float)
224
+ Float(self) ** other
225
+ else
226
+ x , y = other.coerce(self)
227
+ x ** y
228
+ end
229
+ end
230
+ end
231
+
232
+ module Math
233
+ def sqrt(a)
234
+ if a.kind_of?(Complex)
235
+ abs = sqrt(a.real*a.real + a.image*a.image)
236
+ # if not abs.kind_of?(Rational)
237
+ # return a**Rational(1,2)
238
+ # end
239
+ x = sqrt((a.real + abs)/Rational(2))
240
+ y = sqrt((-a.real + abs)/Rational(2))
241
+ # if !(x.kind_of?(Rational) and y.kind_of?(Rational))
242
+ # return a**Rational(1,2)
243
+ # end
244
+ if a.image >= 0
245
+ Complex(x, y)
246
+ else
247
+ Complex(x, -y)
248
+ end
249
+ elsif a >= 0
250
+ rsqrt(a)
251
+ else
252
+ Complex(0,rsqrt(-a))
253
+ end
254
+ end
255
+
256
+ def rsqrt(a)
257
+ if a.kind_of?(Float)
258
+ sqrt!(a)
259
+ elsif a.kind_of?(Rational)
260
+ rsqrt(a.numerator)/rsqrt(a.denominator)
261
+ else
262
+ src = a
263
+ max = 2 ** 32
264
+ byte_a = [src & 0xffffffff]
265
+ # ruby's bug
266
+ while (src >= max) and (src >>= 32)
267
+ byte_a.unshift src & 0xffffffff
268
+ end
269
+
270
+ answer = 0
271
+ main = 0
272
+ side = 0
273
+ for elm in byte_a
274
+ main = (main << 32) + elm
275
+ side <<= 16
276
+ if answer != 0
277
+ if main * 4 < side * side
278
+ applo = main.div(side)
279
+ else
280
+ applo = ((sqrt!(side * side + 4 * main) - side)/2.0).to_i + 1
281
+ end
282
+ else
283
+ applo = sqrt!(main).to_i + 1
284
+ end
285
+
286
+ while (x = (side + applo) * applo) > main
287
+ applo -= 1
288
+ end
289
+ main -= x
290
+ answer = (answer << 16) + applo
291
+ side += applo * 2
292
+ end
293
+ if main == 0
294
+ answer
295
+ else
296
+ sqrt!(a)
297
+ end
298
+ end
299
+ end
300
+
301
+ module_function :sqrt
302
+ module_function :rsqrt
303
+ end
304
+
305
+ class Complex
306
+ Unify = true
307
+ end
308
+
@@ -0,0 +1,1278 @@
1
+ #!/usr/local/bin/ruby
2
+ #--
3
+ # matrix.rb -
4
+ # $Release Version: 1.0$
5
+ # $Revision: 1.11 $
6
+ # $Date: 1999/10/06 11:01:53 $
7
+ # Original Version from Smalltalk-80 version
8
+ # on July 23, 1985 at 8:37:17 am
9
+ # by Keiju ISHITSUKA
10
+ #++
11
+ #
12
+ # = matrix.rb
13
+ #
14
+ # An implementation of Matrix and Vector classes.
15
+ #
16
+ # Author:: Keiju ISHITSUKA
17
+ # Documentation:: Gavin Sinclair (sourced from <i>Ruby in a Nutshell</i> (Matsumoto, O'Reilly))
18
+ #
19
+ # See classes Matrix and Vector for documentation.
20
+ #
21
+
22
+
23
+ require "e2mmap.rb"
24
+
25
+ module ExceptionForMatrix # :nodoc:
26
+ extend Exception2MessageMapper
27
+ def_e2message(TypeError, "wrong argument type %s (expected %s)")
28
+ def_e2message(ArgumentError, "Wrong # of arguments(%d for %d)")
29
+
30
+ def_exception("ErrDimensionMismatch", "\#{self.name} dimension mismatch")
31
+ def_exception("ErrNotRegular", "Not Regular Matrix")
32
+ def_exception("ErrOperationNotDefined", "This operation(%s) can\\'t defined")
33
+ end
34
+
35
+ #
36
+ # The +Matrix+ class represents a mathematical matrix, and provides methods for creating
37
+ # special-case matrices (zero, identity, diagonal, singular, vector), operating on them
38
+ # arithmetically and algebraically, and determining their mathematical properties (trace, rank,
39
+ # inverse, determinant).
40
+ #
41
+ # Note that although matrices should theoretically be rectangular, this is not
42
+ # enforced by the class.
43
+ #
44
+ # Also note that the determinant of integer matrices may be incorrectly calculated unless you
45
+ # also <tt>require 'mathn'</tt>. This may be fixed in the future.
46
+ #
47
+ # == Method Catalogue
48
+ #
49
+ # To create a matrix:
50
+ # * <tt> Matrix[*rows] </tt>
51
+ # * <tt> Matrix.[](*rows) </tt>
52
+ # * <tt> Matrix.rows(rows, copy = true) </tt>
53
+ # * <tt> Matrix.columns(columns) </tt>
54
+ # * <tt> Matrix.diagonal(*values) </tt>
55
+ # * <tt> Matrix.scalar(n, value) </tt>
56
+ # * <tt> Matrix.scalar(n, value) </tt>
57
+ # * <tt> Matrix.identity(n) </tt>
58
+ # * <tt> Matrix.unit(n) </tt>
59
+ # * <tt> Matrix.I(n) </tt>
60
+ # * <tt> Matrix.zero(n) </tt>
61
+ # * <tt> Matrix.row_vector(row) </tt>
62
+ # * <tt> Matrix.column_vector(column) </tt>
63
+ #
64
+ # To access Matrix elements/columns/rows/submatrices/properties:
65
+ # * <tt> [](i, j) </tt>
66
+ # * <tt> #row_size </tt>
67
+ # * <tt> #column_size </tt>
68
+ # * <tt> #row(i) </tt>
69
+ # * <tt> #column(j) </tt>
70
+ # * <tt> #collect </tt>
71
+ # * <tt> #map </tt>
72
+ # * <tt> #minor(*param) </tt>
73
+ #
74
+ # Properties of a matrix:
75
+ # * <tt> #regular? </tt>
76
+ # * <tt> #singular? </tt>
77
+ # * <tt> #square? </tt>
78
+ #
79
+ # Matrix arithmetic:
80
+ # * <tt> *(m) </tt>
81
+ # * <tt> +(m) </tt>
82
+ # * <tt> -(m) </tt>
83
+ # * <tt> #/(m) </tt>
84
+ # * <tt> #inverse </tt>
85
+ # * <tt> #inv </tt>
86
+ # * <tt> ** </tt>
87
+ #
88
+ # Matrix functions:
89
+ # * <tt> #determinant </tt>
90
+ # * <tt> #det </tt>
91
+ # * <tt> #rank </tt>
92
+ # * <tt> #trace </tt>
93
+ # * <tt> #tr </tt>
94
+ # * <tt> #transpose </tt>
95
+ # * <tt> #t </tt>
96
+ #
97
+ # Conversion to other data types:
98
+ # * <tt> #coerce(other) </tt>
99
+ # * <tt> #row_vectors </tt>
100
+ # * <tt> #column_vectors </tt>
101
+ # * <tt> #to_a </tt>
102
+ #
103
+ # String representations:
104
+ # * <tt> #to_s </tt>
105
+ # * <tt> #inspect </tt>
106
+ #
107
+ class Matrix
108
+ @RCS_ID='-$Id: matrix.rb,v 1.11 1999/10/06 11:01:53 keiju Exp keiju $-'
109
+
110
+ # extend Exception2MessageMapper
111
+ include ExceptionForMatrix
112
+
113
+ # instance creations
114
+ private_class_method :new
115
+
116
+ #
117
+ # Creates a matrix where each argument is a row.
118
+ # Matrix[ [25, 93], [-1, 66] ]
119
+ # => 25 93
120
+ # -1 66
121
+ #
122
+ def Matrix.[](*rows)
123
+ new(:init_rows, rows, false)
124
+ end
125
+
126
+ #
127
+ # Creates a matrix where +rows+ is an array of arrays, each of which is a row
128
+ # to the matrix. If the optional argument +copy+ is false, use the given
129
+ # arrays as the internal structure of the matrix without copying.
130
+ # Matrix.rows([[25, 93], [-1, 66]])
131
+ # => 25 93
132
+ # -1 66
133
+ def Matrix.rows(rows, copy = true)
134
+ new(:init_rows, rows, copy)
135
+ end
136
+
137
+ #
138
+ # Creates a matrix using +columns+ as an array of column vectors.
139
+ # Matrix.columns([[25, 93], [-1, 66]])
140
+ # => 25 -1
141
+ # 93 66
142
+ #
143
+ #
144
+ def Matrix.columns(columns)
145
+ rows = (0 .. columns[0].size - 1).collect {
146
+ |i|
147
+ (0 .. columns.size - 1).collect {
148
+ |j|
149
+ columns[j][i]
150
+ }
151
+ }
152
+ Matrix.rows(rows, false)
153
+ end
154
+
155
+ #
156
+ # Creates a matrix where the diagonal elements are composed of +values+.
157
+ # Matrix.diagonal(9, 5, -3)
158
+ # => 9 0 0
159
+ # 0 5 0
160
+ # 0 0 -3
161
+ #
162
+ def Matrix.diagonal(*values)
163
+ size = values.size
164
+ rows = (0 .. size - 1).collect {
165
+ |j|
166
+ row = Array.new(size).fill(0, 0, size)
167
+ row[j] = values[j]
168
+ row
169
+ }
170
+ rows(rows, false)
171
+ end
172
+
173
+ #
174
+ # Creates an +n+ by +n+ diagonal matrix where each diagonal element is
175
+ # +value+.
176
+ # Matrix.scalar(2, 5)
177
+ # => 5 0
178
+ # 0 5
179
+ #
180
+ def Matrix.scalar(n, value)
181
+ Matrix.diagonal(*Array.new(n).fill(value, 0, n))
182
+ end
183
+
184
+ #
185
+ # Creates an +n+ by +n+ identity matrix.
186
+ # Matrix.identity(2)
187
+ # => 1 0
188
+ # 0 1
189
+ #
190
+ def Matrix.identity(n)
191
+ Matrix.scalar(n, 1)
192
+ end
193
+ class << Matrix
194
+ alias unit identity
195
+ alias I identity
196
+ end
197
+
198
+ #
199
+ # Creates an +n+ by +n+ zero matrix.
200
+ # Matrix.zero(2)
201
+ # => 0 0
202
+ # 0 0
203
+ #
204
+ def Matrix.zero(n)
205
+ Matrix.scalar(n, 0)
206
+ end
207
+
208
+ #
209
+ # Creates a single-row matrix where the values of that row are as given in
210
+ # +row+.
211
+ # Matrix.row_vector([4,5,6])
212
+ # => 4 5 6
213
+ #
214
+ def Matrix.row_vector(row)
215
+ case row
216
+ when Vector
217
+ Matrix.rows([row.to_a], false)
218
+ when Array
219
+ Matrix.rows([row.dup], false)
220
+ else
221
+ Matrix.rows([[row]], false)
222
+ end
223
+ end
224
+
225
+ #
226
+ # Creates a single-column matrix where the values of that column are as given
227
+ # in +column+.
228
+ # Matrix.column_vector([4,5,6])
229
+ # => 4
230
+ # 5
231
+ # 6
232
+ #
233
+ def Matrix.column_vector(column)
234
+ case column
235
+ when Vector
236
+ Matrix.columns([column.to_a])
237
+ when Array
238
+ Matrix.columns([column])
239
+ else
240
+ Matrix.columns([[column]])
241
+ end
242
+ end
243
+
244
+ #
245
+ # This method is used by the other methods that create matrices, and is of no
246
+ # use to general users.
247
+ #
248
+ def initialize(init_method, *argv)
249
+ self.send(init_method, *argv)
250
+ end
251
+
252
+ def init_rows(rows, copy)
253
+ if copy
254
+ @rows = rows.collect{|row| row.dup}
255
+ else
256
+ @rows = rows
257
+ end
258
+ self
259
+ end
260
+ private :init_rows
261
+
262
+ #
263
+ # Returns element (+i+,+j+) of the matrix. That is: row +i+, column +j+.
264
+ #
265
+ def [](i, j)
266
+ @rows[i][j]
267
+ end
268
+
269
+ #
270
+ # Returns the number of rows.
271
+ #
272
+ def row_size
273
+ @rows.size
274
+ end
275
+
276
+ #
277
+ # Returns the number of columns. Note that it is possible to construct a
278
+ # matrix with uneven columns (e.g. Matrix[ [1,2,3], [4,5] ]), but this is
279
+ # mathematically unsound. This method uses the first row to determine the
280
+ # result.
281
+ #
282
+ def column_size
283
+ @rows[0].size
284
+ end
285
+
286
+ #
287
+ # Returns row vector number +i+ of the matrix as a Vector (starting at 0 like
288
+ # an array). When a block is given, the elements of that vector are iterated.
289
+ #
290
+ def row(i) # :yield: e
291
+ if block_given?
292
+ for e in @rows[i]
293
+ yield e
294
+ end
295
+ else
296
+ Vector.elements(@rows[i])
297
+ end
298
+ end
299
+
300
+ #
301
+ # Returns column vector number +j+ of the matrix as a Vector (starting at 0
302
+ # like an array). When a block is given, the elements of that vector are
303
+ # iterated.
304
+ #
305
+ def column(j) # :yield: e
306
+ if block_given?
307
+ 0.upto(row_size - 1) do
308
+ |i|
309
+ yield @rows[i][j]
310
+ end
311
+ else
312
+ col = (0 .. row_size - 1).collect {
313
+ |i|
314
+ @rows[i][j]
315
+ }
316
+ Vector.elements(col, false)
317
+ end
318
+ end
319
+
320
+ #
321
+ # Returns a matrix that is the result of iteration of the given block over all
322
+ # elements of the matrix.
323
+ # Matrix[ [1,2], [3,4] ].collect { |i| i**2 }
324
+ # => 1 4
325
+ # 9 16
326
+ #
327
+ def collect # :yield: e
328
+ rows = @rows.collect{|row| row.collect{|e| yield e}}
329
+ Matrix.rows(rows, false)
330
+ end
331
+ alias map collect
332
+
333
+ #
334
+ # Returns a section of the matrix. The parameters are either:
335
+ # * start_row, nrows, start_col, ncols; OR
336
+ # * col_range, row_range
337
+ #
338
+ # Matrix.diagonal(9, 5, -3).minor(0..1, 0..2)
339
+ # => 9 0 0
340
+ # 0 5 0
341
+ #
342
+ def minor(*param)
343
+ case param.size
344
+ when 2
345
+ from_row = param[0].first
346
+ size_row = param[0].end - from_row
347
+ size_row += 1 unless param[0].exclude_end?
348
+ from_col = param[1].first
349
+ size_col = param[1].end - from_col
350
+ size_col += 1 unless param[1].exclude_end?
351
+ when 4
352
+ from_row = param[0]
353
+ size_row = param[1]
354
+ from_col = param[2]
355
+ size_col = param[3]
356
+ else
357
+ Matrix.Raise ArgumentError, param.inspect
358
+ end
359
+
360
+ rows = @rows[from_row, size_row].collect{
361
+ |row|
362
+ row[from_col, size_col]
363
+ }
364
+ Matrix.rows(rows, false)
365
+ end
366
+
367
+ #--
368
+ # TESTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
369
+ #++
370
+
371
+ #
372
+ # Returns +true+ if this is a regular matrix.
373
+ #
374
+ def regular?
375
+ square? and rank == column_size
376
+ end
377
+
378
+ #
379
+ # Returns +true+ is this is a singular (i.e. non-regular) matrix.
380
+ #
381
+ def singular?
382
+ not regular?
383
+ end
384
+
385
+ #
386
+ # Returns +true+ is this is a square matrix. See note in column_size about this
387
+ # being unreliable, though.
388
+ #
389
+ def square?
390
+ column_size == row_size
391
+ end
392
+
393
+ #--
394
+ # OBJECT METHODS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
395
+ #++
396
+
397
+ #
398
+ # Returns +true+ if and only if the two matrices contain equal elements.
399
+ #
400
+ def ==(other)
401
+ return false unless Matrix === other
402
+
403
+ other.compare_by_row_vectors(@rows)
404
+ end
405
+ alias eql? ==
406
+
407
+ #
408
+ # Not really intended for general consumption.
409
+ #
410
+ def compare_by_row_vectors(rows)
411
+ return false unless @rows.size == rows.size
412
+
413
+ 0.upto(@rows.size - 1) do
414
+ |i|
415
+ return false unless @rows[i] == rows[i]
416
+ end
417
+ true
418
+ end
419
+
420
+ #
421
+ # Returns a clone of the matrix, so that the contents of each do not reference
422
+ # identical objects.
423
+ #
424
+ def clone
425
+ Matrix.rows(@rows)
426
+ end
427
+
428
+ #
429
+ # Returns a hash-code for the matrix.
430
+ #
431
+ def hash
432
+ value = 0
433
+ for row in @rows
434
+ for e in row
435
+ value ^= e.hash
436
+ end
437
+ end
438
+ return value
439
+ end
440
+
441
+ #--
442
+ # ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
443
+ #++
444
+
445
+ #
446
+ # Matrix multiplication.
447
+ # Matrix[[2,4], [6,8]] * Matrix.identity(2)
448
+ # => 2 4
449
+ # 6 8
450
+ #
451
+ def *(m) # m is matrix or vector or number
452
+ case(m)
453
+ when Numeric
454
+ rows = @rows.collect {
455
+ |row|
456
+ row.collect {
457
+ |e|
458
+ e * m
459
+ }
460
+ }
461
+ return Matrix.rows(rows, false)
462
+ when Vector
463
+ m = Matrix.column_vector(m)
464
+ r = self * m
465
+ return r.column(0)
466
+ when Matrix
467
+ Matrix.Raise ErrDimensionMismatch if column_size != m.row_size
468
+
469
+ rows = (0 .. row_size - 1).collect {
470
+ |i|
471
+ (0 .. m.column_size - 1).collect {
472
+ |j|
473
+ vij = 0
474
+ 0.upto(column_size - 1) do
475
+ |k|
476
+ vij += self[i, k] * m[k, j]
477
+ end
478
+ vij
479
+ }
480
+ }
481
+ return Matrix.rows(rows, false)
482
+ else
483
+ x, y = m.coerce(self)
484
+ return x * y
485
+ end
486
+ end
487
+
488
+ #
489
+ # Matrix addition.
490
+ # Matrix.scalar(2,5) + Matrix[[1,0], [-4,7]]
491
+ # => 6 0
492
+ # -4 12
493
+ #
494
+ def +(m)
495
+ case m
496
+ when Numeric
497
+ Matrix.Raise ErrOperationNotDefined, "+"
498
+ when Vector
499
+ m = Matrix.column_vector(m)
500
+ when Matrix
501
+ else
502
+ x, y = m.coerce(self)
503
+ return x + y
504
+ end
505
+
506
+ Matrix.Raise ErrDimensionMismatch unless row_size == m.row_size and column_size == m.column_size
507
+
508
+ rows = (0 .. row_size - 1).collect {
509
+ |i|
510
+ (0 .. column_size - 1).collect {
511
+ |j|
512
+ self[i, j] + m[i, j]
513
+ }
514
+ }
515
+ Matrix.rows(rows, false)
516
+ end
517
+
518
+ #
519
+ # Matrix subtraction.
520
+ # Matrix[[1,5], [4,2]] - Matrix[[9,3], [-4,1]]
521
+ # => -8 2
522
+ # 8 1
523
+ #
524
+ def -(m)
525
+ case m
526
+ when Numeric
527
+ Matrix.Raise ErrOperationNotDefined, "-"
528
+ when Vector
529
+ m = Matrix.column_vector(m)
530
+ when Matrix
531
+ else
532
+ x, y = m.coerce(self)
533
+ return x - y
534
+ end
535
+
536
+ Matrix.Raise ErrDimensionMismatch unless row_size == m.row_size and column_size == m.column_size
537
+
538
+ rows = (0 .. row_size - 1).collect {
539
+ |i|
540
+ (0 .. column_size - 1).collect {
541
+ |j|
542
+ self[i, j] - m[i, j]
543
+ }
544
+ }
545
+ Matrix.rows(rows, false)
546
+ end
547
+
548
+ #
549
+ # Matrix division (multiplication by the inverse).
550
+ # Matrix[[7,6], [3,9]] / Matrix[[2,9], [3,1]]
551
+ # => -7 1
552
+ # -3 -6
553
+ #
554
+ def /(other)
555
+ case other
556
+ when Numeric
557
+ rows = @rows.collect {
558
+ |row|
559
+ row.collect {
560
+ |e|
561
+ e / other
562
+ }
563
+ }
564
+ return Matrix.rows(rows, false)
565
+ when Matrix
566
+ return self * other.inverse
567
+ else
568
+ x, y = other.coerce(self)
569
+ rerurn x / y
570
+ end
571
+ end
572
+
573
+ #
574
+ # Returns the inverse of the matrix.
575
+ # Matrix[[1, 2], [2, 1]].inverse
576
+ # => -1 1
577
+ # 0 -1
578
+ #
579
+ def inverse
580
+ Matrix.Raise ErrDimensionMismatch unless square?
581
+ Matrix.I(row_size).inverse_from(self)
582
+ end
583
+ alias inv inverse
584
+
585
+ #
586
+ # Not for public consumption?
587
+ #
588
+ def inverse_from(src)
589
+ size = row_size - 1
590
+ a = src.to_a
591
+
592
+ for k in 0..size
593
+ i = k
594
+ akk = a[k][k].abs
595
+ for j in (k+1)..size
596
+ v = a[j][k].abs
597
+ if v > akk
598
+ i = j
599
+ akk = v
600
+ end
601
+ end
602
+ Matrix.Raise ErrNotRegular if akk == 0
603
+ if i != k
604
+ a[i], a[k] = a[k], a[i]
605
+ @rows[i], @rows[k] = @rows[k], @rows[i]
606
+ end
607
+ akk = a[k][k]
608
+
609
+ for i in 0 .. size
610
+ next if i == k
611
+ q = a[i][k] / akk
612
+ a[i][k] = 0
613
+
614
+ (k + 1).upto(size) do
615
+ |j|
616
+ a[i][j] -= a[k][j] * q
617
+ end
618
+ 0.upto(size) do
619
+ |j|
620
+ @rows[i][j] -= @rows[k][j] * q
621
+ end
622
+ end
623
+
624
+ (k + 1).upto(size) do
625
+ |j|
626
+ a[k][j] /= akk
627
+ end
628
+ 0.upto(size) do
629
+ |j|
630
+ @rows[k][j] /= akk
631
+ end
632
+ end
633
+ self
634
+ end
635
+ #alias reciprocal inverse
636
+
637
+ #
638
+ # Matrix exponentiation. Defined for integer powers only. Equivalent to
639
+ # multiplying the matrix by itself N times.
640
+ # Matrix[[7,6], [3,9]] ** 2
641
+ # => 67 96
642
+ # 48 99
643
+ #
644
+ def ** (other)
645
+ if other.kind_of?(Integer)
646
+ x = self
647
+ if other <= 0
648
+ x = self.inverse
649
+ return Matrix.identity(self.column_size) if other == 0
650
+ other = -other
651
+ end
652
+ z = x
653
+ n = other - 1
654
+ while n != 0
655
+ while (div, mod = n.divmod(2)
656
+ mod == 0)
657
+ x = x * x
658
+ n = div
659
+ end
660
+ z *= x
661
+ n -= 1
662
+ end
663
+ z
664
+ elsif other.kind_of?(Float) || defined?(Rational) && other.kind_of?(Rational)
665
+ Matrix.Raise ErrOperationNotDefined, "**"
666
+ else
667
+ Matrix.Raise ErrOperationNotDefined, "**"
668
+ end
669
+ end
670
+
671
+ #--
672
+ # MATRIX FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
673
+ #++
674
+
675
+ #
676
+ # Returns the determinant of the matrix. If the matrix is not square, the
677
+ # result is 0.
678
+ # Matrix[[7,6], [3,9]].determinant
679
+ # => 63
680
+ #
681
+ def determinant
682
+ return 0 unless square?
683
+
684
+ size = row_size - 1
685
+ a = to_a
686
+
687
+ det = 1
688
+ k = 0
689
+ begin
690
+ if (akk = a[k][k]) == 0
691
+ i = k
692
+ begin
693
+ return 0 if (i += 1) > size
694
+ end while a[i][k] == 0
695
+ a[i], a[k] = a[k], a[i]
696
+ akk = a[k][k]
697
+ det *= -1
698
+ end
699
+ (k + 1).upto(size) do
700
+ |i|
701
+ q = a[i][k] / akk
702
+ (k + 1).upto(size) do
703
+ |j|
704
+ a[i][j] -= a[k][j] * q
705
+ end
706
+ end
707
+ det *= akk
708
+ end while (k += 1) <= size
709
+ det
710
+ end
711
+ alias det determinant
712
+
713
+ #
714
+ # Returns the rank of the matrix. Beware that using Float values, with their
715
+ # usual lack of precision, can affect the value returned by this method. Use
716
+ # Rational values instead if this is important to you.
717
+ # Matrix[[7,6], [3,9]].rank
718
+ # => 2
719
+ #
720
+ def rank
721
+ if column_size > row_size
722
+ a = transpose.to_a
723
+ a_column_size = row_size
724
+ a_row_size = column_size
725
+ else
726
+ a = to_a
727
+ a_column_size = column_size
728
+ a_row_size = row_size
729
+ end
730
+ rank = 0
731
+ k = 0
732
+ begin
733
+ if (akk = a[k][k]) == 0
734
+ i = k
735
+ exists = true
736
+ begin
737
+ if (i += 1) > a_column_size - 1
738
+ exists = false
739
+ break
740
+ end
741
+ end while a[i][k] == 0
742
+ if exists
743
+ a[i], a[k] = a[k], a[i]
744
+ akk = a[k][k]
745
+ else
746
+ i = k
747
+ exists = true
748
+ begin
749
+ if (i += 1) > a_row_size - 1
750
+ exists = false
751
+ break
752
+ end
753
+ end while a[k][i] == 0
754
+ if exists
755
+ k.upto(a_column_size - 1) do
756
+ |j|
757
+ a[j][k], a[j][i] = a[j][i], a[j][k]
758
+ end
759
+ akk = a[k][k]
760
+ else
761
+ next
762
+ end
763
+ end
764
+ end
765
+ (k + 1).upto(a_row_size - 1) do
766
+ |i|
767
+ q = a[i][k] / akk
768
+ (k + 1).upto(a_column_size - 1) do
769
+ |j|
770
+ a[i][j] -= a[k][j] * q
771
+ end
772
+ end
773
+ rank += 1
774
+ end while (k += 1) <= a_column_size - 1
775
+ return rank
776
+ end
777
+
778
+ #
779
+ # Returns the trace (sum of diagonal elements) of the matrix.
780
+ # Matrix[[7,6], [3,9]].trace
781
+ # => 16
782
+ #
783
+ def trace
784
+ tr = 0
785
+ 0.upto(column_size - 1) do
786
+ |i|
787
+ tr += @rows[i][i]
788
+ end
789
+ tr
790
+ end
791
+ alias tr trace
792
+
793
+ #
794
+ # Returns the transpose of the matrix.
795
+ # Matrix[[1,2], [3,4], [5,6]]
796
+ # => 1 2
797
+ # 3 4
798
+ # 5 6
799
+ # Matrix[[1,2], [3,4], [5,6]].transpose
800
+ # => 1 3 5
801
+ # 2 4 6
802
+ #
803
+ def transpose
804
+ Matrix.columns(@rows)
805
+ end
806
+ alias t transpose
807
+
808
+ #--
809
+ # CONVERTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
810
+ #++
811
+
812
+ #
813
+ # FIXME: describe #coerce.
814
+ #
815
+ def coerce(other)
816
+ case other
817
+ when Numeric
818
+ return Scalar.new(other), self
819
+ else
820
+ raise TypeError, "#{self.class} can't be coerced into #{other.class}"
821
+ end
822
+ end
823
+
824
+ #
825
+ # Returns an array of the row vectors of the matrix. See Vector.
826
+ #
827
+ def row_vectors
828
+ rows = (0 .. row_size - 1).collect {
829
+ |i|
830
+ row(i)
831
+ }
832
+ rows
833
+ end
834
+
835
+ #
836
+ # Returns an array of the column vectors of the matrix. See Vector.
837
+ #
838
+ def column_vectors
839
+ columns = (0 .. column_size - 1).collect {
840
+ |i|
841
+ column(i)
842
+ }
843
+ columns
844
+ end
845
+
846
+ #
847
+ # Returns an array of arrays that describe the rows of the matrix.
848
+ #
849
+ def to_a
850
+ @rows.collect{|row| row.collect{|e| e}}
851
+ end
852
+
853
+ #--
854
+ # PRINTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
855
+ #++
856
+
857
+ #
858
+ # Overrides Object#to_s
859
+ #
860
+ def to_s
861
+ "Matrix[" + @rows.collect{
862
+ |row|
863
+ "[" + row.collect{|e| e.to_s}.join(", ") + "]"
864
+ }.join(", ")+"]"
865
+ end
866
+
867
+ #
868
+ # Overrides Object#inspect
869
+ #
870
+ def inspect
871
+ "Matrix"+@rows.inspect
872
+ end
873
+
874
+ # Private CLASS
875
+
876
+ class Scalar < Numeric # :nodoc:
877
+ include ExceptionForMatrix
878
+
879
+ def initialize(value)
880
+ @value = value
881
+ end
882
+
883
+ # ARITHMETIC
884
+ def +(other)
885
+ case other
886
+ when Numeric
887
+ Scalar.new(@value + other)
888
+ when Vector, Matrix
889
+ Scalar.Raise WrongArgType, other.class, "Numeric or Scalar"
890
+ when Scalar
891
+ Scalar.new(@value + other.value)
892
+ else
893
+ x, y = other.coerce(self)
894
+ x + y
895
+ end
896
+ end
897
+
898
+ def -(other)
899
+ case other
900
+ when Numeric
901
+ Scalar.new(@value - other)
902
+ when Vector, Matrix
903
+ Scalar.Raise WrongArgType, other.class, "Numeric or Scalar"
904
+ when Scalar
905
+ Scalar.new(@value - other.value)
906
+ else
907
+ x, y = other.coerce(self)
908
+ x - y
909
+ end
910
+ end
911
+
912
+ def *(other)
913
+ case other
914
+ when Numeric
915
+ Scalar.new(@value * other)
916
+ when Vector, Matrix
917
+ other.collect{|e| @value * e}
918
+ else
919
+ x, y = other.coerce(self)
920
+ x * y
921
+ end
922
+ end
923
+
924
+ def / (other)
925
+ case other
926
+ when Numeric
927
+ Scalar.new(@value / other)
928
+ when Vector
929
+ Scalar.Raise WrongArgType, other.class, "Numeric or Scalar or Matrix"
930
+ when Matrix
931
+ self * _M.inverse
932
+ else
933
+ x, y = other.coerce(self)
934
+ x / y
935
+ end
936
+ end
937
+
938
+ def ** (other)
939
+ case other
940
+ when Numeric
941
+ Scalar.new(@value ** other)
942
+ when Vector
943
+ Scalar.Raise WrongArgType, other.class, "Numeric or Scalar or Matrix"
944
+ when Matrix
945
+ other.powered_by(self)
946
+ else
947
+ x, y = other.coerce(self)
948
+ x ** y
949
+ end
950
+ end
951
+ end
952
+ end
953
+
954
+
955
+ #
956
+ # The +Vector+ class represents a mathematical vector, which is useful in its own right, and
957
+ # also constitutes a row or column of a Matrix.
958
+ #
959
+ # == Method Catalogue
960
+ #
961
+ # To create a Vector:
962
+ # * <tt> Vector.[](*array) </tt>
963
+ # * <tt> Vector.elements(array, copy = true) </tt>
964
+ #
965
+ # To access elements:
966
+ # * <tt> [](i) </tt>
967
+ #
968
+ # To enumerate the elements:
969
+ # * <tt> #each2(v) </tt>
970
+ # * <tt> #collect2(v) </tt>
971
+ #
972
+ # Vector arithmetic:
973
+ # * <tt> *(x) "is matrix or number" </tt>
974
+ # * <tt> +(v) </tt>
975
+ # * <tt> -(v) </tt>
976
+ #
977
+ # Vector functions:
978
+ # * <tt> #inner_product(v) </tt>
979
+ # * <tt> #collect </tt>
980
+ # * <tt> #map </tt>
981
+ # * <tt> #map2(v) </tt>
982
+ # * <tt> #r </tt>
983
+ # * <tt> #size </tt>
984
+ #
985
+ # Conversion to other data types:
986
+ # * <tt> #covector </tt>
987
+ # * <tt> #to_a </tt>
988
+ # * <tt> #coerce(other) </tt>
989
+ #
990
+ # String representations:
991
+ # * <tt> #to_s </tt>
992
+ # * <tt> #inspect </tt>
993
+ #
994
+ class Vector
995
+ include ExceptionForMatrix
996
+
997
+ #INSTANCE CREATION
998
+
999
+ private_class_method :new
1000
+
1001
+ #
1002
+ # Creates a Vector from a list of elements.
1003
+ # Vector[7, 4, ...]
1004
+ #
1005
+ def Vector.[](*array)
1006
+ new(:init_elements, array, copy = false)
1007
+ end
1008
+
1009
+ #
1010
+ # Creates a vector from an Array. The optional second argument specifies
1011
+ # whether the array itself or a copy is used internally.
1012
+ #
1013
+ def Vector.elements(array, copy = true)
1014
+ new(:init_elements, array, copy)
1015
+ end
1016
+
1017
+ #
1018
+ # For internal use.
1019
+ #
1020
+ def initialize(method, array, copy)
1021
+ self.send(method, array, copy)
1022
+ end
1023
+
1024
+ #
1025
+ # For internal use.
1026
+ #
1027
+ def init_elements(array, copy)
1028
+ if copy
1029
+ @elements = array.dup
1030
+ else
1031
+ @elements = array
1032
+ end
1033
+ end
1034
+
1035
+ # ACCESSING
1036
+
1037
+ #
1038
+ # Returns element number +i+ (starting at zero) of the vector.
1039
+ #
1040
+ def [](i)
1041
+ @elements[i]
1042
+ end
1043
+
1044
+ #
1045
+ # Returns the number of elements in the vector.
1046
+ #
1047
+ def size
1048
+ @elements.size
1049
+ end
1050
+
1051
+ #--
1052
+ # ENUMERATIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1053
+ #++
1054
+
1055
+ #
1056
+ # Iterate over the elements of this vector and +v+ in conjunction.
1057
+ #
1058
+ def each2(v) # :yield: e1, e2
1059
+ Vector.Raise ErrDimensionMismatch if size != v.size
1060
+ 0.upto(size - 1) do
1061
+ |i|
1062
+ yield @elements[i], v[i]
1063
+ end
1064
+ end
1065
+
1066
+ #
1067
+ # Collects (as in Enumerable#collect) over the elements of this vector and +v+
1068
+ # in conjunction.
1069
+ #
1070
+ def collect2(v) # :yield: e1, e2
1071
+ Vector.Raise ErrDimensionMismatch if size != v.size
1072
+ (0 .. size - 1).collect do
1073
+ |i|
1074
+ yield @elements[i], v[i]
1075
+ end
1076
+ end
1077
+
1078
+ #--
1079
+ # COMPARING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1080
+ #++
1081
+
1082
+ #
1083
+ # Returns +true+ iff the two vectors have the same elements in the same order.
1084
+ #
1085
+ def ==(other)
1086
+ return false unless Vector === other
1087
+
1088
+ other.compare_by(@elements)
1089
+ end
1090
+ alias eqn? ==
1091
+
1092
+ #
1093
+ # For internal use.
1094
+ #
1095
+ def compare_by(elements)
1096
+ @elements == elements
1097
+ end
1098
+
1099
+ #
1100
+ # Return a copy of the vector.
1101
+ #
1102
+ def clone
1103
+ Vector.elements(@elements)
1104
+ end
1105
+
1106
+ #
1107
+ # Return a hash-code for the vector.
1108
+ #
1109
+ def hash
1110
+ @elements.hash
1111
+ end
1112
+
1113
+ #--
1114
+ # ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1115
+ #++
1116
+
1117
+ #
1118
+ # Multiplies the vector by +x+, where +x+ is a number or another vector.
1119
+ #
1120
+ def *(x)
1121
+ case x
1122
+ when Numeric
1123
+ els = @elements.collect{|e| e * x}
1124
+ Vector.elements(els, false)
1125
+ when Matrix
1126
+ Matrix.column_vector(self) * x
1127
+ else
1128
+ s, x = x.coerce(self)
1129
+ s * x
1130
+ end
1131
+ end
1132
+
1133
+ #
1134
+ # Vector addition.
1135
+ #
1136
+ def +(v)
1137
+ case v
1138
+ when Vector
1139
+ Vector.Raise ErrDimensionMismatch if size != v.size
1140
+ els = collect2(v) {
1141
+ |v1, v2|
1142
+ v1 + v2
1143
+ }
1144
+ Vector.elements(els, false)
1145
+ when Matrix
1146
+ Matrix.column_vector(self) + v
1147
+ else
1148
+ s, x = v.coerce(self)
1149
+ s + x
1150
+ end
1151
+ end
1152
+
1153
+ #
1154
+ # Vector subtraction.
1155
+ #
1156
+ def -(v)
1157
+ case v
1158
+ when Vector
1159
+ Vector.Raise ErrDimensionMismatch if size != v.size
1160
+ els = collect2(v) {
1161
+ |v1, v2|
1162
+ v1 - v2
1163
+ }
1164
+ Vector.elements(els, false)
1165
+ when Matrix
1166
+ Matrix.column_vector(self) - v
1167
+ else
1168
+ s, x = v.coerce(self)
1169
+ s - x
1170
+ end
1171
+ end
1172
+
1173
+ #--
1174
+ # VECTOR FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1175
+ #++
1176
+
1177
+ #
1178
+ # Returns the inner product of this vector with the other.
1179
+ # Vector[4,7].inner_product Vector[10,1] => 47
1180
+ #
1181
+ def inner_product(v)
1182
+ Vector.Raise ErrDimensionMismatch if size != v.size
1183
+
1184
+ p = 0
1185
+ each2(v) {
1186
+ |v1, v2|
1187
+ p += v1 * v2
1188
+ }
1189
+ p
1190
+ end
1191
+
1192
+ #
1193
+ # Like Array#collect.
1194
+ #
1195
+ def collect # :yield: e
1196
+ els = @elements.collect {
1197
+ |v|
1198
+ yield v
1199
+ }
1200
+ Vector.elements(els, false)
1201
+ end
1202
+ alias map collect
1203
+
1204
+ #
1205
+ # Like Vector#collect2, but returns a Vector instead of an Array.
1206
+ #
1207
+ def map2(v) # :yield: e1, e2
1208
+ els = collect2(v) {
1209
+ |v1, v2|
1210
+ yield v1, v2
1211
+ }
1212
+ Vector.elements(els, false)
1213
+ end
1214
+
1215
+ #
1216
+ # Returns the modulus (Pythagorean distance) of the vector.
1217
+ # Vector[5,8,2].r => 9.643650761
1218
+ #
1219
+ def r
1220
+ v = 0
1221
+ for e in @elements
1222
+ v += e*e
1223
+ end
1224
+ return Math.sqrt(v)
1225
+ end
1226
+
1227
+ #--
1228
+ # CONVERTING
1229
+ #++
1230
+
1231
+ #
1232
+ # Creates a single-row matrix from this vector.
1233
+ #
1234
+ def covector
1235
+ Matrix.row_vector(self)
1236
+ end
1237
+
1238
+ #
1239
+ # Returns the elements of the vector in an array.
1240
+ #
1241
+ def to_a
1242
+ @elements.dup
1243
+ end
1244
+
1245
+ #
1246
+ # FIXME: describe Vector#coerce.
1247
+ #
1248
+ def coerce(other)
1249
+ case other
1250
+ when Numeric
1251
+ return Scalar.new(other), self
1252
+ else
1253
+ raise TypeError, "#{self.class} can't be coerced into #{other.class}"
1254
+ end
1255
+ end
1256
+
1257
+ #--
1258
+ # PRINTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
1259
+ #++
1260
+
1261
+ #
1262
+ # Overrides Object#to_s
1263
+ #
1264
+ def to_s
1265
+ "Vector[" + @elements.join(", ") + "]"
1266
+ end
1267
+
1268
+ #
1269
+ # Overrides Object#inspect
1270
+ #
1271
+ def inspect
1272
+ str = "Vector"+@elements.inspect
1273
+ end
1274
+ end
1275
+
1276
+
1277
+ # Documentation comments:
1278
+ # - Matrix#coerce and Vector#coerce need to be documented