Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 70296de3ef6c47352c9e307f0460d9ab099fee89 Sébastien Loisel committed Sep 18, 2011
Showing with 15,667 additions and 0 deletions.
  1. BIN favicon.ico
  2. +110 −0 index.html
  3. +10 −0 resources/license.txt
  4. BIN resources/paperplane-small.png
  5. BIN resources/paperplane.png
  6. BIN resources/wait16.gif
  7. BIN resources/wait24.gif
  8. BIN resources/workshop.png
  9. +9 −0 src/.externalToolBuilders/Call builder.sh.launch
  10. +27 −0 src/.project
  11. +177 −0 src/arithmetic.js
  12. +97 −0 src/eig.js
  13. +361 −0 src/linalg.js
  14. +251 −0 src/logic.js
  15. +420 −0 src/math.js
  16. +142 −0 src/moretests.js
  17. +287 −0 src/printing.js
  18. +104 −0 src/quadprog.js
  19. +272 −0 src/seedrandom.js
  20. +62 −0 src/sets.js
  21. +102 −0 src/simplex.js
  22. +1,053 −0 src/tensors.js
  23. +14 −0 tools/Crypto-JS v2.4.0/aes/aes-min.js
  24. +407 −0 tools/Crypto-JS v2.4.0/aes/aes.js
  25. +12 −0 tools/Crypto-JS v2.4.0/blockmodes/blockmodes-min.js
  26. +381 −0 tools/Crypto-JS v2.4.0/blockmodes/blockmodes.js
  27. +18 −0 tools/Crypto-JS v2.4.0/crypto-md5-hmac/crypto-md5-hmac.js
  28. +17 −0 tools/Crypto-JS v2.4.0/crypto-md5/crypto-md5.js
  29. +29 −0 ...Crypto-JS v2.4.0/crypto-sha1-hmac-pbkdf2-blockmodes-aes/crypto-sha1-hmac-pbkdf2-blockmodes-aes.js
  30. +17 −0 tools/Crypto-JS v2.4.0/crypto-sha1-hmac-pbkdf2-marc4/crypto-sha1-hmac-pbkdf2-marc4.js
  31. +20 −0 tools/Crypto-JS v2.4.0/crypto-sha1-hmac-pbkdf2-rabbit/crypto-sha1-hmac-pbkdf2-rabbit.js
  32. +15 −0 tools/Crypto-JS v2.4.0/crypto-sha1-hmac-pbkdf2/crypto-sha1-hmac-pbkdf2.js
  33. +15 −0 tools/Crypto-JS v2.4.0/crypto-sha1-hmac-pbkdf2async/crypto-sha1-hmac-pbkdf2async.js
  34. +13 −0 tools/Crypto-JS v2.4.0/crypto-sha1-hmac/crypto-sha1-hmac.js
  35. +12 −0 tools/Crypto-JS v2.4.0/crypto-sha1/crypto-sha1.js
  36. +15 −0 tools/Crypto-JS v2.4.0/crypto-sha256-hmac/crypto-sha256-hmac.js
  37. +14 −0 tools/Crypto-JS v2.4.0/crypto-sha256/crypto-sha256.js
  38. +10 −0 tools/Crypto-JS v2.4.0/crypto/crypto-min.js
  39. +160 −0 tools/Crypto-JS v2.4.0/crypto/crypto.js
  40. +7 −0 tools/Crypto-JS v2.4.0/hmac/hmac-min.js
  41. +43 −0 tools/Crypto-JS v2.4.0/hmac/hmac.js
  42. +8 −0 tools/Crypto-JS v2.4.0/marc4/marc4-min.js
  43. +122 −0 tools/Crypto-JS v2.4.0/marc4/marc4.js
  44. +13 −0 tools/Crypto-JS v2.4.0/md5/md5-min.js
  45. +163 −0 tools/Crypto-JS v2.4.0/md5/md5.js
  46. +8 −0 tools/Crypto-JS v2.4.0/pbkdf2/pbkdf2-min.js
  47. +54 −0 tools/Crypto-JS v2.4.0/pbkdf2/pbkdf2.js
  48. +8 −0 tools/Crypto-JS v2.4.0/pbkdf2async/pbkdf2async-min.js
  49. +93 −0 tools/Crypto-JS v2.4.0/pbkdf2async/pbkdf2async.js
  50. +11 −0 tools/Crypto-JS v2.4.0/rabbit/rabbit-min.js
  51. +226 −0 tools/Crypto-JS v2.4.0/rabbit/rabbit.js
  52. +8 −0 tools/Crypto-JS v2.4.0/sha1/sha1-min.js
  53. +91 −0 tools/Crypto-JS v2.4.0/sha1/sha1.js
  54. +10 −0 tools/Crypto-JS v2.4.0/sha256/sha256-min.js
  55. +135 −0 tools/Crypto-JS v2.4.0/sha256/sha256.js
  56. +10 −0 tools/build.sh
  57. +10 −0 tools/checkfile.js
  58. +183 −0 tools/jsdoc-toolkit/README.txt
  59. +33 −0 tools/jsdoc-toolkit/app/frame.js
  60. +102 −0 tools/jsdoc-toolkit/app/frame/Chain.js
  61. +144 −0 tools/jsdoc-toolkit/app/frame/Dumper.js
  62. +84 −0 tools/jsdoc-toolkit/app/frame/Hash.js
  63. +173 −0 tools/jsdoc-toolkit/app/frame/Link.js
  64. +10 −0 tools/jsdoc-toolkit/app/frame/Namespace.js
  65. +134 −0 tools/jsdoc-toolkit/app/frame/Opt.js
  66. +26 −0 tools/jsdoc-toolkit/app/frame/Reflection.js
  67. +93 −0 tools/jsdoc-toolkit/app/frame/String.js
  68. +129 −0 tools/jsdoc-toolkit/app/frame/Testrun.js
  69. +26 −0 tools/jsdoc-toolkit/app/handlers/FOODOC.js
  70. +26 −0 tools/jsdoc-toolkit/app/handlers/XMLDOC.js
  71. +159 −0 tools/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js
  72. +16 −0 tools/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js
  73. +292 −0 tools/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js
  74. +106 −0 tools/jsdoc-toolkit/app/lib/JSDOC.js
  75. +204 −0 tools/jsdoc-toolkit/app/lib/JSDOC/DocComment.js
  76. +294 −0 tools/jsdoc-toolkit/app/lib/JSDOC/DocTag.js
  77. +140 −0 tools/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js
  78. +109 −0 tools/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js
  79. +144 −0 tools/jsdoc-toolkit/app/lib/JSDOC/Lang.js
  80. +146 −0 tools/jsdoc-toolkit/app/lib/JSDOC/Parser.js
  81. +33 −0 tools/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js
  82. +644 −0 tools/jsdoc-toolkit/app/lib/JSDOC/Symbol.js
  83. +243 −0 tools/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js
  84. +41 −0 tools/jsdoc-toolkit/app/lib/JSDOC/TextStream.js
  85. +18 −0 tools/jsdoc-toolkit/app/lib/JSDOC/Token.js
  86. +332 −0 tools/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js
  87. +133 −0 tools/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js
  88. +32 −0 tools/jsdoc-toolkit/app/lib/JSDOC/Util.js
  89. +507 −0 tools/jsdoc-toolkit/app/lib/JSDOC/Walker.js
  90. +111 −0 tools/jsdoc-toolkit/app/main.js
  91. +20 −0 tools/jsdoc-toolkit/app/plugins/commentSrcJson.js
  92. +16 −0 tools/jsdoc-toolkit/app/plugins/frameworkPrototype.js
  93. +10 −0 tools/jsdoc-toolkit/app/plugins/functionCall.js
  94. +62 −0 tools/jsdoc-toolkit/app/plugins/publishSrcHilite.js
  95. +10 −0 tools/jsdoc-toolkit/app/plugins/symbolLink.js
  96. +31 −0 tools/jsdoc-toolkit/app/plugins/tagParamConfig.js
  97. +43 −0 tools/jsdoc-toolkit/app/plugins/tagSynonyms.js
  98. +348 −0 tools/jsdoc-toolkit/app/run.js
  99. +144 −0 tools/jsdoc-toolkit/app/t/TestDoc.js
  100. +13 −0 tools/jsdoc-toolkit/app/t/runner.js
  101. +342 −0 tools/jsdoc-toolkit/app/test.js
  102. +24 −0 tools/jsdoc-toolkit/app/test/addon.js
  103. +14 −0 tools/jsdoc-toolkit/app/test/anon_inner.js
  104. +31 −0 tools/jsdoc-toolkit/app/test/augments.js
  105. +26 −0 tools/jsdoc-toolkit/app/test/augments2.js
  106. +46 −0 tools/jsdoc-toolkit/app/test/borrows.js
  107. +23 −0 tools/jsdoc-toolkit/app/test/borrows2.js
  108. +22 −0 tools/jsdoc-toolkit/app/test/config.js
  109. +18 −0 tools/jsdoc-toolkit/app/test/constructs.js
  110. +10 −0 tools/jsdoc-toolkit/app/test/encoding.js
  111. +12 −0 tools/jsdoc-toolkit/app/test/encoding_other.js
  112. +54 −0 tools/jsdoc-toolkit/app/test/event.js
  113. +14 −0 tools/jsdoc-toolkit/app/test/exports.js
  114. +39 −0 tools/jsdoc-toolkit/app/test/functions_anon.js
  115. +33 −0 tools/jsdoc-toolkit/app/test/functions_nested.js
  116. +13 −0 tools/jsdoc-toolkit/app/test/global.js
  117. +25 −0 tools/jsdoc-toolkit/app/test/globals.js
  118. +10 −0 tools/jsdoc-toolkit/app/test/ignore.js
  119. +16 −0 tools/jsdoc-toolkit/app/test/inner.js
  120. +477 −0 tools/jsdoc-toolkit/app/test/jsdoc_test.js
  121. +33 −0 tools/jsdoc-toolkit/app/test/lend.js
  122. +19 −0 tools/jsdoc-toolkit/app/test/memberof.js
  123. +38 −0 tools/jsdoc-toolkit/app/test/memberof2.js
  124. +33 −0 tools/jsdoc-toolkit/app/test/memberof3.js
  125. +17 −0 tools/jsdoc-toolkit/app/test/memberof_constructor.js
  126. +17 −0 tools/jsdoc-toolkit/app/test/module.js
  127. +25 −0 tools/jsdoc-toolkit/app/test/multi_methods.js
  128. +19 −0 tools/jsdoc-toolkit/app/test/name.js
  129. +23 −0 tools/jsdoc-toolkit/app/test/namespace_nested.js
  130. +13 −0 tools/jsdoc-toolkit/app/test/nocode.js
  131. +20 −0 tools/jsdoc-toolkit/app/test/oblit_anon.js
  132. +20 −0 tools/jsdoc-toolkit/app/test/overview.js
  133. +37 −0 tools/jsdoc-toolkit/app/test/param_inline.js
  134. +8 −0 tools/jsdoc-toolkit/app/test/params_optional.js
  135. +17 −0 tools/jsdoc-toolkit/app/test/prototype.js
  136. +9 −0 tools/jsdoc-toolkit/app/test/prototype_nested.js
  137. +13 −0 tools/jsdoc-toolkit/app/test/prototype_oblit.js
  138. +24 −0 tools/jsdoc-toolkit/app/test/prototype_oblit_constructor.js
  139. +10 −0 tools/jsdoc-toolkit/app/test/public.js
  140. +5 −0 tools/jsdoc-toolkit/app/test/scripts/code.js
  141. +5 −0 tools/jsdoc-toolkit/app/test/scripts/notcode.txt
  142. +42 −0 tools/jsdoc-toolkit/app/test/shared.js
  143. +2 −0 tools/jsdoc-toolkit/app/test/shared2.js
  144. +22 −0 tools/jsdoc-toolkit/app/test/shortcuts.js
  145. +13 −0 tools/jsdoc-toolkit/app/test/static_this.js
  146. +31 −0 tools/jsdoc-toolkit/app/test/synonyms.js
  147. +23 −0 tools/jsdoc-toolkit/app/test/tosource.js
  148. +14 −0 tools/jsdoc-toolkit/app/test/variable_redefine.js
  149. +124 −0 tools/jsdoc-toolkit/changes.txt
  150. +31 −0 tools/jsdoc-toolkit/conf/sample.conf
  151. +36 −0 tools/jsdoc-toolkit/java/build.xml
  152. +36 −0 tools/jsdoc-toolkit/java/build_1.4.xml
  153. BIN tools/jsdoc-toolkit/java/classes/js.jar
  154. +21 −0 tools/jsdoc-toolkit/java/src/JsDebugRun.java
  155. +21 −0 tools/jsdoc-toolkit/java/src/JsRun.java
  156. BIN tools/jsdoc-toolkit/jsdebug.jar
  157. BIN tools/jsdoc-toolkit/jsrun.jar
  158. +52 −0 tools/jsdoc-toolkit/jsrun.sh
  159. +17 −0 tools/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl
  160. +56 −0 tools/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl
  161. +649 −0 tools/jsdoc-toolkit/templates/jsdoc/class.tmpl
  162. +39 −0 tools/jsdoc-toolkit/templates/jsdoc/index.tmpl
  163. +201 −0 tools/jsdoc-toolkit/templates/jsdoc/publish.js
  164. +163 −0 tools/jsdoc-toolkit/templates/jsdoc/static/default.css
  165. +162 −0 tools/jsdoc-toolkit/templates/jsdoc/static/default.css~
  166. +2 −0 tools/jsdoc-toolkit/templates/jsdoc/static/header.html
  167. +19 −0 tools/jsdoc-toolkit/templates/jsdoc/static/index.html
  168. +35 −0 tools/jsdoc-toolkit/templates/jsdoc/symbol.tmpl
  169. +12 −0 tools/mkdoc.sh
  170. +4 −0 tools/mkzip.sh
  171. +2 −0 tools/numeric_footer.js
  172. +338 −0 tools/numeric_header.js
  173. +35 −0 tools/unit2.js
  174. +520 −0 workshop.html
  175. +54 −0 workshop.php
