Skip to content

Commit 70296de

Browse files
author
Sébastien Loisel
committed
Initial commit
0 parents  commit 70296de

File tree

175 files changed

+15667
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+15667
-0
lines changed

favicon.ico

4.19 KB
Binary file not shown.

index.html

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<html>
2+
<head>
3+
<link rel="SHORTCUT ICON" href="favicon.ico">
4+
<title>Numeric Javascript</title>
5+
<style>
6+
body {
7+
font-family: sans-serif;
8+
font-size: 14px;
9+
margin-top: 10px;
10+
margin-left: 50px;
11+
margin-right: 50px;
12+
margin-bottom: 50px;
13+
}
14+
15+
td.big {
16+
font-size: 36px;
17+
font-weight: bold;
18+
}
19+
td.beta {
20+
color: #b0b0b0;
21+
}
22+
23+
a.tryit { font-size:24px; font-weight: bold; }
24+
a:link { color: #0000ff; }
25+
a:visited { color: #0000ff; }
26+
a:active { color: #0000ff; }
27+
a:hover { color: #ff0000; }
28+
29+
h1 {
30+
font-size: 24px;
31+
}
32+
33+
table.float {
34+
width: 405px;
35+
float: right;
36+
border-width: 5px;
37+
border-style: solid;
38+
border-color: #b0b0b0;
39+
margin-left:10px;
40+
}
41+
42+
td { font-size: 14px; }
43+
44+
td.float {
45+
padding:10px;
46+
font-weight: bold;
47+
}
48+
</style>
49+
50+
<body>
51+
<table>
52+
<tr>
53+
<td><img src="resources/paperplane-small.png"></td>
54+
<td><table><tr>
55+
<td class="big">Numeric Javascript.</td>
56+
<td class="beta">(Beta)</td></tr>
57+
<table><tr>
58+
<td><a href="workshop.php?link=6b035104673d7847a8dd74b8d3b1a6dbe0034a50731fd2202208a27681d6811b" class="tryit">Try it now!</a>
59+
<td width=75 align="center">or</td>
60+
<td><a href="numeric-1.0.zip" class="tryit">Download Source Code (zip)</a>.</td>
61+
</tr></table></td>
62+
</tr>
63+
</table>
64+
65+
<h1>What?</h1>
66+
67+
<table class="float"><tr><td class="float">
68+
<a href="workshop.php?link=6b035104673d7847a8dd74b8d3b1a6dbe0034a50731fd2202208a27681d6811b"><img src="resources/workshop.png" alt="Numeric Javascript Workshop" width="400px"></a><br><br>
69+
Try <a href="workshop.php?link=6b035104673d7847a8dd74b8d3b1a6dbe0034a50731fd2202208a27681d6811b">Numeric Javascript Workshop</a> right from your browser!
70+
</td></tr></table>
71+
72+
<a href="http://www.ma.hw.ac.uk/~loisel/numeric/">Numeric Javascript</a>
73+
is a library for numerical computations in Javascript. You can write Javascript
74+
programs that manipulate matrices, solve linear problems, find eigenvalues and
75+
solve optimization problems in the browser. You can also use
76+
Numeric Javascript outside the browser with <a href="http://nodejs.org/">Node.js</a>
77+
and similar server-side technologies.<br><br>
78+
79+
In addition to the <tt>numeric.js</tt> Javascript library, you can use
80+
the <a hef="workshop.php?link=6b035104673d7847a8dd74b8d3b1a6dbe0034a50731fd2202208a27681d6811b">Numeric Javascript Workshop</a> (pictured right),
81+
to interact with a Javascript prompt that is preloaded with
82+
the Numeric Javascript library.
83+
84+
<h1>Why?</h1>
85+
86+
Computers are very powerful devices but your audience often doesn't have
87+
the software tools you use, such as Fortran compilers or a MATLAB license.
88+
For small and medium scientific programming tasks, you can use
89+
<a href="http://www.ma.hw.ac.uk/~loisel/numeric/">Numeric Javascript</a>
90+
to write numerical programs that will run in any modern browser <b>without installing any
91+
special software.</b>
92+
You can reach a much broader audience and communicate your ideas more clearly
93+
by using Numeric Javascript.<br><br>
94+
95+
<h1>How?</h1>
96+
97+
<a href="http://www.ma.hw.ac.uk/~loisel/numeric/">Numeric Javascript</a> is
98+
a Javascript library. It is loaded into each visitor's browser when
99+
they visit a page that uses Numeric Javascript. This means that their own
100+
browser is able to solve many scientific problems without ever having to
101+
contact the server. As a result, your server can serve essentially static
102+
pages -- all the computing power is in your visitors's browsers and computers.
103+
104+
<h1>Who?</h1>
105+
106+
Numeric Javascript is written by
107+
<a href="http://www.ma.hw.ac.uk/~loisel/">S&eacute;bastien Loisel</a>
108+
for use by anyone who needs to do numerical computations in Javascript.
109+
110+

resources/license.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The spinning wait icons by Andrew B. Davidson were taken from
2+
3+
http://www.andrewdavidson.com/articles/spinning-wait-icons/
4+
5+
The icons are copyrighted. As far as license goes, this is my understanding
6+
from the above web site:
7+
8+
"These icons are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License."
9+
10+
Link to license: http://creativecommons.org/licenses/by-nc-sa/2.5/

resources/paperplane-small.png

14.1 KB
Loading

resources/paperplane.png

32.5 KB
Loading

resources/wait16.gif

3.02 KB
Loading

resources/wait24.gif

4.68 KB
Loading

resources/workshop.png

42.9 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
3+
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="/Users/sebastienloisel/Dropbox/javascript/numeric/log/build.log"/>
4+
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="true"/>
5+
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="/Users/sebastienloisel/Dropbox/javascript/numeric/tools/build.sh"/>
6+
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,"/>
7+
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
8+
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="/Users/sebastienloisel/Dropbox/javascript/numeric/tools"/>
9+
</launchConfiguration>

src/.project

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>numeric</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
15+
<triggers>auto,full,incremental,</triggers>
16+
<arguments>
17+
<dictionary>
18+
<key>LaunchConfigHandle</key>
19+
<value>&lt;project&gt;/.externalToolBuilders/Call builder.sh.launch</value>
20+
</dictionary>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
26+
</natures>
27+
</projectDescription>

src/arithmetic.js

+177
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
/**
2+
* Adds tensors
3+
*
4+
* @example
5+
> numeric.add(1,2)
6+
t(3)
7+
> numeric.add(1,[2,3])
8+
t([3,4])
9+
> numeric.add([1,2],3)
10+
t([4,5])
11+
> numeric.add([1,2],[3,4])
12+
t([4,6])
13+
> numeric.add(numeric.t(1,2),numeric.t(3,4))
14+
t(4,6)
15+
> numeric.add(1,numeric.t(2,3))
16+
t(3,3)
17+
> numeric.add(numeric.t(2,3),1)
18+
t(3,3)
19+
> numeric.add(numeric.t([1,2],[3,4]),numeric.t([5,6],[7,8]))
20+
t([6,8],
21+
[10,12])
22+
> numeric.add(1,2,3,4,5,6,7,8,9)
23+
t(45)
24+
*/
25+
function add() {
26+
function adder(x,y) { var i; for(i=0;i<x.length;i++) { x[i] += y(i); } }
27+
var ret = copy(t(arguments[0])),foo;
28+
var i,j,foo,bar;
29+
for(i=1;i<arguments.length;i++) {
30+
foo = t(arguments[i]);
31+
if(ret.s.length === 0 && foo.s.length >0) {
32+
bar = ret;
33+
ret = copy(foo);
34+
foo = bar;
35+
}
36+
adder(ret.x,mkf(foo.x));
37+
if(typeof ret.y === "undefined") {
38+
if(typeof foo.y !== "undefined") {
39+
ret.y = foo.y.slice(0);
40+
}
41+
} else {
42+
if(typeof foo.y !== "undefined") {
43+
adder(ret.y,mkf(foo.y));
44+
}
45+
}
46+
}
47+
return ret;
48+
}
49+
expo(add);
50+
51+
/**
52+
* Subtracts tensors.
53+
*
54+
* @example
55+
> numeric.sub(1,2)
56+
t(-1)
57+
> numeric.sub(1,[2,3])
58+
t([-1,-2])
59+
> numeric.sub(numeric.t(1,2),([3,4]))
60+
t([-2,-3],[2,2])
61+
> numeric.sub([1,2],numeric.t(3,4))
62+
t([-2,-1],[-4,-4])
63+
> numeric.sub(numeric.t([1,2],[3,4]),numeric.t([5,6],[7,8]))
64+
t([-4,-4],[-4,-4])
65+
*/
66+
function sub() {
67+
function subber(x,y) { var i; for(i=0;i<x.length;i++) { x[i] -= y(i); } }
68+
var ret = copy(t(arguments[0])),foo;
69+
var i,j,foo,bar;
70+
for(i=1;i<arguments.length;i++) {
71+
foo = t(arguments[i]);
72+
if(ret.s.length === 0 && foo.s.length >0) {
73+
if(typeof ret.y === "undefined") {
74+
ret = mkT(foo.s,mka(foo.x.length,ret.x[0]));
75+
} else {
76+
ret = mkT(foo.s,mka(foo.x.length,ret.x[0]),
77+
mka(foo.x.length,ret.y[0]));
78+
}
79+
}
80+
subber(ret.x,mkf(foo.x));
81+
if(typeof foo.y !== "undefined") {
82+
if(typeof ret.y === "undefined") {
83+
ret.y = mka(ret.x.length,0);
84+
}
85+
subber(ret.y,mkf(foo.y));
86+
}
87+
}
88+
return ret;
89+
}
90+
expo(sub);
91+
92+
/**
93+
* Multiplies tensors pointwise.
94+
*
95+
* For matrix products, etc... see dot() and tensor().
96+
*
97+
* @example
98+
> numeric.mul(1,2)
99+
t(2)
100+
> numeric.mul([1,2],[3,4])
101+
t([3,8])
102+
> numeric.mul(numeric.t(1,2),numeric.t(3,4))
103+
t(-5,10)
104+
> numeric.mul(numeric.t([1,2],[3,4]),numeric.t([5,6],[7,8]))
105+
t([-16,-20],[22,40])
106+
*/
107+
function mul() {
108+
function muler(x,y) { var i; for(i=0;i<x.length;i++) { x[i] *= y(i); } }
109+
var ret = copy(t(arguments[0])),foo;
110+
var i,j,foo,bar,x1,y1,x2,y2,z1,z2;
111+
for(i=1;i<arguments.length;i++) {
112+
foo = t(arguments[i]);
113+
if(typeof ret.y !== "undefined" || typeof foo.y !== "undefined") {
114+
x1 = real(ret);
115+
y1 = imag(ret);
116+
x2 = real(foo);
117+
y2 = imag(foo);
118+
z1 = sub(mul(x1,x2),mul(y1,y2));
119+
z2 = add(mul(x1,y2),mul(y1,x2));
120+
ret = mkT(z1.s,z1.x,z2.x);
121+
} else {
122+
if(ret.s.length === 0 && foo.s.length > 0) {
123+
bar = ret;
124+
ret = copy(foo);
125+
foo = bar;
126+
}
127+
muler(ret.x,mkf(foo.x));
128+
}
129+
}
130+
return ret;
131+
}
132+
expo(mul);
133+
134+
/**
135+
* Pointwise division of tensor.
136+
*
137+
* @example
138+
> numeric.div(1,2)
139+
t(0.5)
140+
> numeric.div([1,2],4)
141+
t([0.25,0.5])
142+
> numeric.div(4,[1,2])
143+
t([4,2])
144+
> numeric.div([1,2],[4,8])
145+
t([0.25,0.25])
146+
> numeric.div(numeric.t(1,2),numeric.t(3,4))
147+
t(0.44,0.08)
148+
> numeric.div(1,numeric.t(3,4))
149+
t(0.12,-0.16)
150+
> numeric.div(numeric.t(3,4),5)
151+
t(0.6,0.8)
152+
*/
153+
function div() {
154+
function diver(x,y) { var i; for(i=0;i<x.length;i++) { x[i] /= y(i); } }
155+
var ret = copy(t(arguments[0])),foo;
156+
var i,j,foo,bar,x1,y1,x2,y2,z1,z2,r;
157+
for(i=1;i<arguments.length;i++) {
158+
foo = t(arguments[i]);
159+
if(typeof ret.y !== "undefined" || typeof foo.y !== "undefined") {
160+
x1 = real(ret);
161+
y1 = imag(ret);
162+
x2 = real(foo);
163+
y2 = imag(foo);
164+
r = add(mul(x2,x2),mul(y2,y2));
165+
z1 = div(add(mul(x1,x2),mul(y1,y2)),r);
166+
z2 = div(sub(mul(y1,x2),mul(x1,y2)),r);
167+
ret = mkT(z1.s,z1.x,z2.x);
168+
} else {
169+
if(ret.s.length === 0 && foo.s.length > 0) {
170+
ret = mkT(foo.s,mka(foo.x.length,ret.x[0]));
171+
}
172+
diver(ret.x,mkf(foo.x));
173+
}
174+
}
175+
return ret;
176+
}
177+
expo(div);

0 commit comments

Comments
 (0)