-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
270 lines (249 loc) · 11.2 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<!DOCTYPE html>
<html>
<head>
<link rel="icon" type="image/png" href="fav32.png" />
<!--[if IE]><link rel="shortcut icon" href="sitelink/favicon.ico"/><![endif]-->
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!--[if lt IE 9]>
<script
src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>Little's Webpages</title>
<meta name="description" content="The Github webpage for the Little
programming language">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css" >
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
display: block;
}
</style>
<link rel="stylesheet" type="text/css"
href="main.css" />
<script type="text/javascript" src="bignum.js"></script>
<script type="text/javascript" src="bigrational.js"></script>
<script type="text/javascript" src="integer_function.js"></script>
<script type="text/javascript" src="type-o-mat.js"></script>
<script type="text/javascript">
function despell() {
var string = document.getElementById('input_string').value;
var domobj = document.getElementById('kbd_layout');
var layout = domobj.options[domobj.selectedIndex].text;
var result = string.typeerrors(layout);
document.getElementById('output').value = result.join("\n");
return false;
}
function comp_bernoulli() {
var selectedRadio = "none";
var output = "";
var input = 0;
var i;
var string = document.getElementById('input_string').value;
var radios = document.getElementsByName("choice");
for (i = 0; i < radios.length; i++) {
if (radios[i].checked == true) {
selectedRadio = radios[i].value;
}
}
var rat = new Bigrational(1, 1);
input = parseInt(string);
var result = rat.bernoulli(input);
if (selectedRadio == "all") {
for (i = 0; i <= input; i++) {
if (i.isEven() || i == 1) {
output += rat.bernoulli(i).toString() + "\r\n";
}
}
} else {
output = result.toString();
}
document.getElementById('output').value = output;
return false;
}
</script>
</head>
<body id="index" class="home">
<header id="banner" class="body">
<h1>A <a href="https://github.com/czurnieden/Little" title="Little"><span style="font-variant:small-caps;font-weight:bold">Little</span></a> arbitrary precision in JavaScript</h1>
<nav><ul>
<li class="active"><a href="#">Home</a></li>
<li><a href="https://github.com/czurnieden/">Software</a></li>
<li><a href="https://deamentiaemundi.wordpress.com">Blog</a></li>
<li><a href="http://www.imdb.com/title/tt0118884/">Contact</a></li>
</ul></nav>
</header>
<aside id="featured" class="body"><article>
<figure><div id="case">
<div class="little_icon left">blame</div>
<div class="little_icon right"><img src="fav64.png" alt="CZ sign" /></div>
</div></figure>
<hgroup>
<h2>Status <span id="cdate">Thu Dec 11 02:27:56 CET 2014</span></h2>
</hgroup>
<p style="padding-left:3em;">
<span class="drumroll">New!</span> <a href="bernoulli.html">Give it a try!</a> Well, the raw bigint/bigrational libraries at least.
</p>
<p>
The <a href="https://github.com/czurnieden/Little/blob/master/libs/bignum.js">big integer library</a> is nearly complete,
with the exception of all of the things I forgot, of course and some optimizations that will follow later.
For example: Toom-Cook multiplication/squareing of higher order<br>
I have put the stuff listed below into the sub-directory <a href="https://github.com/czurnieden/Little/blob/master/libs/">libs</a>.
</p>
<ul>
<li>A bunch of helper functions</li>
<li>A <a href="https://github.com/czurnieden/Little/blob/master/libs/bignum.js">Bigint library</a> with the following arithmetic functions:<ul>
<li>Addition/Subtraction</li>
<li>Multiplication and fast multiplication (Karatsuba, Toom-Cook 3, FFT)</li>
<li>Division and fast division (Burnikel-Ziegler and Newton, Barret division is still broken)</li>
<li>Squaring and fast Squaring (Karatsuba, Toom-Cook 3, FFT)</li>
<li>Power (small integer to the power of a bigint and bigint to the power of a small integer)</li>
<li>Integer logarithm with a positive integer base</li>
<li>n<sup>th</sup> root for positive integer n</li>
<li>reading and printing the number as a string (a bit slow, no optimizations but see below)</li>
<li>GCD, LCM and extended GCD</li>
<li>a bunch of small needful functions (comparing, checking etc.)</li>
</ul></li>
<li>A <a href="https://github.com/czurnieden/Little/blob/master/libs/bigrational.js">Bigrational library</a> with the following arithmetic functions:<ul>
<li>Addition/Subtraction</li>
<li>Multiplication/Divison</li>
<li>n<sup>th</sup> root for positive rationals</li>
<li>median rounding (e.g.: for the roots)</li>
<li>a lot of helper functions</li>
<li>Bernoulli numbers. See below for the example</li>
</ul></li>
<li>A <a href="https://github.com/czurnieden/Little/blob/master/libs/integer_function.js">integer functions library</a> with the following content:<ul>
<li>Factorial, superfactorial, fallingfactorial, risingfactorial, doublefactorial, subfactorial</li>
<li>Binomial</li>
<li>Catalan number (not the constant)</li>
<li>Stirling numbers of the first kind</li>
<li>Stirling numbers of the second kind</li>
<li>Bell numbers</li>
<li>Eulerian (zig) numbers</li>
<li>Fibonacci</li>
</ul></li>
<li>A distinct lack of documentation</li>
</ul>
<p class="widerpar">
The <a href="https://github.com/czurnieden/Little/blob/master/libs/bignum.js">file with the Bigint library</a> is stand-alone, you can give it a try without much ado.
</p>
<p>
Some optimization for reading and writing big integers are possible, especially the radices base 2<sup>k</sup> like 2, 8, 16 and 2<sup>26</sup> (the size of the bigint digit).<br> Optimization of in- and output for radix ten is possible if we work with larger chunks instead of single characters. The input would be much faster (the output not so much but still faster) but needs a big integer library with radix 10<sup>k</sup> (with k = 7 for ECMAScript's standard 64-bit numbers).<br>
It (including the basic Bigdecimal code necessary) is in the code but still commented out, needs some more testing.
</p>
<p>
All what is left to do is to write a basic Bigfloat library (with the same number of functions of the Bigint library) and get the parser to spit out the correct AST.
</p>
</article></aside>
<section id="content" class="body">
<ol id="posts-list" class="hfeed">
<li><article class="hentry">
<header>
<h2 class="entry-title">Bernoulli Numbers</h2>
</header>
<footer class="post-info">
The algorithm is based on: Brent, Richard P., and David Harvey. "Fast computation of Bernoulli, Tangent
and Secant numbers." Computational and Analytical Mathematics. Springer New
York, 2013. 127-142. <a href="http://arxiv.org/abs/1108.0286">Preprint here</a>
</footer>
<div class="entry-content">
<p>Get a Bernoulli number. Please be aware that this is done in pure
JavaScript. So B<sub>100</sub> gets you quasi immediate satisfaction
but B<sub>1,000</sub> may need a minute or five.<br>
The algorithm caches the results up to B<sub>n</sub>
</p>
<p>
<form class="typo_form" name="bern_form" id="bern_form" onsubmit="return false" action="" method="post" >
<ul>
<li>
<h2>Bernoulli Numbers</h2>
</li>
<li>
<label for="input_string">Which one?</label>
<input type="text" style="width:5em;" name="input_string" id="input_string" required/>
</li>
<li>
<label>How many?</label>
<input style="vertical-align:bottom;width:1em" type="radio" name="choice" id="choice_one" value="one" checked="checked"/>
<span>One</span><br>
<input style="vertical-align:bottom;width:1em" type="radio" name="choice" id="choice_all" value="all"/>
<span>All (B<sub>2n</sub> including B<sub>1</sub>)</span><br>
<li>
<li>
<label for="output">Bernoulli Number(s):</label>
<textarea type="text" name="output" id="output" cols="60" rows="10" readonly="readonly"></textarea>
</li>
<li>
<button class="submit" onclick="comp_bernoulli()">Compute</button>
</li>
</ul>
</form>
</p>
<p>
</p>
</div>
</article></li>
<li><article class="hentry">
<header>
<h2 class="entry-title">Make Some Typos</h2>
</header>
<footer class="post-info">
A JavaScript port of an older version of the Perl module <a href="https://metacpan.org/pod/Lingua::TypoGenerator">Lingua::TypoGenerator</a> by Ivan Tubert-Brohman with some additional keyboard layouts
</footer>
<div class="entry-content">
<p>And if you cannot do it yourself, here is a little script to help you out with it.</p>
<p>
<form class="typo_form" name="typo_form" id="typo_form" onsubmit="return false" action="#" method="post" >
<ul>
<li>
<h2>Type-O-Mat</h2>
</li>
<li>
<label for="input_string">Spelled right:</label>
<input type="text" name="input_string" id="input_string" required/>
</li>
<li>
<label for="output">Spelled wrong:</label>
<textarea type="text" name="output" id="output" cols="60" rows="10" readonly="readonly"></textarea>
</li>
<li>
<button class="submit" onclick="despell()">Spe3lcheck</button> with
<select id="kbd_layout">
<option>en</option>
<option>es</option>
<option>fr</option>
<option>pt</option>
<option>de</option>
</select> layout.
</li>
</ul>
</form>
</p>
<p>
It is quite simple and works quite correct for English keyboard layouts, but only so-so for the rest. See the <a href="./type-o-mat.js">Source code</a> for details. For a more refined algorithm you might look at <a href="https://metacpan.org/pod/Lingua::DE::TypoGenerator"> Lingua::DE::TypoGenerator</a>
</p>
</div>
</article></li>
<!--
<li><article class="hentry">
...
</article></li>
<li><article class="hentry">
...
</article></li>-->
</ol><!-- /#posts-list -->
</section><!-- /#content -->
<section id="extras" class="body">
<div class="blogroll">
<h2>Needful Links</h2>
<ul>
<li><a href="http://www.ecma-international.org/ecma-262/5.1/" rel="external">ECMAScript</a></li>
<li><a href="https://developer.mozilla.org/" rel="external">MDN</a></li>
<li><a href="http://en.wikipedia.org" rel="external">Wikipedia</a></li>
</ul>
</div><!-- /.blogroll -->
</section><!-- /#extras -->
<footer id="contentinfo" class="body">
This page is in large parts based upon the example <a href="http://www.smashingmagazine.com/2009/08/04/designing-a-html-5-layout-from-scratch/">Smashing HTML5</a> by <a href="http://enrique-ramirez.com">Enrique Ramírez</a>.<br />It looked quite good before I took it into my unwashed hands.
</footer><!-- /#contentinfo -->
</body>
</html>