Binary file not shown.
@@ -0,0 +1,110 @@
+<html>
+<head>
+<link rel="SHORTCUT ICON" href="favicon.ico">
+<title>Numeric Javascript</title>
+<style>
+body {
+ font-family: sans-serif;
+ font-size: 14px;
+ margin-top: 10px;
+ margin-left: 50px;
+ margin-right: 50px;
+ margin-bottom: 50px;
+}
+
+td.big {
+ font-size: 36px;
+ font-weight: bold;
+}
+td.beta {
+ color: #b0b0b0;
+}
+
+a.tryit { font-size:24px; font-weight: bold; }
+a:link { color: #0000ff; }
+a:visited { color: #0000ff; }
+a:active { color: #0000ff; }
+a:hover { color: #ff0000; }
+
+h1 {
+ font-size: 24px;
+}
+
+table.float {
+ width: 405px;
+ float: right;
+ border-width: 5px;
+ border-style: solid;
+ border-color: #b0b0b0;
+ margin-left:10px;
+}
+
+td { font-size: 14px; }
+
+td.float {
+ padding:10px;
+ font-weight: bold;
+}
+</style>
+
+<body>
+<table>
+ <tr>
+ <td><img src="resources/paperplane-small.png"></td>
+ <td><table><tr>
+ <td class="big">Numeric Javascript.</td>
+ <td class="beta">(Beta)</td></tr>
+ <table><tr>
+ <td><a href="workshop.php?link=6b035104673d7847a8dd74b8d3b1a6dbe0034a50731fd2202208a27681d6811b" class="tryit">Try it now!</a>
+ <td width=75 align="center">or</td>
+ <td><a href="numeric-1.0.zip" class="tryit">Download Source Code (zip)</a>.</td>
+ </tr></table></td>
+ </tr>
+</table>
+
+<h1>What?</h1>
+
+<table class="float"><tr><td class="float">
+<a href="workshop.php?link=6b035104673d7847a8dd74b8d3b1a6dbe0034a50731fd2202208a27681d6811b"><img src="resources/workshop.png" alt="Numeric Javascript Workshop" width="400px"></a><br><br>
+Try <a href="workshop.php?link=6b035104673d7847a8dd74b8d3b1a6dbe0034a50731fd2202208a27681d6811b">Numeric Javascript Workshop</a> right from your browser!
+</td></tr></table>
+
+<a href="http://www.ma.hw.ac.uk/~loisel/numeric/">Numeric Javascript</a>
+is a library for numerical computations in Javascript. You can write Javascript
+programs that manipulate matrices, solve linear problems, find eigenvalues and
+solve optimization problems in the browser. You can also use
+Numeric Javascript outside the browser with <a href="http://nodejs.org/">Node.js</a>
+and similar server-side technologies.<br><br>
+
+In addition to the <tt>numeric.js</tt> Javascript library, you can use
+the <a hef="workshop.php?link=6b035104673d7847a8dd74b8d3b1a6dbe0034a50731fd2202208a27681d6811b">Numeric Javascript Workshop</a> (pictured right),
+to interact with a Javascript prompt that is preloaded with
+the Numeric Javascript library.
+
+<h1>Why?</h1>
+
+Computers are very powerful devices but your audience often doesn't have
+the software tools you use, such as Fortran compilers or a MATLAB license.
+For small and medium scientific programming tasks, you can use
+<a href="http://www.ma.hw.ac.uk/~loisel/numeric/">Numeric Javascript</a>
+to write numerical programs that will run in any modern browser <b>without installing any
+special software.</b>
+You can reach a much broader audience and communicate your ideas more clearly
+by using Numeric Javascript.<br><br>
+
+<h1>How?</h1>
+
+<a href="http://www.ma.hw.ac.uk/~loisel/numeric/">Numeric Javascript</a> is
+a Javascript library. It is loaded into each visitor's browser when
+they visit a page that uses Numeric Javascript. This means that their own
+browser is able to solve many scientific problems without ever having to
+contact the server. As a result, your server can serve essentially static
+pages -- all the computing power is in your visitors's browsers and computers.
+
+<h1>Who?</h1>
+
+Numeric Javascript is written by
+<a href="http://www.ma.hw.ac.uk/~loisel/">S&eacute;bastien Loisel</a>
+for use by anyone who needs to do numerical computations in Javascript.
+
+
@@ -0,0 +1,10 @@
+The spinning wait icons by Andrew B. Davidson were taken from
+
+http://www.andrewdavidson.com/articles/spinning-wait-icons/
+
+The icons are copyrighted. As far as license goes, this is my understanding
+from the above web site:
+
+"These icons are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License."
+
+Link to license: http://creativecommons.org/licenses/by-nc-sa/2.5/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
+<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="/Users/sebastienloisel/Dropbox/javascript/numeric/log/build.log"/>
+<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="true"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="/Users/sebastienloisel/Dropbox/javascript/numeric/tools/build.sh"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
+<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
+<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="/Users/sebastienloisel/Dropbox/javascript/numeric/tools"/>
+</launchConfiguration>
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>numeric</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
+ <triggers>auto,full,incremental,</triggers>
+ <arguments>
+ <dictionary>
+ <key>LaunchConfigHandle</key>
+ <value>&lt;project&gt;/.externalToolBuilders/Call builder.sh.launch</value>
+ </dictionary>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,177 @@
+/**
+ * Adds tensors
+ *
+ * @example
+> numeric.add(1,2)
+t(3)
+> numeric.add(1,[2,3])
+t([3,4])
+> numeric.add([1,2],3)
+t([4,5])
+> numeric.add([1,2],[3,4])
+t([4,6])
+> numeric.add(numeric.t(1,2),numeric.t(3,4))
+t(4,6)
+> numeric.add(1,numeric.t(2,3))
+t(3,3)
+> numeric.add(numeric.t(2,3),1)
+t(3,3)
+> numeric.add(numeric.t([1,2],[3,4]),numeric.t([5,6],[7,8]))
+t([6,8],
+ [10,12])
+> numeric.add(1,2,3,4,5,6,7,8,9)
+t(45)
+ */
+function add() {
+ function adder(x,y) { var i; for(i=0;i<x.length;i++) { x[i] += y(i); } }
+ var ret = copy(t(arguments[0])),foo;
+ var i,j,foo,bar;
+ for(i=1;i<arguments.length;i++) {
+ foo = t(arguments[i]);
+ if(ret.s.length === 0 && foo.s.length >0) {
+ bar = ret;
+ ret = copy(foo);
+ foo = bar;
+ }
+ adder(ret.x,mkf(foo.x));
+ if(typeof ret.y === "undefined") {
+ if(typeof foo.y !== "undefined") {
+ ret.y = foo.y.slice(0);
+ }
+ } else {
+ if(typeof foo.y !== "undefined") {
+ adder(ret.y,mkf(foo.y));
+ }
+ }
+ }
+ return ret;
+}
+expo(add);
+
+/**
+ * Subtracts tensors.
+ *
+ * @example
+> numeric.sub(1,2)
+t(-1)
+> numeric.sub(1,[2,3])
+t([-1,-2])
+> numeric.sub(numeric.t(1,2),([3,4]))
+t([-2,-3],[2,2])
+> numeric.sub([1,2],numeric.t(3,4))
+t([-2,-1],[-4,-4])
+> numeric.sub(numeric.t([1,2],[3,4]),numeric.t([5,6],[7,8]))
+t([-4,-4],[-4,-4])
+ */
+function sub() {
+ function subber(x,y) { var i; for(i=0;i<x.length;i++) { x[i] -= y(i); } }
+ var ret = copy(t(arguments[0])),foo;
+ var i,j,foo,bar;
+ for(i=1;i<arguments.length;i++) {
+ foo = t(arguments[i]);
+ if(ret.s.length === 0 && foo.s.length >0) {
+ if(typeof ret.y === "undefined") {
+ ret = mkT(foo.s,mka(foo.x.length,ret.x[0]));
+ } else {
+ ret = mkT(foo.s,mka(foo.x.length,ret.x[0]),
+ mka(foo.x.length,ret.y[0]));
+ }
+ }
+ subber(ret.x,mkf(foo.x));
+ if(typeof foo.y !== "undefined") {
+ if(typeof ret.y === "undefined") {
+ ret.y = mka(ret.x.length,0);
+ }
+ subber(ret.y,mkf(foo.y));
+ }
+ }
+ return ret;
+}
+expo(sub);
+
+/**
+ * Multiplies tensors pointwise.
+ *
+ * For matrix products, etc... see dot() and tensor().
+ *
+ * @example
+> numeric.mul(1,2)
+t(2)
+> numeric.mul([1,2],[3,4])
+t([3,8])
+> numeric.mul(numeric.t(1,2),numeric.t(3,4))
+t(-5,10)
+> numeric.mul(numeric.t([1,2],[3,4]),numeric.t([5,6],[7,8]))
+t([-16,-20],[22,40])
+ */
+function mul() {
+ function muler(x,y) { var i; for(i=0;i<x.length;i++) { x[i] *= y(i); } }
+ var ret = copy(t(arguments[0])),foo;
+ var i,j,foo,bar,x1,y1,x2,y2,z1,z2;
+ for(i=1;i<arguments.length;i++) {
+ foo = t(arguments[i]);
+ if(typeof ret.y !== "undefined" || typeof foo.y !== "undefined") {
+ x1 = real(ret);
+ y1 = imag(ret);
+ x2 = real(foo);
+ y2 = imag(foo);
+ z1 = sub(mul(x1,x2),mul(y1,y2));
+ z2 = add(mul(x1,y2),mul(y1,x2));
+ ret = mkT(z1.s,z1.x,z2.x);
+ } else {
+ if(ret.s.length === 0 && foo.s.length > 0) {
+ bar = ret;
+ ret = copy(foo);
+ foo = bar;
+ }
+ muler(ret.x,mkf(foo.x));
+ }
+ }
+ return ret;
+}
+expo(mul);
+
+/**
+ * Pointwise division of tensor.
+ *
+ * @example
+> numeric.div(1,2)
+t(0.5)
+> numeric.div([1,2],4)
+t([0.25,0.5])
+> numeric.div(4,[1,2])
+t([4,2])
+> numeric.div([1,2],[4,8])
+t([0.25,0.25])
+> numeric.div(numeric.t(1,2),numeric.t(3,4))
+t(0.44,0.08)
+> numeric.div(1,numeric.t(3,4))
+t(0.12,-0.16)
+> numeric.div(numeric.t(3,4),5)
+t(0.6,0.8)
+ */
+function div() {
+function diver(x,y) { var i; for(i=0;i<x.length;i++) { x[i] /= y(i); } }
+var ret = copy(t(arguments[0])),foo;
+var i,j,foo,bar,x1,y1,x2,y2,z1,z2,r;
+for(i=1;i<arguments.length;i++) {
+ foo = t(arguments[i]);
+ if(typeof ret.y !== "undefined" || typeof foo.y !== "undefined") {
+ x1 = real(ret);
+ y1 = imag(ret);
+ x2 = real(foo);
+ y2 = imag(foo);
+ r = add(mul(x2,x2),mul(y2,y2));
+ z1 = div(add(mul(x1,x2),mul(y1,y2)),r);
+ z2 = div(sub(mul(y1,x2),mul(x1,y2)),r);
+ ret = mkT(z1.s,z1.x,z2.x);
+ } else {
+ if(ret.s.length === 0 && foo.s.length > 0) {
+ ret = mkT(foo.s,mka(foo.x.length,ret.x[0]));
+ }
+ diver(ret.x,mkf(foo.x));
+ }
+}
+return ret;
+}
+expo(div);
Oops, something went wrong.

0 comments on commit 70296de

Please sign in to comment.