├── .gitignore ├── MANIFEST.in ├── README.rst ├── numscrypt ├── __base__.py ├── __init__.py ├── development │ ├── automated_tests │ │ └── ndarray │ │ │ ├── autotest.html │ │ │ ├── autotest.py │ │ │ ├── basics │ │ │ └── __init__.py │ │ │ ├── module_fft │ │ │ └── __init__.py │ │ │ └── module_linalg │ │ │ └── __init__.py │ ├── docs │ │ ├── complex.txt │ │ └── tolist.txt │ ├── manual_tests │ │ ├── numpy_eig │ │ │ ├── __javascript__ │ │ │ │ ├── extra │ │ │ │ │ └── sourcemap │ │ │ │ │ │ ├── test.js.map │ │ │ │ │ │ ├── test.min.js.cascade.mapdump │ │ │ │ │ │ ├── test.min.js.map │ │ │ │ │ │ ├── test.mod.js.map │ │ │ │ │ │ └── test.shrink.js.map │ │ │ │ ├── test.js │ │ │ │ ├── test.min.js │ │ │ │ └── test.mod.js │ │ │ ├── test.html │ │ │ ├── test.min.html │ │ │ ├── test.py │ │ │ └── testmp.py │ │ └── slicing_optimization │ │ │ ├── __javascript__ │ │ │ ├── test.js │ │ │ ├── test.min.js │ │ │ └── test.mod.js │ │ │ ├── test.html │ │ │ ├── test.min.html │ │ │ └── test.py │ └── shipment │ │ ├── os │ │ ├── shipment_test.py │ │ ├── site │ │ ├── test_install.py │ │ └── upload_all.py ├── docs │ ├── Numscrypt.html │ ├── images │ │ ├── Thumbs.db │ │ ├── abacus_square - Copy (2).png │ │ ├── abacus_square - Copy.png │ │ ├── abacus_square.png │ │ ├── lin_alg_book.jpg │ │ ├── numscrypt_logo_sphinx.html │ │ ├── numscrypt_logo_sphinx.png │ │ ├── numscrypt_logo_white.html │ │ ├── numscrypt_logo_white.png │ │ └── numscrypt_logo_white_small.png │ └── sphinx │ │ ├── Makefile │ │ ├── _build │ │ ├── doctrees │ │ │ ├── autotest_suite.doctree │ │ │ ├── autotesting_transcrypt.doctree │ │ │ ├── environment.pickle │ │ │ ├── index.doctree │ │ │ ├── installation_use.doctree │ │ │ ├── integration_javascript.doctree │ │ │ ├── special_facilities.doctree │ │ │ ├── supported_constructs.doctree │ │ │ ├── transcrypt_what_why.doctree │ │ │ └── what_why.doctree │ │ └── html │ │ │ ├── .buildinfo │ │ │ ├── _sources │ │ │ ├── index.rst.txt │ │ │ ├── index.txt │ │ │ ├── installation_use.rst.txt │ │ │ ├── installation_use.txt │ │ │ ├── supported_constructs.rst.txt │ │ │ ├── supported_constructs.txt │ │ │ ├── what_why.rst.txt │ │ │ └── what_why.txt │ │ │ ├── _static │ │ │ ├── Thumbs.db │ │ │ ├── ajax-loader.gif │ │ │ ├── basic.css │ │ │ ├── classic.css │ │ │ ├── comment-bright.png │ │ │ ├── comment-close.png │ │ │ ├── comment.png │ │ │ ├── default.css │ │ │ ├── doctools.js │ │ │ ├── down-pressed.png │ │ │ ├── down.png │ │ │ ├── file.png │ │ │ ├── jquery-1.11.1.js │ │ │ ├── jquery-3.1.0.js │ │ │ ├── jquery.js │ │ │ ├── logo_sphinx.png │ │ │ ├── minus.png │ │ │ ├── monk_transcribing.png │ │ │ ├── numscrypt_logo_sphinx.png │ │ │ ├── plus.png │ │ │ ├── pygments.css │ │ │ ├── searchtools.js │ │ │ ├── sidebar.js │ │ │ ├── underscore-1.3.1.js │ │ │ ├── underscore.js │ │ │ ├── up-pressed.png │ │ │ ├── up.png │ │ │ └── websupport.js │ │ │ ├── genindex.html │ │ │ ├── index.html │ │ │ ├── installation_use.html │ │ │ ├── objects.inv │ │ │ ├── search.html │ │ │ ├── searchindex.js │ │ │ ├── supported_constructs.html │ │ │ └── what_why.html │ │ ├── _templates │ │ ├── globaltoc.html │ │ └── localtoc.html │ │ ├── conf.py │ │ ├── index.rst │ │ ├── installation_use.rst │ │ ├── make.bat │ │ ├── supported_constructs.rst │ │ └── what_why.rst ├── fft │ ├── __init__.py │ └── __javascript__ │ │ └── fft_nayuki_precalc_fixed.js ├── license_reference.txt ├── linalg │ ├── __init__.py │ ├── eigen_mpmath - Copy.py │ └── eigen_mpmath.py └── random.py ├── setup.cfg └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # ====== File extensions anywhere 2 | *.nogit 3 | *.pyc 4 | *.npp 5 | *.log 6 | *.egg-info/ 7 | *.min.html/ 8 | .DS_Store 9 | 10 | # ======= Directories anywhere 11 | __target__/ 12 | __javascript__/ 13 | __pycache__/ 14 | .mypy_cache/ 15 | dist/ 16 | build/ 17 | node_modules/ 18 | package-lock/ 19 | 20 | # ======== Directories at specific locations 21 | transcrypt/docs/sphinx/_build/ 22 | transcrypt/development/attic/ 23 | transcrypt/development/docs/ 24 | transcrypt/development/experiments/ 25 | transcrypt/development/automated_tests/*/autotest.html 26 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | global-include *.py *.js *.rst *.html *.css *.lyx *.pdf *.png *.gif *.jpg *.txt *.jar *.bat * 2 | global-exclude *.pyc .gitignore 3 | 4 | prune .git 5 | prune dist 6 | prune numscrypt.egg-info 7 | prune numscrypt/development/attic 8 | prune numscrypt/development/docs 9 | prune numscrypt/development/experiments 10 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | **What is Numscrypt?** 2 | 3 | Numscrypt is a port of a small part of NumPy to Transcrypt using JavaScript typed arrays. As with Transcrypt, the eventual goal is not to completely copy a desktop programming environment. Rather a lean and mean subset is sought that can still be very useful, e.g. for science demo's in the browser or for small to medium scale computations. 4 | 5 | Whereas NumPy often has multiple way to do things, Numscrypt focuses on one obvious way. The clearest example is the NumPy type *matrix* type, that is a specialization of *ndarray* with confusingly deviating use of some operators. In Transcrypt *matrix* is deliberately left out, to keep the code lean. 6 | 7 | While the first minor versions of Numscrypt fully supported views, strides, offsets and arrays of arbitrary dimension, this proved to be too slow when compiled to JavaScript. Especially the generalized indexing caused a lot of overhead when arrays weren't stored in natural order. Moreover supporting arrays of arbitrary dimension lead to recursion in some places, and with that to suboptimal performance and scalability. And all this overhead was merely there to support use cases that were relatively rare. Of course copying in itself costs time, but JavaScript typed arrays can do it in one highly optimized operation , e.g. in case of slicing, provided natural storage order is followed. And indeed copies cost memory as well. However views are slow due to complicated index computations, and speed was favoured over small memory use here. 8 | 9 | The rationale behind favouring speed over small memory use deserves some attention, since it also makes clear what Numscrypt is for. In computations like inversion, non-elementwise matrix multiplication, convolution and FFT, the ability to store very large arrays is pointless if computations are slow. So the choice for speed over small memory use illustrates the fact that Numscrypt is meant for non-trivial computations on small to medium scale, rather than for data reshuffling on medium to large scale. 10 | 11 | In contrast to Transcrypt, which already has seen officially releases, Numscrypt is still experimental. This led to the conclusion that if the course had to be altered significantly, it had to happen soon, well before the first release. So in pursuit a good balance between familiarity and efficiency, requirements with respect to Numpy compatibility have been relaxed. Arrays can now only have one or two dimensions and are always stored in natural storage order per row. This means that views are not supported anymore and slices are always copies, since that enables them to have natural storage order as well, enabling fast access. 12 | 13 | **Computing in a browser?** 14 | 15 | - At first Numscrypt was purely meant as a tool for education and demonstration. The fact that some serious numerical math libraries for JavaScript do exist, sometimes using weird tricks to mimic operator overloading, led to reconsideration. Although computing in JavaScript on a browser certainly restricts performance and scalabilty compared to computing in C++ on dedicated manycore hardware, this doesn't mean that there aren't many useful, serious applications. If, given the existence of several JavaScript math libraries, there appears to be a need for computing in the browser, why not enable doing so in a language that is familiar to scientists and technicians, and has decent solutions for e.g. operator overloading and slicing notation. The partial parity between Numscrypt and Numpy is another attractive aspect of this approach. With broad use in mind, not only is there a direct gain of execution speed by simplifying matters, also chances of future optimization using asm.js, simd.js or GPGPU code are better in that case. The newly introduced type annotations of Python may well ease application of such technologies in a robust manner. 16 | 17 | - Despite the fact that they are used in some branches of physics, arrays with more dimensions than 2 are relatively rare. If they are needed, in most cases a one- or multi-dimensional list of 2D arrays will do just as well. The speed benefits gained from restricting arrays to 1D and 2D are enormous when forced to compile to something like JavaScript rather than C++, since the whole strided index computation mechanism is largely avoided. Also the code of Numscrypt becomes much more simple. Striving for code simplicity is always an important design consideration. It enables others to understand the source and contribute to it. It enables rapid addition of new features. And, with a browser application, it makes for lean downloads. As a result of the restriction to 1D and 2D arrays, lean, efficient JavaScript code can be generated, even for arrays of complex numbers, which are considered essential for clean notation of e.g harmonic solutions of systems of linear differential equations. 18 | 19 | - 1D and 2D arrays with natural storage order map rather well on existing JavaScript math libraries. This means that for some applications Numscrypt can be a mere elegant facade for something already available in JavaScript. The FFT has been implemented along that line using the efficient, partially precalculated JavaScript variant of the Nayuki FFT rather than the slower, non-precalculated Python variant. This means that the number of samples is restricted to a power of 2 currently. Compromises like that are probably wise when computing in a browser. Generalizing to N samples is considerably slower and as an alternative a suitable form of padding combined with windowing can be used. Recently also the 2D FFT has been added. 20 | 21 | **The bottom line...** 22 | 23 | The course of Numscrypt has been fundamentally altered. Starting out as a toy, it now has serious, but modest, ambitions. If people venture to compute in JavaScript, why not allow them to do it in Python, a language is established in the scientific community, traditionally featuring things like operator overloading and complex numbers. While predicting is hard, especially if it concerns the future, there's a wave of new technologies coming up allowing faster computation in JavaScript. Numscrypt is now simple and open enough to surf on that wave, while hiding the technical details behind a very readable notation. 24 | 25 | Jacques de Hooge 26 | 27 | .. figure:: http://www.transcrypt.org/numscrypt/illustrations/numscrypt_logo_white_small.png 28 | :alt: Logo 29 | 30 | **The first computers were used... to compute** 31 | 32 | What's new 33 | ========== 34 | 35 | N.B. Always use the newest version of Transcrypt to be able to use the newest features of Numscrypt. 36 | 37 | - Eigenvector decomposition (numpy.linalg.eig) now supported for complex arrays 38 | - Added numpy.linalg.norm 39 | - Tested with Transcrypt Paris 3.6.80 40 | - FFT2 and IFFT2 (2D Fast Fourier Transform) now supported for complex arrays 41 | - Complete redesign 42 | 43 | Other packages you might like 44 | ============================= 45 | 46 | - Python to JavaScript transpiler, supporting multiple inheritance and generating lean, highly readable code: https://pypi.python.org/pypi/Transcrypt 47 | - Multi-module Python source code obfuscator: https://pypi.python.org/pypi/Opy 48 | - PLC simulator with Arduino code generation: https://pypi.python.org/pypi/SimPyLC 49 | - A lightweight Python course taking beginners seriously (under construction): https://pypi.python.org/pypi/LightOn 50 | - Event driven evaluation nodes: https://pypi.python.org/pypi/Eden 51 | -------------------------------------------------------------------------------- /numscrypt/__base__.py: -------------------------------------------------------------------------------- 1 | ns_version = '0.0.40' 2 | -------------------------------------------------------------------------------- /numscrypt/development/automated_tests/ndarray/autotest.py: -------------------------------------------------------------------------------- 1 | import org.transcrypt.autotester 2 | 3 | import basics 4 | import module_linalg 5 | import module_fft 6 | 7 | autoTester = org.transcrypt.autotester.AutoTester () 8 | 9 | autoTester.run (basics, 'basics') 10 | autoTester.run (module_linalg, 'module_linalg') 11 | autoTester.run (module_fft, 'module_fft') 12 | 13 | autoTester.done () 14 | -------------------------------------------------------------------------------- /numscrypt/development/automated_tests/ndarray/basics/__init__.py: -------------------------------------------------------------------------------- 1 | from org.transcrypt.stubs.browser import * 2 | from org.transcrypt.stubs.browser import __main__, __envir__, __pragma__ 3 | 4 | # Imports for Transcrypt, skipped runtime by CPython 5 | if __envir__.executor_name == __envir__.transpiler_name: 6 | import numscrypt as num 7 | 8 | # Imports for CPython, skipped compile time by Transcrypt 9 | __pragma__ ('skip') 10 | import numpy as num 11 | __pragma__ ('noskip') 12 | 13 | def run (autoTester): 14 | z = num.zeros ((4, 3), 'int32') 15 | autoTester.check ('Zeros', z.tolist (), '
') 16 | 17 | o = num.ones ((4, 5)) 18 | autoTester.check ('Ones', o.astype ('int32') .tolist ()) 19 | 20 | i = num.identity (3, 'int32') 21 | autoTester.check ('Identity', i.tolist (), '
') 22 | 23 | a = num.array ([ 24 | [1, 1, 2, 3], 25 | [4, 5, 6, 7], 26 | [8, 9, 10, 12] 27 | ]) 28 | 29 | autoTester.check ('Matrix a', a.tolist (), '
') 30 | 31 | autoTester.check ('Transpose of a', a.transpose () .tolist (), '
') 32 | 33 | b = num.array ([ 34 | [2, 2, 4, 6], 35 | [8, 10, 12, 14], 36 | [16, 18, 20, 24] 37 | ]) 38 | 39 | bp = b.transpose () 40 | 41 | autoTester.check ('Matrix b', b.tolist (), '
') 42 | autoTester.check ('Permutation of b', bp.tolist (), '
') 43 | 44 | c = num.array ([ 45 | [1, 2, 3, 4], 46 | [5, 6, 7, 8], 47 | [9, 10, 11, 12], 48 | ], 'int32') 49 | 50 | autoTester.check ('Shape c', tuple (c.shape), '
') 51 | autoTester.check ('Matrix c', c.tolist (), '
') 52 | 53 | ct = c.transpose () 54 | autoTester.check ('Shape ct', tuple (ct.shape), '
') 55 | autoTester.check ('Transpose of c', ct .tolist (), '
') 56 | 57 | cs0, cs1 = num.hsplit (c, 2) 58 | autoTester.check ('Matrix cs0', cs0.tolist (), '
') 59 | autoTester.check ('Matrix cs1', cs1.tolist (), '
') 60 | 61 | ci = num.hstack ((cs1, cs0)) 62 | autoTester.check ('Matrix ci', ci.tolist (), '
') 63 | 64 | cts0, cts1, cts2 = num.hsplit (ct, 3) 65 | autoTester.check ('Matrix cts0', cts0.tolist (), '
') 66 | autoTester.check ('Matrix cts1', cts1.tolist (), '
') 67 | autoTester.check ('Matrix cts2', cts2.tolist (), '
') 68 | 69 | cti = num.hstack ((cts2, cts1, cts0)) 70 | autoTester.check ('Matrix ci', cti.tolist (), '
') 71 | 72 | d = num.array ([ 73 | [13, 14], 74 | [15, 16], 75 | [17, 18], 76 | [19, 20] 77 | ], 'int32') 78 | 79 | autoTester.check ('Matrix d', d.tolist (), '
') 80 | dt = d.transpose () 81 | autoTester.check ('Permutation of d', dt.tolist (), '
') 82 | 83 | ds0, ds1, ds2, ds3 = num.vsplit (d, 4) 84 | autoTester.check ('Matrix ds0', ds0.tolist (), '
') 85 | autoTester.check ('Matrix ds1', ds1.tolist (), '
') 86 | autoTester.check ('Matrix ds2', ds2.tolist (), '
') 87 | autoTester.check ('Matrix ds3', ds3.tolist (), '
') 88 | 89 | di = num.vstack ((ds3, ds2, ds1, ds0)) 90 | autoTester.check ('Matrix di', di.tolist (), '
') 91 | 92 | dts0, dts1 = num.vsplit (dt, 2) 93 | autoTester.check ('Matrix dts0', dts0.tolist (), '
') 94 | autoTester.check ('Matrix dts1', dts1.tolist (), '
') 95 | 96 | dti = num.vstack ((dts1, dts0)) 97 | autoTester.check ('Matrix dti', dti.tolist (), '
') 98 | 99 | v0 = num.array (range (10)) 100 | v1 = num.array ((1, 2, 3, 1, 2, 3, 1, 2, 3, 1)) 101 | 102 | m_in_mul = num.array (((-1, 2, 3), (4, 5, 6), (7, 8, 10))) 103 | v_in_mul = num.array ((-1, 2, 4)) 104 | 105 | __pragma__ ('opov') 106 | 107 | a [1, 0] = 177 108 | el = b [1, 2] 109 | 110 | bsl0 = b [1, 1 : 3] 111 | bsl1 = b [1 : 2, 1 : 3] 112 | bsl2 = b [1 : 2, 1] 113 | bsl3 = b [1, 1 : 3] 114 | bsl4 = b [ : , 1] 115 | bsl5 = b [1, 1 : 3] 116 | bsl6 = b [1, 1 : 3] 117 | bsl7 = b [1, 2 : 3] 118 | 119 | bpsl0 = bp [1, 1 : 3] 120 | bpsl1 = bp [1 : 2, 1 : 3] 121 | bpsl2 = bp [1, 0 : ] 122 | bpsl3 = bp [1, 1 : 3] 123 | bpsl4 = bp [ : , 1] 124 | bpsl5 = bp [3, 1 : 3] 125 | bpsl6 = bp [2 : 4, 1 : 3] 126 | bpsl7 = bp [2 : 4, 2 : 3] 127 | 128 | sum = a + b 129 | dif = a - b 130 | prod = a * b 131 | quot = a / b 132 | dot = c @ d 133 | vsum = v0 + v1 134 | vel = 80 # vsum [6] 135 | vsum [6] = 70 136 | 137 | mul_a3 = a * 3 138 | mul_3a = 3 * a 139 | div_a3 = a / 3.1234567 140 | div_3a = 3.1234567 / a 141 | add_a3 = a + 3 142 | add_3a = 3 + a 143 | sub_a3 = a - 3 144 | sub_3a = 3 - a 145 | neg_a = -a 146 | 147 | m_out_mul = m_in_mul @ v_in_mul 148 | 149 | __pragma__ ('noopov') 150 | 151 | autoTester.check ('El a [1, 2, 3] alt', a.tolist (), '
') 152 | autoTester.check ('El b [1, 2, 3]', el, '
') 153 | 154 | autoTester.check ('Sl b0', bsl0.tolist (), '
') 155 | autoTester.check ('Sl b1', bsl1.tolist (), '
') 156 | autoTester.check ('Sl b2', bsl2.tolist (), '
') 157 | autoTester.check ('Sl b3', bsl3.tolist (), '
') 158 | autoTester.check ('Sl b4', bsl4.tolist (), '
') 159 | autoTester.check ('Sl b5', bsl5.tolist (), '
') 160 | autoTester.check ('Sl b6', bsl6.tolist (), '
') 161 | autoTester.check ('Sl b7', bsl7.tolist (), '
') 162 | 163 | autoTester.check ('Sl bp0', bpsl0.tolist (), '
') 164 | autoTester.check ('Sl bp1', bpsl1.tolist (), '
') 165 | autoTester.check ('Sl bp2', bpsl2.tolist (), '
') 166 | autoTester.check ('Sl bp3', bpsl3.tolist (), '
') 167 | autoTester.check ('Sl bp4', bpsl4.tolist (), '
') 168 | autoTester.check ('Sl bp5', bpsl5.tolist (), '
') 169 | autoTester.check ('Sl bp6', bpsl6.tolist (), '
') 170 | autoTester.check ('Sl bp7', bpsl7.tolist (), '
') 171 | 172 | autoTester.check ('Matrix sum', sum.tolist (), '
') 173 | autoTester.check ('Matrix difference', dif.tolist (), '
') 174 | autoTester.check ('Matrix product', prod.tolist (), '
') 175 | autoTester.check ('Matrix quotient', quot.tolist (), '
') 176 | autoTester.check ('Matrix dotproduct', dot.tolist (), '
') 177 | 178 | autoTester.check ('Vector', v0.tolist (), '
') 179 | autoTester.check ('Vector', v1.tolist (), '
') 180 | autoTester.check ('El sum old', vel, '
') 181 | autoTester.check ('Vector sum new', vsum.tolist (), '
') 182 | 183 | autoTester.check ('mul_a3', mul_a3.tolist (), '
') 184 | autoTester.check ('mul_3a', mul_3a.tolist (), '
') 185 | autoTester.check ('div_a3', num.round (div_a3, 2).tolist (), '
') 186 | autoTester.check ('div_3a', num.round (div_3a, 2).tolist (), '
') 187 | autoTester.check ('add_a3', add_a3.tolist (), '
') 188 | autoTester.check ('add_3a', add_3a.tolist (), '
') 189 | autoTester.check ('sub_a3', sub_a3.tolist (), '
') 190 | autoTester.check ('sub_3a', sub_3a.tolist (), '
') 191 | autoTester.check ('neg_a', neg_a.tolist (), '
') 192 | autoTester.check ('m_out_mul', m_out_mul.tolist (), '
') 193 | 194 | __pragma__ ('opov') 195 | comp_a = num.array ([ 196 | [1 + 2j, 2 - 1j, 3], 197 | [4, 5 + 3j, 7] 198 | ], 'complex128') 199 | comp_b = num.array ([ 200 | [6, 8 - 1j], 201 | [9 + 3j, 10], 202 | [11, 12 - 6j] 203 | ], 'complex128') 204 | comp_c = comp_a @ comp_b 205 | __pragma__ ('noopov') 206 | 207 | autoTester.check ('comp_a', comp_a.tolist (), '
') 208 | autoTester.check ('comp_b', comp_b.tolist (), '
') 209 | autoTester.check ('comp_c', comp_c.tolist (), '
') 210 | 211 | __pragma__ ('opov') 212 | 213 | comp_a_square = comp_a [ : , : 2] 214 | comp_b_square = comp_b [1 : , : ] 215 | 216 | comp_c_square = comp_a_square * comp_b_square 217 | comp_d_square = comp_a_square / comp_b_square 218 | comp_e_square = comp_a_square + comp_b_square 219 | comp_f_square = comp_a_square - comp_b_square 220 | 221 | __pragma__ ('noopov') 222 | 223 | autoTester.check ('comp_a_square', comp_a_square.tolist (), '
') 224 | autoTester.check ('comp_b_square', comp_b_square.tolist (), '
') 225 | autoTester.check ('comp_c_square', comp_c_square.tolist (), '
') 226 | autoTester.check ('comp_d_square', num.round (comp_d_square, 2).tolist (), '
') 227 | autoTester.check ('comp_e_square', comp_e_square.tolist (), '
') 228 | autoTester.check ('comp_f_square', comp_f_square.tolist (), '
') 229 | 230 | __pragma__ ('opov') 231 | sliceable_a = num.array ([ 232 | [1, 2, 3, 4], 233 | [5, 6, 7, 8], 234 | [9, 10, 11, 12], 235 | [13, 14, 15, 16] 236 | ]) 237 | autoTester.check ('sliceable_a', sliceable_a.tolist ()) 238 | 239 | slice_a = sliceable_a [1 : , 1 : ] 240 | autoTester.check ('slice_a') 241 | 242 | sliceable_at = sliceable_a.transpose () 243 | slice_at = sliceable_at [1 : ] 244 | 245 | __pragma__ ('noopov') 246 | -------------------------------------------------------------------------------- /numscrypt/development/automated_tests/ndarray/module_fft/__init__.py: -------------------------------------------------------------------------------- 1 | from org.transcrypt.stubs.browser import * 2 | from org.transcrypt.stubs.browser import __main__, __envir__, __pragma__ 3 | 4 | from math import sin, cos, pi 5 | 6 | transpiled = __envir__.executor_name == __envir__.transpiler_name 7 | 8 | # Imports for Transcrypt, skipped run time by CPython 9 | if __envir__.executor_name == __envir__.transpiler_name: 10 | import numscrypt as num 11 | import numscrypt.fft as fft 12 | 13 | # Imports for CPython, skipped compile time by Transcrypt 14 | __pragma__ ('skip') 15 | import numpy as num 16 | import numpy.fft as fft 17 | __pragma__ ('noskip') 18 | 19 | fSample = 4096 20 | tTotal = 2 21 | fSin = 30 22 | fCos = 50 23 | 24 | def getNow (): # Avoid operator overloading, which would result in the dysfunctional: __new__ __call__ (Date) 25 | return __new__ (Date ()) 26 | 27 | def tCurrent (iCurrent): 28 | return iCurrent / fSample 29 | 30 | def run (autoTester): 31 | __pragma__ ('opov') 32 | delta = 0.001 + 0.001j 33 | __pragma__ ('noopov') 34 | 35 | autoTester.check ('
------ 1D ------
') 36 | 37 | cut = 102 38 | 39 | autoTester.check ('Samples computed: {}
'.format (tTotal * fSample)) 40 | autoTester.check ('Samples shown: {}
'.format (cut)) 41 | 42 | orig = num.array ([ 43 | complex (0.3 + sin (2 * pi * fSin * t) + 0.5 * cos (2 * pi * fCos * t), 0) 44 | for t in [ 45 | iSample / fSample 46 | for iSample in range (tTotal * fSample) 47 | ] 48 | ], 'complex128') 49 | 50 | __pragma__ ('opov') 51 | 52 | autoTester.check ('Original samples', num.round (orig + delta, 3) .tolist ()[ : cut], '
') 53 | 54 | if transpiled: 55 | timeStartFft = getNow () 56 | freqs = fft.fft (orig) 57 | if transpiled: 58 | timeStopFft = getNow () 59 | 60 | autoTester.check ('Frequencies', num.round (freqs + delta, 3) .tolist ()[ : cut], '
') 61 | 62 | if transpiled: 63 | timeStartIfft = getNow () 64 | reconstr = fft.ifft (freqs) 65 | if transpiled: 66 | timeStopIfft = getNow () 67 | 68 | autoTester.check ('Reconstructed samples', num.round (reconstr + delta, 3) .tolist ()[ : cut], '
') 69 | 70 | __pragma__ ('noopov') 71 | 72 | if transpiled: 73 | print ('FFT for {} samples took {} ms'.format (tTotal * fSample, timeStopFft - timeStartFft)) 74 | print ('IFFT for {} samples took {} ms'.format (tTotal * fSample, timeStopIfft - timeStartIfft)) 75 | 76 | autoTester.check ('
------ 2D ------
') 77 | 78 | __pragma__ ('opov') 79 | 80 | orig2 = num.zeros ((128, 128), 'complex128') 81 | orig2 [32 : 96, 32 : 96] = num.ones ((64, 64), 'complex128') 82 | 83 | autoTester.check ('Original samples', num.round (orig2 + delta, 3) [64 : 68, 16 : 112] .tolist (), '
') 84 | 85 | if transpiled: 86 | timeStartFft = getNow () 87 | 88 | freqs2 = fft.fft2 (orig2) 89 | if transpiled: 90 | timeStopFft = getNow () 91 | 92 | autoTester.check ('Frequencies', num.round (freqs2 + delta, 3) [64 : 68, 16 : 112] .tolist (), '
') 93 | 94 | if transpiled: 95 | timeStartIfft = getNow () 96 | reconstr2 = fft.ifft2 (freqs2) 97 | if transpiled: 98 | timeStopIfft = getNow () 99 | 100 | if transpiled: 101 | print ('FFT2 for {} samples took {} ms'.format (orig2.size, timeStopFft - timeStartFft)) 102 | print ('IFFT2 for {} samples took {} ms'.format (orig2.size, timeStopIfft - timeStartIfft)) 103 | 104 | autoTester.check ('Reconstructed samples', num.round (reconstr2 + delta, 3) [64 : 68, 16 : 112] .tolist (), '
') 105 | 106 | __pragma__ ('noopov') 107 | 108 | -------------------------------------------------------------------------------- /numscrypt/development/automated_tests/ndarray/module_linalg/__init__.py: -------------------------------------------------------------------------------- 1 | from org.transcrypt.stubs.browser import * 2 | from org.transcrypt.stubs.browser import __main__, __envir__, __pragma__ 3 | 4 | # Imports for Transcrypt, skipped run time by CPython 5 | if __envir__.executor_name == __envir__.transpiler_name: 6 | import numscrypt as num 7 | import numscrypt.linalg as linalg 8 | 9 | # Imports for CPython, skipped compile time by Transcrypt 10 | __pragma__ ('skip') 11 | import numpy as num 12 | import numpy.linalg as linalg 13 | num.set_printoptions (linewidth = 240) 14 | __pragma__ ('noskip') 15 | 16 | def run (autoTester): 17 | autoTester.check ('====== inverse ======') 18 | 19 | # Real 20 | 21 | r = num.array ([ 22 | [2.12, -2.11, -1.23], 23 | [2.31, 1.14, 3.15], 24 | [1.13, 1.98, 2.81] 25 | ]) 26 | 27 | autoTester.check ('Matrix r', num.round (r, 2) .tolist (), '
') 28 | 29 | ri = linalg.inv (r) 30 | 31 | autoTester.check ('Matrix ri', num.round (ri, 2) .tolist (), '
') 32 | 33 | __pragma__ ('opov') 34 | rid = r @ ri 35 | __pragma__ ('noopov') 36 | 37 | autoTester.check ('r @ ri', [[int (round (elem)) for elem in row] for row in rid.tolist ()], '
') 38 | 39 | __pragma__ ('opov') 40 | delta = 0.001 41 | autoTester.check ('r * r', num.round (r * r + delta, 3) .tolist (), '
') 42 | autoTester.check ('r / r', num.round (r / r + delta, 3) .tolist (), '
') 43 | autoTester.check ('r + r', num.round (r + r + delta, 3) .tolist (), '
') 44 | autoTester.check ('r - r', num.round (r - r + delta, 3) .tolist (), '
') 45 | __pragma__ ('noopov') 46 | 47 | # Complex 48 | 49 | __pragma__ ('opov') 50 | c = num.array ([ 51 | [2.12 - 3.15j, -2.11, -1.23], 52 | [2.31, 1.14, 3.15 + 2.75j], 53 | [1.13, 1.98 - 4.33j, 2.81] 54 | ], 'complex128') 55 | __pragma__ ('noopov') 56 | 57 | autoTester.check ('Matrix c', num.round (c, 2) .tolist (), '
') 58 | 59 | ci = linalg.inv (c) 60 | 61 | autoTester.check ('Matrix ci', num.round (ci, 2) .tolist (), '
') 62 | 63 | __pragma__ ('opov') 64 | cid = c @ ci 65 | __pragma__ ('noopov') 66 | 67 | # autoTester.check ('c @ ci', [['{} + j{}'.format (int (round (elem.real)), int (round (elem.imag))) for elem in row] for row in cid.tolist ()], '
') 68 | 69 | __pragma__ ('opov') 70 | delta = 0.001 + 0.001j 71 | autoTester.check ('c * c', num.round (c * c + delta , 3) .tolist (), '
') 72 | autoTester.check ('c / c', num.round (c / c + delta, 3) .tolist (), '
') 73 | autoTester.check ('c + c', num.round (c + c + delta, 3) .tolist (), '
') 74 | autoTester.check ('c - c', num.round (c - c + delta, 3) .tolist (), '
') 75 | __pragma__ ('noopov') 76 | 77 | autoTester.check ('====== eigen ======') 78 | 79 | __pragma__ ('opov') 80 | 81 | for a in ( 82 | num.array ([ 83 | [0, 1j], 84 | [-1j, 1] 85 | ], 'complex128'), 86 | num.array ([ 87 | [1, -2, 3, 1], 88 | [5, 8, -1, -5], 89 | [2, 1, 1, 100], 90 | [2, 1, -1, 0] 91 | ], 'complex128'), 92 | ): 93 | eVals, eVecs = linalg.eig (a) 94 | 95 | enumSorted = sorted ( 96 | enumerate (eVals.tolist ()), 97 | key = lambda elem: -(elem [1].real + elem [1].imag / 1000) # Order on primarily on real, secundarily on imag, note conjugate vals 98 | ) 99 | 100 | indicesSorted = [elem [0] for elem in enumSorted] 101 | eValsSorted = [elem [1] for elem in enumSorted] 102 | 103 | eValsMat = num.empty (a.shape, a.dtype) 104 | for iRow in range (a.shape [0]): 105 | for iCol in range (a.shape [1]): 106 | eValsMat [iRow, iCol] = eVals [iCol] 107 | 108 | eVecsNorms = num.empty ((eVecs.shape [1], ), a.dtype) 109 | for iNorm in range (eVecsNorms.shape [0]): 110 | eVecsNorms [iNorm] = complex (linalg.norm (eVecs [:, iNorm])) 111 | 112 | eVecsCanon = num.empty (a.shape, a.dtype) 113 | for iRow in range (a.shape [0]): 114 | for iCol in range (a.shape [1]): 115 | eVecsCanon [iRow, iCol] = eVecs [iRow, iCol] / eVecs [0, iCol] 116 | 117 | eVecsSorted = num.empty (a.shape, a.dtype) 118 | for iRow in range (a.shape [0]): 119 | for iCol in range (a.shape [1]): 120 | eVecsSorted [iRow, iCol] = eVecsCanon [iRow, indicesSorted [iCol]] 121 | 122 | ''' 123 | autoTester.check ('\n---------------- a ----------------------') 124 | autoTester.check (a) 125 | autoTester.check ('\n---------------- eigVals ----------------') 126 | autoTester.check (eVals) 127 | autoTester.check ('\n---------------- eigValsMat--------------') 128 | autoTester.check (eValsMat) 129 | autoTester.check ('\n---------------- eigVecs ----------------') 130 | autoTester.check (eVecs) 131 | autoTester.check ('\n---------------- eigValsMat @ eigVecs ---') 132 | autoTester.check (eValsMat * eVecs) 133 | autoTester.check ('\n---------------- a @ eigVecs-------------') 134 | autoTester.check (a @ eVecs) 135 | autoTester.check ('\n---------------- eigVecsNorms -----------') 136 | autoTester.check (eVecsNorms) 137 | autoTester.check ('\n---------------- eigVecsCanon -----------') 138 | autoTester.check (eVecsCanon) 139 | ''' 140 | autoTester.check ('\n---------------- eigVecsSorted ----------') 141 | autoTester.check ([[(round (value.real + 1e-3, 3), round (value.imag + 1e-3, 3)) for value in row] for row in eVecsSorted.tolist ()]) 142 | autoTester.check ('\n---------------- eigValsSorted ----------') 143 | autoTester.check ([(round (value.real + 1e-3, 3), round (value.imag + 1e-3, 3)) for value in eValsSorted], '\n') 144 | -------------------------------------------------------------------------------- /numscrypt/development/docs/complex.txt: -------------------------------------------------------------------------------- 1 | A complex ndarray has the same interface as an ndarray 2 | But internally it consists of two ndarrays -------------------------------------------------------------------------------- /numscrypt/development/docs/tolist.txt: -------------------------------------------------------------------------------- 1 | To convert a numpy array into a list, go through the indices in target order and use [] to retrieve righ element. 2 | -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/numpy_eig/__javascript__/extra/sourcemap/test.min.js.cascade.mapdump: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/development/manual_tests/numpy_eig/__javascript__/extra/sourcemap/test.min.js.cascade.mapdump -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/numpy_eig/__javascript__/extra/sourcemap/test.mod.js.map: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "file": "D:/activ_tosh/geatec/Numscrypt/numscrypt/development/manual_tests/numpy_eig/__javascript__/test.mod.js", 4 | "sources": [ 5 | "D:/activ_tosh/geatec/Numscrypt/numscrypt/development/manual_tests/numpy_eig/test.py" 6 | ], 7 | "sourcesContent": [ 8 | "from org.transcrypt.stubs.browser import *\nfrom org.transcrypt.stubs.browser import __main__, __envir__, __pragma__\n\n# Imports for Transcrypt, resolved run time\nif __envir__.executor_name == __envir__.transpiler_name:\n\timport numscrypt as num\n\timport numscrypt.linalg as linalg\n\n# Imports for CPython, resolved compile time\n__pragma__ ('skip')\nimport numpy as num\nimport numpy.linalg as linalg\nnum.set_printoptions (linewidth = 240)\n__pragma__ ('noskip')\n\n__pragma__ ('opov')\n\ndef show (*args):\n print (*args)\n\nfor a in ( \n num.array ([\n [0, 1j],\n [-1j, 1]\n ], 'complex128'),\n num.array ([\n [1, -2, 3, 1],\n [5, 8, -1, -5],\n [2, 1, 1, 100],\n [2, 1, -1, 0]\n ], 'complex128'),\n num.array ([\n [1, 1, 0, 0],\n [0, 2, 2, 0],\n [0, 0, 3, 3],\n [0, 0, 0, 4]\n ], 'complex128'),\n) [1:2]:\n eVals, eVecs = linalg.eig (a)\n \n enumSorted = sorted (\n enumerate (eVals.tolist ()),\n key = lambda elem: -(elem [1].real + elem [1].imag / 1000) # Order on primarily on real, secundarily on imag, note conjugate vals\n )\n \n indicesSorted = [elem [0] for elem in enumSorted]\n eValsSorted = [elem [1] for elem in enumSorted]\n \n eValsMat = num.empty (a.shape, a.dtype)\n for iRow in range (a.shape [0]):\n for iCol in range (a.shape [1]):\n eValsMat [iRow, iCol] = eVals [iCol]\n \n eVecsNorms = num.empty ((eVecs.shape [1], ), a.dtype)\n for iNorm in range (eVecsNorms.shape [0]):\n eVecsNorms [iNorm] = complex (linalg.norm (eVecs [:, iNorm]))\n \n eVecsCanon = num.empty (a.shape, a.dtype)\n for iRow in range (a.shape [0]):\n for iCol in range (a.shape [1]):\n eVecsCanon [iRow, iCol] = eVecs [iRow, iCol] / eVecs [0, iCol] \n \n eVecsSorted = num.empty (a.shape, a.dtype)\n for iRow in range (a.shape [0]):\n for iCol in range (a.shape [1]):\n eVecsSorted [iRow, iCol] = eVecsCanon [iRow, indicesSorted [iCol]]\n \n show ( '=========================================')\n '''\n show ('\\n---------------- a ----------------------')\n show (a)\n show ('\\n---------------- eigVals ----------------')\n show (eVals)\n show ('\\n---------------- eigValsMat--------------')\n show (eValsMat)\n show ('\\n---------------- eigVecs ----------------')\n show (eVecs)\n show ('\\n---------------- eigValsMat @ eigVecs ---')\n show (eValsMat * eVecs)\n show ('\\n---------------- a @ eigVecs-------------')\n show (a @ eVecs)\n show ('\\n---------------- eigVecsNorms -----------')\n show (eVecsNorms)\n show ('\\n---------------- eigVecsCanon -----------')\n show (eVecsCanon)\n '''\n show ('\\n---------------- eigVecsSorted ----------')\n show ([[(round (value.real + 1e-10, 3), round (value.imag + 1e-10, 3)) for value in row] for row in eVecsSorted.tolist ()])\n show ('\\n---------------- eigValsSorted ----------')\n show ([(round (value.real + 1e-10, 3), round (value.imag + 1e-10, 3)) for value in eValsSorted], '\\n')\n show ( '=========================================')\n \n" 9 | ], 10 | "mappings": "AAAA;AAAA;AAIA;AACA;AACA;AAAA;AAWA;AAAA;AACA;AAAA;AAaA;AAAA;AAMA;AACA;AAAA;AAAA;AAGA;AAAA;AAAA;AAIA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAEA;AACA;AACA;AAAA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAEA;AAmBA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA" 11 | } -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/numpy_eig/__javascript__/test.mod.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | var __name__ = '__main__'; 3 | if (__envir__.executor_name == __envir__.transpiler_name) { 4 | var num = __init__ (__world__.numscrypt); 5 | var linalg = __init__ (__world__.numscrypt.linalg); 6 | } 7 | var show = function () { 8 | var args = tuple ([].slice.apply (arguments).slice (0)); 9 | __call__.apply (null, [print].concat ([null]).concat (args)); 10 | }; 11 | var __iterable0__ = __getslice__ (tuple ([__call__ (num.array, num, list ([list ([0, complex (0, 1.0)]), list ([__neg__ (complex (0, 1.0)), 1])]), 'complex128'), __call__ (num.array, num, list ([list ([1, __neg__ (2), 3, 1]), list ([5, 8, __neg__ (1), __neg__ (5)]), list ([2, 1, 1, 100]), list ([2, 1, __neg__ (1), 0])]), 'complex128'), __call__ (num.array, num, list ([list ([1, 1, 0, 0]), list ([0, 2, 2, 0]), list ([0, 0, 3, 3]), list ([0, 0, 0, 4])]), 'complex128')]), 1, 2, 1); 12 | for (var __index0__ = 0; __index0__ < len (__iterable0__); __index0__++) { 13 | var a = __getitem__ (__iterable0__, __index0__); 14 | var __left0__ = __call__ (linalg.eig, linalg, a); 15 | var eVals = __left0__ [0]; 16 | var eVecs = __left0__ [1]; 17 | var enumSorted = __call__ (sorted, null, __call__ (enumerate, null, __call__ (eVals.tolist, eVals)), __kwargtrans__ ({key: (function __lambda__ (elem) { 18 | return __neg__ (__add__ (__getitem__ (elem, 1).real, __truediv__ (__getitem__ (elem, 1).imag, 1000))); 19 | })})); 20 | var indicesSorted = (function () { 21 | var __accu0__ = []; 22 | var __iterable1__ = enumSorted; 23 | for (var __index1__ = 0; __index1__ < len (__iterable1__); __index1__++) { 24 | var elem = __getitem__ (__iterable1__, __index1__); 25 | __call__ (__accu0__.append, __accu0__, __getitem__ (elem, 0)); 26 | } 27 | return __accu0__; 28 | }) (); 29 | var eValsSorted = (function () { 30 | var __accu0__ = []; 31 | var __iterable1__ = enumSorted; 32 | for (var __index1__ = 0; __index1__ < len (__iterable1__); __index1__++) { 33 | var elem = __getitem__ (__iterable1__, __index1__); 34 | __call__ (__accu0__.append, __accu0__, __getitem__ (elem, 1)); 35 | } 36 | return __accu0__; 37 | }) (); 38 | var eValsMat = __call__ (num.empty, num, a.shape, a.dtype); 39 | for (var iRow = 0; iRow < __getitem__ (a.shape, 0); iRow++) { 40 | for (var iCol = 0; iCol < __getitem__ (a.shape, 1); iCol++) { 41 | eValsMat.__setitem__ ([iRow, iCol], __getitem__ (eVals, iCol)); 42 | } 43 | } 44 | var eVecsNorms = __call__ (num.empty, num, tuple ([__getitem__ (eVecs.shape, 1)]), a.dtype); 45 | for (var iNorm = 0; iNorm < __getitem__ (eVecsNorms.shape, 0); iNorm++) { 46 | __setitem__ (eVecsNorms, iNorm, __call__ (complex, null, __call__ (linalg.norm, linalg, eVecs.__getitem__ ([tuple ([0, null, 1]), iNorm])))); 47 | } 48 | var eVecsCanon = __call__ (num.empty, num, a.shape, a.dtype); 49 | for (var iRow = 0; iRow < __getitem__ (a.shape, 0); iRow++) { 50 | for (var iCol = 0; iCol < __getitem__ (a.shape, 1); iCol++) { 51 | eVecsCanon.__setitem__ ([iRow, iCol], __truediv__ (eVecs.__getitem__ ([iRow, iCol]), eVecs.__getitem__ ([0, iCol]))); 52 | } 53 | } 54 | var eVecsSorted = __call__ (num.empty, num, a.shape, a.dtype); 55 | for (var iRow = 0; iRow < __getitem__ (a.shape, 0); iRow++) { 56 | for (var iCol = 0; iCol < __getitem__ (a.shape, 1); iCol++) { 57 | eVecsSorted.__setitem__ ([iRow, iCol], eVecsCanon.__getitem__ ([iRow, __getitem__ (indicesSorted, iCol)])); 58 | } 59 | } 60 | __call__ (show, null, '========================================='); 61 | __call__ (show, null, '\n---------------- eigVecsSorted ----------'); 62 | __call__ (show, null, (function () { 63 | var __accu0__ = []; 64 | var __iterable1__ = __call__ (eVecsSorted.tolist, eVecsSorted); 65 | for (var __index1__ = 0; __index1__ < len (__iterable1__); __index1__++) { 66 | var row = __getitem__ (__iterable1__, __index1__); 67 | __call__ (__accu0__.append, __accu0__, (function () { 68 | var __accu1__ = []; 69 | var __iterable2__ = row; 70 | for (var __index2__ = 0; __index2__ < len (__iterable2__); __index2__++) { 71 | var value = __getitem__ (__iterable2__, __index2__); 72 | __call__ (__accu1__.append, __accu1__, tuple ([__call__ (round, null, __add__ (value.real, 1e-10), 3), __call__ (round, null, __add__ (value.imag, 1e-10), 3)])); 73 | } 74 | return __accu1__; 75 | }) ()); 76 | } 77 | return __accu0__; 78 | }) ()); 79 | __call__ (show, null, '\n---------------- eigValsSorted ----------'); 80 | __call__ (show, null, (function () { 81 | var __accu0__ = []; 82 | var __iterable1__ = eValsSorted; 83 | for (var __index1__ = 0; __index1__ < len (__iterable1__); __index1__++) { 84 | var value = __getitem__ (__iterable1__, __index1__); 85 | __call__ (__accu0__.append, __accu0__, tuple ([__call__ (round, null, __add__ (value.real, 1e-10), 3), __call__ (round, null, __add__ (value.imag, 1e-10), 3)])); 86 | } 87 | return __accu0__; 88 | }) (), '\n'); 89 | __call__ (show, null, '========================================='); 90 | } 91 | __pragma__ ('' + 92 | 'numscrypt' + 93 | 'numscrypt.linalg' + 94 | '') 95 | __pragma__ ('') 96 | __all__.__name__ = __name__; 97 | __all__.a = a; 98 | __all__.eVals = eVals; 99 | __all__.eValsMat = eValsMat; 100 | __all__.eValsSorted = eValsSorted; 101 | __all__.eVecs = eVecs; 102 | __all__.eVecsCanon = eVecsCanon; 103 | __all__.eVecsNorms = eVecsNorms; 104 | __all__.eVecsSorted = eVecsSorted; 105 | __all__.enumSorted = enumSorted; 106 | __all__.iCol = iCol; 107 | __all__.iNorm = iNorm; 108 | __all__.iRow = iRow; 109 | __all__.indicesSorted = indicesSorted; 110 | __all__.show = show; 111 | __pragma__ ('') 112 | }) (); 113 | -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/numpy_eig/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | 15 |
16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/numpy_eig/test.min.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 13 | 14 | 15 |
16 |
17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/numpy_eig/test.py: -------------------------------------------------------------------------------- 1 | from org.transcrypt.stubs.browser import * 2 | from org.transcrypt.stubs.browser import __main__, __envir__, __pragma__ 3 | 4 | # Imports for Transcrypt, resolved run time 5 | if __envir__.executor_name == __envir__.transpiler_name: 6 | import numscrypt as num 7 | import numscrypt.linalg as linalg 8 | 9 | # Imports for CPython, resolved compile time 10 | __pragma__ ('skip') 11 | import numpy as num 12 | import numpy.linalg as linalg 13 | num.set_printoptions (linewidth = 240) 14 | __pragma__ ('noskip') 15 | 16 | __pragma__ ('opov') 17 | 18 | def show (*args): 19 | print (*args) 20 | 21 | for a in ( 22 | num.array ([ 23 | [0, 1j], 24 | [-1j, 1] 25 | ], 'complex128'), 26 | num.array ([ 27 | [1, -2, 3, 1], 28 | [5, 8, -1, -5], 29 | [2, 1, 1, 100], 30 | [2, 1, -1, 0] 31 | ], 'complex128'), 32 | num.array ([ 33 | [1, 1, 0, 0], 34 | [0, 2, 2, 0], 35 | [0, 0, 3, 3], 36 | [0, 0, 0, 4] 37 | ], 'complex128'), 38 | ) [1:2]: 39 | eVals, eVecs = linalg.eig (a) 40 | 41 | enumSorted = sorted ( 42 | enumerate (eVals.tolist ()), 43 | key = lambda elem: -(elem [1].real + elem [1].imag / 1000) # Order on primarily on real, secundarily on imag, note conjugate vals 44 | ) 45 | 46 | indicesSorted = [elem [0] for elem in enumSorted] 47 | eValsSorted = [elem [1] for elem in enumSorted] 48 | 49 | eValsMat = num.empty (a.shape, a.dtype) 50 | for iRow in range (a.shape [0]): 51 | for iCol in range (a.shape [1]): 52 | eValsMat [iRow, iCol] = eVals [iCol] 53 | 54 | eVecsNorms = num.empty ((eVecs.shape [1], ), a.dtype) 55 | for iNorm in range (eVecsNorms.shape [0]): 56 | eVecsNorms [iNorm] = complex (linalg.norm (eVecs [:, iNorm])) 57 | 58 | eVecsCanon = num.empty (a.shape, a.dtype) 59 | for iRow in range (a.shape [0]): 60 | for iCol in range (a.shape [1]): 61 | eVecsCanon [iRow, iCol] = eVecs [iRow, iCol] / eVecs [0, iCol] 62 | 63 | eVecsSorted = num.empty (a.shape, a.dtype) 64 | for iRow in range (a.shape [0]): 65 | for iCol in range (a.shape [1]): 66 | eVecsSorted [iRow, iCol] = eVecsCanon [iRow, indicesSorted [iCol]] 67 | 68 | show ( '=========================================') 69 | ''' 70 | show ('\n---------------- a ----------------------') 71 | show (a) 72 | show ('\n---------------- eigVals ----------------') 73 | show (eVals) 74 | show ('\n---------------- eigValsMat--------------') 75 | show (eValsMat) 76 | show ('\n---------------- eigVecs ----------------') 77 | show (eVecs) 78 | show ('\n---------------- eigValsMat @ eigVecs ---') 79 | show (eValsMat * eVecs) 80 | show ('\n---------------- a @ eigVecs-------------') 81 | show (a @ eVecs) 82 | show ('\n---------------- eigVecsNorms -----------') 83 | show (eVecsNorms) 84 | show ('\n---------------- eigVecsCanon -----------') 85 | show (eVecsCanon) 86 | ''' 87 | show ('\n---------------- eigVecsSorted ----------') 88 | show ([[(round (value.real + 1e-10, 3), round (value.imag + 1e-10, 3)) for value in row] for row in eVecsSorted.tolist ()]) 89 | show ('\n---------------- eigValsSorted ----------') 90 | show ([(round (value.real + 1e-10, 3), round (value.imag + 1e-10, 3)) for value in eValsSorted], '\n') 91 | show ( '=========================================') 92 | 93 | -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/numpy_eig/testmp.py: -------------------------------------------------------------------------------- 1 | from mpmath import * 2 | 3 | a = matrix ([ 4 | [1, 1j], 5 | [-1j, 1] 6 | ], 'complex128') 7 | 8 | w, v = eig (a) 9 | 10 | 11 | print (w) 12 | print ('111----') 13 | print (v) 14 | print () 15 | print () 16 | 17 | 18 | ''' 19 | a = matrix ([ 20 | [1, -2, 3, 1], 21 | [5, 8, -1, -5], 22 | [2, 1, 1, 100], 23 | [2, 1, -1, 0] 24 | ], 'complex128') 25 | 26 | w, v = eig (a) 27 | 28 | print (w) 29 | print ('222----') 30 | print (v) 31 | print () 32 | ''' -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/slicing_optimization/__javascript__/test.mod.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | var random = {}; 3 | var __name__ = '__main__'; 4 | var num = __init__ (__world__.numscrypt); 5 | var num_rand = __init__ (__world__.numscrypt.random); 6 | var linalg = __init__ (__world__.numscrypt.linalg); 7 | __nest__ (random, '', __init__ (__world__.random)); 8 | var result = ''; 9 | for (var useComplex of tuple ([false, true])) { 10 | for (var transpose of tuple ([false, true])) { 11 | if (useComplex) { 12 | var a = num.array ((function () { 13 | var __accu0__ = []; 14 | for (var iRow = 0; iRow < 30; iRow++) { 15 | __accu0__.append ((function () { 16 | var __accu1__ = []; 17 | for (var iCol = 0; iCol < 30; iCol++) { 18 | __accu1__.append (complex (random.random (), random.random ())); 19 | } 20 | return __accu1__; 21 | }) ()); 22 | } 23 | return __accu0__; 24 | }) (), 'complex128'); 25 | } 26 | else { 27 | var a = num_rand.rand (30, 30); 28 | } 29 | var timeStartTranspose = new Date (); 30 | if (transpose) { 31 | var a = a.transpose (); 32 | } 33 | var timeStartInv = new Date (); 34 | var ai = linalg.inv (a); 35 | var timeStartMul = new Date (); 36 | var id = __matmul__ (a, ai); 37 | var timeStartScalp = new Date (); 38 | var sp = __mul__ (a, a); 39 | var timeStartDiv = new Date (); 40 | var sp = __truediv__ (a, a); 41 | var timeStartAdd = new Date (); 42 | var sp = __add__ (a, a); 43 | var timeStartSub = new Date (); 44 | var sp = __sub__ (a, a); 45 | var timeStartEig = new Date (); 46 | if (useComplex) { 47 | var __left0__ = linalg.eig (a.__getitem__ ([tuple ([0, 10, 1]), tuple ([0, 10, 1])])); 48 | var evals = __left0__ [0]; 49 | var evecs = __left0__ [1]; 50 | } 51 | var timeEnd = new Date (); 52 | result += '\n
\na @ ai [0:5, 0:5] =\n\n{}\n'.format (str (num.round (id.__getitem__ ([tuple ([0, 5, 1]), tuple ([0, 5, 1])]), 2)).py_replace (' ', '\t'));
53 | 				if (transpose) {
54 | 					result += '\nTranspose took: {} ms'.format (timeStartInv - timeStartTranspose);
55 | 				}
56 | 				result += '\nInverse took: {} ms\nMatrix product (@) took: {} ms\nElementwise product (*) took: {} ms\nDivision took: {} ms\nAddition took: {} ms\nSubtraction took: {} ms\nEigenvals/vecs took: {} ms\n
\n'.format (timeStartMul - timeStartInv, timeStartScalp - timeStartMul, timeStartDiv - timeStartScalp, timeStartAdd - timeStartDiv, timeStartSub - timeStartAdd, timeStartEig - timeStartSub, (useComplex ? timeEnd - timeStartEig : 'N.A.')); 57 | } 58 | } 59 | document.getElementById ('result').innerHTML = result; 60 | __pragma__ ('' + 61 | 'numscrypt' + 62 | 'numscrypt.linalg' + 63 | 'numscrypt.random' + 64 | 'random' + 65 | '') 66 | __pragma__ ('') 67 | __all__.__name__ = __name__; 68 | __all__.a = a; 69 | __all__.ai = ai; 70 | __all__.evals = evals; 71 | __all__.evecs = evecs; 72 | __all__.id = id; 73 | __all__.result = result; 74 | __all__.sp = sp; 75 | __all__.timeEnd = timeEnd; 76 | __all__.timeStartAdd = timeStartAdd; 77 | __all__.timeStartDiv = timeStartDiv; 78 | __all__.timeStartEig = timeStartEig; 79 | __all__.timeStartInv = timeStartInv; 80 | __all__.timeStartMul = timeStartMul; 81 | __all__.timeStartScalp = timeStartScalp; 82 | __all__.timeStartSub = timeStartSub; 83 | __all__.timeStartTranspose = timeStartTranspose; 84 | __all__.transpose = transpose; 85 | __all__.useComplex = useComplex; 86 | __pragma__ ('') 87 | }) (); 88 | -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/slicing_optimization/test.html: -------------------------------------------------------------------------------- 1 |
Calculating...
2 | 3 | -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/slicing_optimization/test.min.html: -------------------------------------------------------------------------------- 1 |
Calculating...
2 | 3 | -------------------------------------------------------------------------------- /numscrypt/development/manual_tests/slicing_optimization/test.py: -------------------------------------------------------------------------------- 1 | from org.transcrypt.stubs.browser import * 2 | from org.transcrypt.stubs.browser import __pragma__ 3 | 4 | import numscrypt as num 5 | import numscrypt.random as num_rand 6 | import numscrypt.linalg as linalg 7 | import random 8 | 9 | result = '' 10 | 11 | for useComplex in (False, True): 12 | for transpose in (False, True): 13 | if useComplex: 14 | a = num.array ([ 15 | [complex (random.random (), random.random ()) for iCol in range (30)] 16 | for iRow in range (30) 17 | ], 'complex128') 18 | else: 19 | a = num_rand.rand (30, 30) 20 | 21 | timeStartTranspose = __new__ (Date ()) 22 | if transpose: 23 | a = a.transpose () 24 | 25 | timeStartInv = __new__ (Date ()) 26 | ai = linalg.inv (a) 27 | 28 | timeStartMul = __new__ (Date ()) 29 | __pragma__ ('opov') 30 | id = a @ ai 31 | __pragma__ ('noopov') 32 | 33 | timeStartScalp = __new__ (Date ()) 34 | __pragma__ ('opov') 35 | sp = a * a 36 | __pragma__ ('noopov') 37 | 38 | timeStartDiv = __new__ (Date ()) 39 | __pragma__ ('opov') 40 | sp = a / a 41 | __pragma__ ('noopov') 42 | 43 | timeStartAdd = __new__ (Date ()) 44 | __pragma__ ('opov') 45 | sp = a + a 46 | __pragma__ ('noopov') 47 | 48 | timeStartSub = __new__ (Date ()) 49 | __pragma__ ('opov') 50 | sp = a - a 51 | __pragma__ ('noopov') 52 | 53 | timeStartEig = __new__ (Date ()) 54 | if useComplex: 55 | evals, evecs = linalg.eig (a [:10, :10]) 56 | 57 | timeEnd = __new__ (Date ()) 58 | 59 | result += ( 60 | ''' 61 |
 62 | a @ ai [0:5, 0:5] =
 63 | 
 64 | {}
 65 | ''' 
 66 |         ) .format (
 67 |             str (num.round (id [0:5, 0:5], 2)) .replace (' ', '\t'),
 68 |         )
 69 | 
 70 |         if transpose:
 71 |             result += (
 72 | '''
 73 | Transpose took: {} ms'''
 74 |             ).format (
 75 |                 timeStartInv - timeStartTranspose
 76 |             )
 77 |             
 78 |         result += (
 79 | '''
 80 | Inverse took: {} ms
 81 | Matrix product (@) took: {} ms
 82 | Elementwise product (*) took: {} ms
 83 | Division took: {} ms
 84 | Addition took: {} ms
 85 | Subtraction took: {} ms
 86 | Eigenvals/vecs took: {} ms
 87 | 
88 | ''' 89 | ) .format ( 90 | timeStartMul - timeStartInv, 91 | timeStartScalp - timeStartMul, 92 | timeStartDiv - timeStartScalp, 93 | timeStartAdd - timeStartDiv, 94 | timeStartSub - timeStartAdd, 95 | timeStartEig - timeStartSub, 96 | timeEnd - timeStartEig if useComplex else 'N.A.' 97 | ) 98 | 99 | document.getElementById ('result') .innerHTML = result 100 | -------------------------------------------------------------------------------- /numscrypt/development/shipment/shipment_test.py: -------------------------------------------------------------------------------- 1 | import os 2 | import webbrowser 3 | 4 | os.system ('clear') 5 | 6 | shipDir = os.path.dirname (os.path.abspath (__file__)) .replace ('\\', '/') 7 | rootDir = '/'.join (shipDir.split ('/')[ : -2]) 8 | 9 | def getAbsPath (relPath): 10 | return '{}/{}'.format (rootDir, relPath) 11 | 12 | def test (relPath, fileNamePrefix, run = False): 13 | os.chdir (getAbsPath (relPath)) 14 | os.system ('ts -b -c -m {}{}.py'.format (fcallSwitch, fileNamePrefix)) 15 | 16 | if run: 17 | os.chdir (getAbsPath (relPath)) 18 | os.system ('ts -r {}.py'.format (fileNamePrefix)) 19 | 20 | # webbrowser.open ('file://{}/{}.html'.format (getAbsPath (relPath), fileNamePrefix), new = 2) 21 | # webbrowser.open ('file://{}/{}.min.html'.format (getAbsPath (relPath), fileNamePrefix), new = 2) # Obsolete? 22 | 23 | def autoTest (*args): 24 | test (*args, True) 25 | 26 | os.system ('py39 test_install.py') 27 | 28 | for fcallSwitch in (' ',): 29 | # for fcallSwitch in (' ', '-f '): # Outcommented to save testing time 30 | autoTest ('development/automated_tests/ndarray', 'autotest') 31 | # test ('development/manual_tests/slicing_optimization', 'test') 32 | 33 | if fcallSwitch: 34 | print ('Shipment test completed') 35 | else: 36 | input ('Close browser tabs opened by shipment test and press [enter] for fcall test') 37 | -------------------------------------------------------------------------------- /numscrypt/development/shipment/test_install.py: -------------------------------------------------------------------------------- 1 | import os 2 | import site 3 | 4 | sitepackagesDir = os.path.dirname (site.__file__) + '/site-packages' 5 | 6 | shipDir = os.path.dirname (os.path.abspath (__file__)) 7 | appRootDir = '/'.join (shipDir.split ('/')[ : -2]) 8 | distributionDir = '/'.join (appRootDir.split ('/')[ : -1]) 9 | 10 | ''' 11 | print () 12 | print (sitepackagesDir) 13 | print (shipDir) 14 | print (appRootDir) 15 | print (distributionDir) 16 | print () 17 | ''' 18 | 19 | def getAbsPath (rootDir, relPath): 20 | return '{}/{}'.format (rootDir, relPath) 21 | 22 | def copyCode (relPath): 23 | if '/' in relPath: 24 | relDir = '{}/'.format (relPath .rsplit ('/', 1) [0]) 25 | else: 26 | relDir = '' 27 | 28 | os.system ('cp -f {} {}'.format ( 29 | getAbsPath (appRootDir, relPath), 30 | getAbsPath (sitepackagesDir, 'numscrypt/{}'.format (relDir)) 31 | )) 32 | 33 | copyCode ('__init__.py') 34 | copyCode ('__base__.py') 35 | copyCode ('random.py') 36 | copyCode ('linalg/__init__.py') 37 | copyCode ('linalg/eigen_mpmath.py') 38 | copyCode ('fft/__init__.py') 39 | copyCode ('fft/__javascript__/fft_nayuki_precalc_fixed.js') 40 | -------------------------------------------------------------------------------- /numscrypt/development/shipment/upload_all.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | shipDir = os.path.dirname (os.path.abspath (__file__)) .replace ('\\', '/') 4 | appRootDir = '/'.join (shipDir.split ('/')[ : -2]) 5 | distributionDir = '/'.join (appRootDir.split ('/')[ : -1]) 6 | dynWebRootDir, statWebRootDir = eval (open ('upload_all.nogit') .read ()) 7 | sphinxDir = '/'.join ([appRootDir, 'docs/sphinx']) 8 | 9 | def getAbsPath (rootDir, relPath): 10 | return '{}/{}'.format (rootDir, relPath) 11 | 12 | def copyWebsite (projRelPath, webRelPath, static = False, subdirs = False): 13 | os.system ('xcopy /Y {} {} {}'.format ('/E' if subdirs else '', getAbsPath (appRootDir, projRelPath) .replace ('/', '\\'), getAbsPath (statWebRootDir if static else dynWebRootDir, webRelPath) .replace ('/', '\\'))) 14 | 15 | os.chdir (sphinxDir) 16 | os.system ('make html') 17 | copyWebsite ('docs/sphinx/_build/html', 'numscrypt/docs/html/', True, True) 18 | 19 | os.chdir (distributionDir) 20 | 21 | os.system ('uploadPython') 22 | 23 | os.system ('git add .') 24 | os.system ('git commit -m"{}"'.format (input ('Description of commit: '))) 25 | os.system ('git push origin master') 26 | 27 | os.chdir (shipDir) 28 | -------------------------------------------------------------------------------- /numscrypt/docs/Numscrypt.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /numscrypt/docs/images/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/images/Thumbs.db -------------------------------------------------------------------------------- /numscrypt/docs/images/abacus_square - Copy (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/images/abacus_square - Copy (2).png -------------------------------------------------------------------------------- /numscrypt/docs/images/abacus_square - Copy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/images/abacus_square - Copy.png -------------------------------------------------------------------------------- /numscrypt/docs/images/abacus_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/images/abacus_square.png -------------------------------------------------------------------------------- /numscrypt/docs/images/lin_alg_book.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/images/lin_alg_book.jpg -------------------------------------------------------------------------------- /numscrypt/docs/images/numscrypt_logo_sphinx.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 8 | 11 |
5 | 6 | Nμmscrλpt 7 |
9 | 10 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /numscrypt/docs/images/numscrypt_logo_sphinx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/images/numscrypt_logo_sphinx.png -------------------------------------------------------------------------------- /numscrypt/docs/images/numscrypt_logo_white.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 8 | 11 |
5 | 6 | Nμmscrλpt 7 |
9 | 10 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /numscrypt/docs/images/numscrypt_logo_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/images/numscrypt_logo_white.png -------------------------------------------------------------------------------- /numscrypt/docs/images/numscrypt_logo_white_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/images/numscrypt_logo_white_small.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext 18 | 19 | help: 20 | @echo "Please use \`make ' where is one of" 21 | @echo " html to make standalone HTML files" 22 | @echo " dirhtml to make HTML files named index.html in directories" 23 | @echo " singlehtml to make a single large HTML file" 24 | @echo " pickle to make pickle files" 25 | @echo " json to make JSON files" 26 | @echo " htmlhelp to make HTML files and a HTML help project" 27 | @echo " qthelp to make HTML files and a qthelp project" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 31 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 32 | @echo " text to make text files" 33 | @echo " man to make manual pages" 34 | @echo " texinfo to make Texinfo files" 35 | @echo " info to make Texinfo files and run them through makeinfo" 36 | @echo " gettext to make PO message catalogs" 37 | @echo " changes to make an overview of all changed/added/deprecated items" 38 | @echo " linkcheck to check all external links for integrity" 39 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 40 | 41 | clean: 42 | -rm -rf $(BUILDDIR)/* 43 | 44 | html: 45 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 48 | 49 | dirhtml: 50 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 51 | @echo 52 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 53 | 54 | singlehtml: 55 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 56 | @echo 57 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 58 | 59 | pickle: 60 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 61 | @echo 62 | @echo "Build finished; now you can process the pickle files." 63 | 64 | json: 65 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 66 | @echo 67 | @echo "Build finished; now you can process the JSON files." 68 | 69 | htmlhelp: 70 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 71 | @echo 72 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 73 | ".hhp project file in $(BUILDDIR)/htmlhelp." 74 | 75 | qthelp: 76 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 77 | @echo 78 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 79 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 80 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/Numscrypt.qhcp" 81 | @echo "To view the help file:" 82 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/Numscrypt.qhc" 83 | 84 | devhelp: 85 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 86 | @echo 87 | @echo "Build finished." 88 | @echo "To view the help file:" 89 | @echo "# mkdir -p $$HOME/.local/share/devhelp/Numscrypt" 90 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/Numscrypt" 91 | @echo "# devhelp" 92 | 93 | epub: 94 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 95 | @echo 96 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 97 | 98 | latex: 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 107 | @echo "Running LaTeX files through pdflatex..." 108 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 109 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 110 | 111 | text: 112 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 113 | @echo 114 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 115 | 116 | man: 117 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 118 | @echo 119 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 120 | 121 | texinfo: 122 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 123 | @echo 124 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 125 | @echo "Run \`make' in that directory to run these through makeinfo" \ 126 | "(use \`make info' here to do that automatically)." 127 | 128 | info: 129 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 130 | @echo "Running Texinfo files through makeinfo..." 131 | make -C $(BUILDDIR)/texinfo info 132 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 133 | 134 | gettext: 135 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 136 | @echo 137 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 138 | 139 | changes: 140 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 141 | @echo 142 | @echo "The overview file is in $(BUILDDIR)/changes." 143 | 144 | linkcheck: 145 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 146 | @echo 147 | @echo "Link check complete; look for any errors in the above output " \ 148 | "or in $(BUILDDIR)/linkcheck/output.txt." 149 | 150 | doctest: 151 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 152 | @echo "Testing of doctests in the sources finished, look at the " \ 153 | "results in $(BUILDDIR)/doctest/output.txt." 154 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/doctrees/autotest_suite.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/doctrees/autotest_suite.doctree -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/doctrees/autotesting_transcrypt.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/doctrees/autotesting_transcrypt.doctree -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/doctrees/environment.pickle -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/doctrees/index.doctree -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/doctrees/installation_use.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/doctrees/installation_use.doctree -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/doctrees/integration_javascript.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/doctrees/integration_javascript.doctree -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/doctrees/special_facilities.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/doctrees/special_facilities.doctree -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/doctrees/supported_constructs.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/doctrees/supported_constructs.doctree -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/doctrees/transcrypt_what_why.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/doctrees/transcrypt_what_why.doctree -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/doctrees/what_why.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/doctrees/what_why.doctree -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 687efe3cd3f3216a498a68a830c2ecd3 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_sources/index.rst.txt: -------------------------------------------------------------------------------- 1 | Welcome to Numscrypt's documentation! 2 | ====================================== 3 | 4 | Table of Contents: 5 | ------------------ 6 | 7 | .. toctree:: 8 | :numbered: 9 | :maxdepth: 2 10 | 11 | what_why 12 | installation_use 13 | supported_constructs 14 | 15 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_sources/index.txt: -------------------------------------------------------------------------------- 1 | Welcome to Numscrypt's documentation! 2 | ====================================== 3 | 4 | Table of Contents: 5 | ------------------ 6 | 7 | .. toctree:: 8 | :numbered: 9 | :maxdepth: 2 10 | 11 | what_why 12 | installation_use 13 | supported_constructs 14 | 15 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_sources/installation_use.rst.txt: -------------------------------------------------------------------------------- 1 | Getting started 2 | =============== 3 | 4 | Installation 5 | ------------ 6 | 7 | Numscrypt is currently tested under Windows, Linux and OSX. To install it, type: 8 | 9 | *pip install numscrypt* 10 | 11 | from the command prompt. This will also install Transcrypt if it's not yet there. 12 | 13 | You can test your installation as follows: 14 | 15 | 1. Go to directory *../Numscrypt-/numscrypt/development/automated_tests/ndarray* 16 | 2. From the command prompt run *transcrypt -b -c -m autotest.py*. This will compile the autotests into file *autotest.js* and put it into the *__javascript__* subdirectory. Do NOT go to that directory (there's no need, stay where you went at point 4) 17 | 3. From the command prompt run *transcrypt -r autotest.py*. This will run the autotests with CPython creating file *autotest.html* that refers to the generated *autotest.js* file 18 | 4. Load the autotest.html into your browser, e.g. by clicking on it (tests were done with Chrome). It will load *autotest.js*, run it and compare the output with what was generated by CPython. It should report no errors 19 | 20 | To experiment with Numscrypt yourself: 21 | 22 | 1. Create a directory for your experiments 23 | 2. Make your own thing there, e.g. *experiment1.py* 24 | 3. Compile with *transcrypt -b -c -m experiment1.py* (The -c is only needed if you use complex numbers) 25 | 4. Make an HTML page that will load your code in the browser. Use the HTML file generated by the autotest as an example of how to do that 26 | 5. Load the HTML and and run the JavaSCript 27 | 28 | Troubleshooting checklist 29 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 30 | 31 | 1. Problem installing NumPy. To be able to test back to back with CPython, NumPy has to be installed into Python 3.6. On Linux and OSX the simplest way to achieve this, is to use `miniconda `_. 32 | 2. Problem installing Numscrypt into the right version of Python. Numscrypt and Transcrypt require Python 3.6. To be certain that the right version of Python is picked for installation, on Windows install with: 33 | 34 | *python36 -m pip install Transcrypt* 35 | 36 | On Linux install with: 37 | 38 | *python3.6 -m pip install Transcrypt* 39 | 40 | Preferably use the miniconda installation of Python 3.6 as described earlier in this checklist. 41 | Use the --upgrade switch to upgrade rather than first-time install, as described in `pip's documentation `_. 42 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_sources/installation_use.txt: -------------------------------------------------------------------------------- 1 | Getting started 2 | =============== 3 | 4 | Installation 5 | ------------ 6 | 7 | Numscrypt is currently tested under Windows, Linux and OSX. To install it, type: 8 | 9 | *pip install numscrypt* 10 | 11 | from the command prompt. This will also install Transcrypt if it's not yet there. 12 | 13 | You can test your installation as follows: 14 | 15 | 1. Go to directory *../Numscrypt-/numscrypt/development/automated_tests/ndarray* 16 | 2. From the command prompt run *transcrypt -b -c -m autotest.py*. This will compile the autotests into file *autotest.js* and put it into the *__javascript__* subdirectory. Do NOT go to that directory (there's no need, stay where you went at point 4) 17 | 3. From the command prompt run *transcrypt -r autotest.py*. This will run the autotests with CPython creating file *autotest.html* that refers to the generated *autotest.js* file 18 | 4. Load the autotest.html into your browser, e.g. by clicking on it (tests were done with Chrome). It will load *autotest.js*, run it and compare the output with what was generated by CPython. It should report no errors 19 | 20 | To experiment with Numscrypt yourself: 21 | 22 | 1. Create a directory for your experiments 23 | 2. Make your own thing there, e.g. *experiment1.py* 24 | 3. Compile with *transcrypt -b -c -m experiment1.py* (The -c is only needed if you use complex numbers) 25 | 4. Make an HTML page that will load your code in the browser. Use the HTML file generated by the autotest as an example of how to do that 26 | 5. Load the HTML and and run the JavaSCript 27 | 28 | Troubleshooting checklist 29 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 30 | 31 | 1. Problem installing NumPy. To be able to test back to back with CPython, NumPy has to be installed into Python 3.6. On Linux and OSX the simplest way to achieve this, is to use `miniconda `_. 32 | 2. Problem installing Numscrypt into the right version of Python. Numscrypt and Transcrypt require Python 3.6. To be certain that the right version of Python is picked for installation, on Windows install with: 33 | 34 | *python36 -m pip install Transcrypt* 35 | 36 | On Linux install with: 37 | 38 | *python3.6 -m pip install Transcrypt* 39 | 40 | Preferably use the miniconda installation of Python 3.6 as described earlier in this checklist. 41 | Use the --upgrade switch to upgrade rather than first-time install, as described in `pip's documentation `_. 42 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_sources/supported_constructs.rst.txt: -------------------------------------------------------------------------------- 1 | Currently available features 2 | ============================= 3 | 4 | Numscrypt currently supports: 5 | 6 | - ndarray with 7 | - one or two dimensions 8 | - dtype int32, float32, float64, complex32 and complex64 9 | - indexing 10 | - simple and extended slicing 11 | - astype 12 | - tolist 13 | - real 14 | - imag 15 | - __repr__ and __str__ 16 | - transpose 17 | - overloaded operators: * / + - @, mixing of ndarray and scalar expressions 18 | 19 | - empty, array, copy 20 | - hsplit, vsplit 21 | - hstack, vstack 22 | - zeros, ones, identity 23 | 24 | - linalg with 25 | - matrix inversion 26 | - eigenvalue / eigenvector decomposition 27 | 28 | - FFT with 29 | - FFT for 2^n complex samples 30 | - IFFT for 2^n complex samples 31 | - FFT2 for 2^n x 2^n complex samples 32 | - IFFT2 for 2^n x 2^n complex samples 33 | 34 | Note that all operations where the distinction between row vectors and column vectors matters, only work on ndarrays with two dimensions. 35 | Such operations are e.g. *@*, *hstack*, *vstack*, *hsplit* and *vsplit*. 36 | When used with these operations, a row vector should have shape *(1,n)* and a column vector should have shape *(n,1)*. 37 | Furthermore views and broadcasting are not supported. 38 | 39 | Systematic code examples: a guided tour of Numscrypt 40 | ===================================================== 41 | 42 | One ready-to-run code example is worth more than ten lengthy descriptions. The *autotest and demo suite*, that is part of the distribution, is a collection of sourcecode fragments called *testlets*. These testlets are used for automated regression testing of Numscrypt against NumPy. 43 | Since they systematically cover all the library constructs, they are also very effective as a learning tool. The testlets are arranged alphabetically by subject. 44 | 45 | .. literalinclude:: ../../development/automated_tests/ndarray/autotest.py 46 | :tab-width: 4 47 | :caption: Autotest: Numscrypt autotest demo suite 48 | 49 | Basics: creating and using arrays 50 | --------------------------------- 51 | 52 | .. literalinclude:: ../../development/automated_tests/ndarray/basics/__init__.py 53 | :tab-width: 4 54 | :caption: Testlet: basics 55 | 56 | Linalg: matrix inversion and eigen decomposition 57 | ------------------------------------------------ 58 | 59 | .. literalinclude:: ../../development/automated_tests/ndarray/module_linalg/__init__.py 60 | :tab-width: 4 61 | :caption: Testlet: module_linalg 62 | 63 | Fourier transform: FFT(2) and IFFT(2) for 2^n (x 2^n) samples, using complex arrays 64 | ----------------------------------------------------------------------------------- 65 | 66 | .. literalinclude:: ../../development/automated_tests/ndarray/module_fft/__init__.py 67 | :tab-width: 4 68 | :caption: Testlet: module_fft 69 | 70 | Some more examples: interactive tests 71 | ===================================== 72 | 73 | Benchmark 74 | --------- 75 | 76 | Performance of operations like *@* and *inv* 77 | 78 | .. literalinclude:: ../../development/manual_tests/slicing_optimization/test.py 79 | :tab-width: 4 80 | :caption: Benchmark: slicing_optimization 81 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_sources/supported_constructs.txt: -------------------------------------------------------------------------------- 1 | Currently available features 2 | ============================= 3 | 4 | Numscrypt currently supports: 5 | 6 | - ndarray with 7 | - one or two dimensions 8 | - dtype int32, float32, float64, complex32 and complex64 9 | - indexing 10 | - simple and extended slicing 11 | - astype 12 | - tolist 13 | - real 14 | - imag 15 | - __repr__ and __str__ 16 | - transpose 17 | - overloaded operators: * / + - @, mixing of ndarray and scalar expressions 18 | 19 | - empty, array, copy 20 | - hsplit, vsplit 21 | - hstack, vstack 22 | - zeros, ones, identity 23 | 24 | - linalg with 25 | - matrix inversion 26 | - eigenvalue / eigenvector decomposition 27 | 28 | - FFT with 29 | - FFT for 2^n complex samples 30 | - IFFT for 2^n complex samples 31 | - FFT2 for 2^n x 2^n complex samples 32 | - IFFT2 for 2^n x 2^n complex samples 33 | 34 | Systematic code examples: a guided tour of Numscrypt 35 | ===================================================== 36 | 37 | One ready-to-run code example is worth more than ten lengthy descriptions. The *autotest and demo suite*, that is part of the distribution, is a collection of sourcecode fragments called *testlets*. These testlets are used for automated regression testing of Numscrypt against NumPy. 38 | Since they systematically cover all the library constructs, they are also very effective as a learning tool. The testlets are arranged alphabetically by subject. 39 | 40 | .. literalinclude:: ../../development/automated_tests/ndarray/autotest.py 41 | :tab-width: 4 42 | :caption: Autotest: Numscrypt autotest demo suite 43 | 44 | Basics: creating and using arrays 45 | --------------------------------- 46 | 47 | .. literalinclude:: ../../development/automated_tests/ndarray/basics/__init__.py 48 | :tab-width: 4 49 | :caption: Testlet: basics 50 | 51 | Linalg: matrix inversion and eigen decomposition 52 | ------------------------------------------------ 53 | 54 | .. literalinclude:: ../../development/automated_tests/ndarray/module_linalg/__init__.py 55 | :tab-width: 4 56 | :caption: Testlet: module_linalg 57 | 58 | Fourier transform: FFT(2) and IFFT(2) for 2^n (x 2^n) samples, using complex arrays 59 | ----------------------------------------------------------------------------------- 60 | 61 | .. literalinclude:: ../../development/automated_tests/ndarray/module_fft/__init__.py 62 | :tab-width: 4 63 | :caption: Testlet: module_fft 64 | 65 | Some more examples: interactive tests 66 | ===================================== 67 | 68 | Benchmark 69 | --------- 70 | 71 | Performance of operations like *@* and *inv* 72 | 73 | .. literalinclude:: ../../development/manual_tests/slicing_optimization/test.py 74 | :tab-width: 4 75 | :caption: Benchmark: slicing_optimization 76 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_sources/what_why.rst.txt: -------------------------------------------------------------------------------- 1 | Numscrypt: what and why 2 | ======================== 3 | 4 | What is Numscrypt 5 | ----------------- 6 | 7 | Numscrypt is a port of a small but relevant part of NumPy to Transcrypt using JavaScript typed arrays. As with Transcrypt, the eventual goal is not to completely copy a desktop programming environment. Rather a lean and mean subset is sought that can still be very useful, e.g. for science demo's in the browser or for small to medium scale computations. Whereas NumPy often has multiple way to do things, Numscrypt focuses on one obvious way. The clearest example is the NumPy type *matrix* type, that is a specialization of *ndarray* with confusingly deviating use of some operators. In Transcrypt *matrix* is deliberately left out, to keep the code lean. 8 | 9 | While the first minor versions of Numscrypt fully supported views, strides, offsets and arrays of arbitrary dimension, this proved to be too slow when compiled to JavaScript. In pursuit a good balance between familiarity and efficiency, requirements with respect to Numpy compatibility have been relaxed. Arrays can only have one or two dimensions and are always stored in natural storage order per row. This means that views are not supported and slices are always copies, since that enables them to have natural storage order as well, enabling fast access. Despite the fact that they are used in some branches of physics, arrays with more than two dimensions are relatively rare. If they are needed, in most cases a one- or multi-dimensional list of 2D arrays will do just as well. 10 | 11 | The speed benefits gained from these simplifications are enormous when forced to compile to something like JavaScript rather than C++. With broad applicability in mind, not only is there a direct gain of execution speed by simplifying matters, but also the source code of Numscrypt is much simpler. This code simplicity increases the chance of future optimization using asm.js, simd.js or GPGPU. The newly introduced type annotations of Python may well facilitate introduction of such technologies in a robust manner. 12 | 13 | In Numscrypt, speed is generally favored over memory conservation. In computations like inversion, non-elementwise matrix multiplication, convolution and FFT, the ability to store very large arrays is pointless if computations are slow. So the choice for speed over memory conservation illustrates the fact that Numscrypt is meant for non-trivial computations on small to medium scale, rather than for data reshuffling on medium to large scale. 14 | 15 | Computing in a browser? 16 | ----------------------- 17 | 18 | At first Numscrypt was purely meant as a tool for education and demonstration. The fact that some serious numerical math libraries for JavaScript do exist, sometimes using weird tricks to mimic operator overloading, led to reconsideration. Although computing in JavaScript in a browser certainly restricts performance and scalabilty compared to computing in C++ on dedicated manycore hardware, this doesn't mean that there aren't many useful, serious applications. If, given the existence of several JavaScript math libraries, there appears to be a need for computing in the browser, why not enable doing so in a language that is familiar to scientists and technicians, and has decent solutions for e.g. operator overloading and slicing notation. The partial parity between Numscrypt and Numpy is another attractive aspect of this approach. 19 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_sources/what_why.txt: -------------------------------------------------------------------------------- 1 | Numscrypt: what and why 2 | ======================== 3 | 4 | What is Numscrypt 5 | ----------------- 6 | 7 | Numscrypt is a port of a small but relevant part of NumPy to Transcrypt using JavaScript typed arrays. As with Transcrypt, the eventual goal is not to completely copy a desktop programming environment. Rather a lean and mean subset is sought that can still be very useful, e.g. for science demo's in the browser or for small to medium scale computations. Whereas NumPy often has multiple way to do things, Numscrypt focuses on one obvious way. The clearest example is the NumPy type *matrix* type, that is a specialization of *ndarray* with confusingly deviating use of some operators. In Transcrypt *matrix* is deliberately left out, to keep the code lean. 8 | 9 | While the first minor versions of Numscrypt fully supported views, strides, offsets and arrays of arbitrary dimension, this proved to be too slow when compiled to JavaScript. In pursuit a good balance between familiarity and efficiency, requirements with respect to Numpy compatibility have been relaxed. Arrays can only have one or two dimensions and are always stored in natural storage order per row. This means that views are not supported and slices are always copies, since that enables them to have natural storage order as well, enabling fast access. Despite the fact that they are used in some branches of physics, arrays with more than two dimensions are relatively rare. If they are needed, in most cases a one- or multi-dimensional list of 2D arrays will do just as well. 10 | 11 | The speed benefits gained from these simplifications are enormous when forced to compile to something like JavaScript rather than C++. With broad applicability in mind, not only is there a direct gain of execution speed by simplifying matters, but also the source code of Numscrypt is much simpler. This code simplicity increases the chance of future optimization using asm.js, simd.js or GPGPU. The newly introduced type annotations of Python may well facilitate introduction of such technologies in a robust manner. 12 | 13 | In Numscrypt, speed is generally favored over memory conservation. In computations like inversion, non-elementwise matrix multiplication, convolution and FFT, the ability to store very large arrays is pointless if computations are slow. So the choice for speed over memory conservation illustrates the fact that Numscrypt is meant for non-trivial computations on small to medium scale, rather than for data reshuffling on medium to large scale. 14 | 15 | Computing in a browser? 16 | ----------------------- 17 | 18 | At first Numscrypt was purely meant as a tool for education and demonstration. The fact that some serious numerical math libraries for JavaScript do exist, sometimes using weird tricks to mimic operator overloading, led to reconsideration. Although computing in JavaScript in a browser certainly restricts performance and scalabilty compared to computing in C++ on dedicated manycore hardware, this doesn't mean that there aren't many useful, serious applications. If, given the existence of several JavaScript math libraries, there appears to be a need for computing in the browser, why not enable doing so in a language that is familiar to scientists and technicians, and has decent solutions for e.g. operator overloading and slicing notation. The partial parity between Numscrypt and Numpy is another attractive aspect of this approach. 19 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/Thumbs.db -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/ajax-loader.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/ajax-loader.gif -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/basic.css: -------------------------------------------------------------------------------- 1 | /* 2 | * basic.css 3 | * ~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- basic theme. 6 | * 7 | * :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /* -- main layout ----------------------------------------------------------- */ 13 | 14 | div.clearer { 15 | clear: both; 16 | } 17 | 18 | /* -- relbar ---------------------------------------------------------------- */ 19 | 20 | div.related { 21 | width: 100%; 22 | font-size: 90%; 23 | } 24 | 25 | div.related h3 { 26 | display: none; 27 | } 28 | 29 | div.related ul { 30 | margin: 0; 31 | padding: 0 0 0 10px; 32 | list-style: none; 33 | } 34 | 35 | div.related li { 36 | display: inline; 37 | } 38 | 39 | div.related li.right { 40 | float: right; 41 | margin-right: 5px; 42 | } 43 | 44 | /* -- sidebar --------------------------------------------------------------- */ 45 | 46 | div.sphinxsidebarwrapper { 47 | padding: 10px 5px 0 10px; 48 | } 49 | 50 | div.sphinxsidebar { 51 | float: left; 52 | width: 230px; 53 | margin-left: -100%; 54 | font-size: 90%; 55 | word-wrap: break-word; 56 | overflow-wrap : break-word; 57 | } 58 | 59 | div.sphinxsidebar ul { 60 | list-style: none; 61 | } 62 | 63 | div.sphinxsidebar ul ul, 64 | div.sphinxsidebar ul.want-points { 65 | margin-left: 20px; 66 | list-style: square; 67 | } 68 | 69 | div.sphinxsidebar ul ul { 70 | margin-top: 0; 71 | margin-bottom: 0; 72 | } 73 | 74 | div.sphinxsidebar form { 75 | margin-top: 10px; 76 | } 77 | 78 | div.sphinxsidebar input { 79 | border: 1px solid #98dbcc; 80 | font-family: sans-serif; 81 | font-size: 1em; 82 | } 83 | 84 | div.sphinxsidebar #searchbox input[type="text"] { 85 | width: 170px; 86 | } 87 | 88 | img { 89 | border: 0; 90 | max-width: 100%; 91 | } 92 | 93 | /* -- search page ----------------------------------------------------------- */ 94 | 95 | ul.search { 96 | margin: 10px 0 0 20px; 97 | padding: 0; 98 | } 99 | 100 | ul.search li { 101 | padding: 5px 0 5px 20px; 102 | background-image: url(file.png); 103 | background-repeat: no-repeat; 104 | background-position: 0 7px; 105 | } 106 | 107 | ul.search li a { 108 | font-weight: bold; 109 | } 110 | 111 | ul.search li div.context { 112 | color: #888; 113 | margin: 2px 0 0 30px; 114 | text-align: left; 115 | } 116 | 117 | ul.keywordmatches li.goodmatch a { 118 | font-weight: bold; 119 | } 120 | 121 | /* -- index page ------------------------------------------------------------ */ 122 | 123 | table.contentstable { 124 | width: 90%; 125 | margin-left: auto; 126 | margin-right: auto; 127 | } 128 | 129 | table.contentstable p.biglink { 130 | line-height: 150%; 131 | } 132 | 133 | a.biglink { 134 | font-size: 1.3em; 135 | } 136 | 137 | span.linkdescr { 138 | font-style: italic; 139 | padding-top: 5px; 140 | font-size: 90%; 141 | } 142 | 143 | /* -- general index --------------------------------------------------------- */ 144 | 145 | table.indextable { 146 | width: 100%; 147 | } 148 | 149 | table.indextable td { 150 | text-align: left; 151 | vertical-align: top; 152 | } 153 | 154 | table.indextable ul { 155 | margin-top: 0; 156 | margin-bottom: 0; 157 | list-style-type: none; 158 | } 159 | 160 | table.indextable > tbody > tr > td > ul { 161 | padding-left: 0em; 162 | } 163 | 164 | table.indextable tr.pcap { 165 | height: 10px; 166 | } 167 | 168 | table.indextable tr.cap { 169 | margin-top: 10px; 170 | background-color: #f2f2f2; 171 | } 172 | 173 | img.toggler { 174 | margin-right: 3px; 175 | margin-top: 3px; 176 | cursor: pointer; 177 | } 178 | 179 | div.modindex-jumpbox { 180 | border-top: 1px solid #ddd; 181 | border-bottom: 1px solid #ddd; 182 | margin: 1em 0 1em 0; 183 | padding: 0.4em; 184 | } 185 | 186 | div.genindex-jumpbox { 187 | border-top: 1px solid #ddd; 188 | border-bottom: 1px solid #ddd; 189 | margin: 1em 0 1em 0; 190 | padding: 0.4em; 191 | } 192 | 193 | /* -- domain module index --------------------------------------------------- */ 194 | 195 | table.modindextable td { 196 | padding: 2px; 197 | border-collapse: collapse; 198 | } 199 | 200 | /* -- general body styles --------------------------------------------------- */ 201 | 202 | div.body p, div.body dd, div.body li, div.body blockquote { 203 | -moz-hyphens: auto; 204 | -ms-hyphens: auto; 205 | -webkit-hyphens: auto; 206 | hyphens: auto; 207 | } 208 | 209 | a.headerlink { 210 | visibility: hidden; 211 | } 212 | 213 | h1:hover > a.headerlink, 214 | h2:hover > a.headerlink, 215 | h3:hover > a.headerlink, 216 | h4:hover > a.headerlink, 217 | h5:hover > a.headerlink, 218 | h6:hover > a.headerlink, 219 | dt:hover > a.headerlink, 220 | caption:hover > a.headerlink, 221 | p.caption:hover > a.headerlink, 222 | div.code-block-caption:hover > a.headerlink { 223 | visibility: visible; 224 | } 225 | 226 | div.body p.caption { 227 | text-align: inherit; 228 | } 229 | 230 | div.body td { 231 | text-align: left; 232 | } 233 | 234 | .first { 235 | margin-top: 0 !important; 236 | } 237 | 238 | p.rubric { 239 | margin-top: 30px; 240 | font-weight: bold; 241 | } 242 | 243 | img.align-left, .figure.align-left, object.align-left { 244 | clear: left; 245 | float: left; 246 | margin-right: 1em; 247 | } 248 | 249 | img.align-right, .figure.align-right, object.align-right { 250 | clear: right; 251 | float: right; 252 | margin-left: 1em; 253 | } 254 | 255 | img.align-center, .figure.align-center, object.align-center { 256 | display: block; 257 | margin-left: auto; 258 | margin-right: auto; 259 | } 260 | 261 | .align-left { 262 | text-align: left; 263 | } 264 | 265 | .align-center { 266 | text-align: center; 267 | } 268 | 269 | .align-right { 270 | text-align: right; 271 | } 272 | 273 | /* -- sidebars -------------------------------------------------------------- */ 274 | 275 | div.sidebar { 276 | margin: 0 0 0.5em 1em; 277 | border: 1px solid #ddb; 278 | padding: 7px 7px 0 7px; 279 | background-color: #ffe; 280 | width: 40%; 281 | float: right; 282 | } 283 | 284 | p.sidebar-title { 285 | font-weight: bold; 286 | } 287 | 288 | /* -- topics ---------------------------------------------------------------- */ 289 | 290 | div.topic { 291 | border: 1px solid #ccc; 292 | padding: 7px 7px 0 7px; 293 | margin: 10px 0 10px 0; 294 | } 295 | 296 | p.topic-title { 297 | font-size: 1.1em; 298 | font-weight: bold; 299 | margin-top: 10px; 300 | } 301 | 302 | /* -- admonitions ----------------------------------------------------------- */ 303 | 304 | div.admonition { 305 | margin-top: 10px; 306 | margin-bottom: 10px; 307 | padding: 7px; 308 | } 309 | 310 | div.admonition dt { 311 | font-weight: bold; 312 | } 313 | 314 | div.admonition dl { 315 | margin-bottom: 0; 316 | } 317 | 318 | p.admonition-title { 319 | margin: 0px 10px 5px 0px; 320 | font-weight: bold; 321 | } 322 | 323 | div.body p.centered { 324 | text-align: center; 325 | margin-top: 25px; 326 | } 327 | 328 | /* -- tables ---------------------------------------------------------------- */ 329 | 330 | table.docutils { 331 | border: 0; 332 | border-collapse: collapse; 333 | } 334 | 335 | table caption span.caption-number { 336 | font-style: italic; 337 | } 338 | 339 | table caption span.caption-text { 340 | } 341 | 342 | table.docutils td, table.docutils th { 343 | padding: 1px 8px 1px 5px; 344 | border-top: 0; 345 | border-left: 0; 346 | border-right: 0; 347 | border-bottom: 1px solid #aaa; 348 | } 349 | 350 | table.footnote td, table.footnote th { 351 | border: 0 !important; 352 | } 353 | 354 | th { 355 | text-align: left; 356 | padding-right: 5px; 357 | } 358 | 359 | table.citation { 360 | border-left: solid 1px gray; 361 | margin-left: 1px; 362 | } 363 | 364 | table.citation td { 365 | border-bottom: none; 366 | } 367 | 368 | /* -- figures --------------------------------------------------------------- */ 369 | 370 | div.figure { 371 | margin: 0.5em; 372 | padding: 0.5em; 373 | } 374 | 375 | div.figure p.caption { 376 | padding: 0.3em; 377 | } 378 | 379 | div.figure p.caption span.caption-number { 380 | font-style: italic; 381 | } 382 | 383 | div.figure p.caption span.caption-text { 384 | } 385 | 386 | /* -- field list styles ----------------------------------------------------- */ 387 | 388 | table.field-list td, table.field-list th { 389 | border: 0 !important; 390 | } 391 | 392 | .field-list ul { 393 | margin: 0; 394 | padding-left: 1em; 395 | } 396 | 397 | .field-list p { 398 | margin: 0; 399 | } 400 | 401 | .field-name { 402 | -moz-hyphens: manual; 403 | -ms-hyphens: manual; 404 | -webkit-hyphens: manual; 405 | hyphens: manual; 406 | } 407 | 408 | /* -- other body styles ----------------------------------------------------- */ 409 | 410 | ol.arabic { 411 | list-style: decimal; 412 | } 413 | 414 | ol.loweralpha { 415 | list-style: lower-alpha; 416 | } 417 | 418 | ol.upperalpha { 419 | list-style: upper-alpha; 420 | } 421 | 422 | ol.lowerroman { 423 | list-style: lower-roman; 424 | } 425 | 426 | ol.upperroman { 427 | list-style: upper-roman; 428 | } 429 | 430 | dl { 431 | margin-bottom: 15px; 432 | } 433 | 434 | dd p { 435 | margin-top: 0px; 436 | } 437 | 438 | dd ul, dd table { 439 | margin-bottom: 10px; 440 | } 441 | 442 | dd { 443 | margin-top: 3px; 444 | margin-bottom: 10px; 445 | margin-left: 30px; 446 | } 447 | 448 | dt:target, .highlighted { 449 | background-color: #fbe54e; 450 | } 451 | 452 | dl.glossary dt { 453 | font-weight: bold; 454 | font-size: 1.1em; 455 | } 456 | 457 | .optional { 458 | font-size: 1.3em; 459 | } 460 | 461 | .sig-paren { 462 | font-size: larger; 463 | } 464 | 465 | .versionmodified { 466 | font-style: italic; 467 | } 468 | 469 | .system-message { 470 | background-color: #fda; 471 | padding: 5px; 472 | border: 3px solid red; 473 | } 474 | 475 | .footnote:target { 476 | background-color: #ffa; 477 | } 478 | 479 | .line-block { 480 | display: block; 481 | margin-top: 1em; 482 | margin-bottom: 1em; 483 | } 484 | 485 | .line-block .line-block { 486 | margin-top: 0; 487 | margin-bottom: 0; 488 | margin-left: 1.5em; 489 | } 490 | 491 | .guilabel, .menuselection { 492 | font-family: sans-serif; 493 | } 494 | 495 | .accelerator { 496 | text-decoration: underline; 497 | } 498 | 499 | .classifier { 500 | font-style: oblique; 501 | } 502 | 503 | abbr, acronym { 504 | border-bottom: dotted 1px; 505 | cursor: help; 506 | } 507 | 508 | /* -- code displays --------------------------------------------------------- */ 509 | 510 | pre { 511 | overflow: auto; 512 | overflow-y: hidden; /* fixes display issues on Chrome browsers */ 513 | } 514 | 515 | span.pre { 516 | -moz-hyphens: none; 517 | -ms-hyphens: none; 518 | -webkit-hyphens: none; 519 | hyphens: none; 520 | } 521 | 522 | td.linenos pre { 523 | padding: 5px 0px; 524 | border: 0; 525 | background-color: transparent; 526 | color: #aaa; 527 | } 528 | 529 | table.highlighttable { 530 | margin-left: 0.5em; 531 | } 532 | 533 | table.highlighttable td { 534 | padding: 0 0.5em 0 0.5em; 535 | } 536 | 537 | div.code-block-caption { 538 | padding: 2px 5px; 539 | font-size: small; 540 | } 541 | 542 | div.code-block-caption code { 543 | background-color: transparent; 544 | } 545 | 546 | div.code-block-caption + div > div.highlight > pre { 547 | margin-top: 0; 548 | } 549 | 550 | div.code-block-caption span.caption-number { 551 | padding: 0.1em 0.3em; 552 | font-style: italic; 553 | } 554 | 555 | div.code-block-caption span.caption-text { 556 | } 557 | 558 | div.literal-block-wrapper { 559 | padding: 1em 1em 0; 560 | } 561 | 562 | div.literal-block-wrapper div.highlight { 563 | margin: 0; 564 | } 565 | 566 | code.descname { 567 | background-color: transparent; 568 | font-weight: bold; 569 | font-size: 1.2em; 570 | } 571 | 572 | code.descclassname { 573 | background-color: transparent; 574 | } 575 | 576 | code.xref, a code { 577 | background-color: transparent; 578 | font-weight: bold; 579 | } 580 | 581 | h1 code, h2 code, h3 code, h4 code, h5 code, h6 code { 582 | background-color: transparent; 583 | } 584 | 585 | .viewcode-link { 586 | float: right; 587 | } 588 | 589 | .viewcode-back { 590 | float: right; 591 | font-family: sans-serif; 592 | } 593 | 594 | div.viewcode-block:target { 595 | margin: -1px -10px; 596 | padding: 0 10px; 597 | } 598 | 599 | /* -- math display ---------------------------------------------------------- */ 600 | 601 | img.math { 602 | vertical-align: middle; 603 | } 604 | 605 | div.body div.math p { 606 | text-align: center; 607 | } 608 | 609 | span.eqno { 610 | float: right; 611 | } 612 | 613 | span.eqno a.headerlink { 614 | position: relative; 615 | left: 0px; 616 | z-index: 1; 617 | } 618 | 619 | div.math:hover a.headerlink { 620 | visibility: visible; 621 | } 622 | 623 | /* -- printout stylesheet --------------------------------------------------- */ 624 | 625 | @media print { 626 | div.document, 627 | div.documentwrapper, 628 | div.bodywrapper { 629 | margin: 0 !important; 630 | width: 100%; 631 | } 632 | 633 | div.sphinxsidebar, 634 | div.related, 635 | div.footer, 636 | #top-link { 637 | display: none; 638 | } 639 | } -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/classic.css: -------------------------------------------------------------------------------- 1 | /* 2 | * classic.css_t 3 | * ~~~~~~~~~~~~~ 4 | * 5 | * Sphinx stylesheet -- classic theme. 6 | * 7 | * :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | @import url("basic.css"); 13 | 14 | /* -- page layout ----------------------------------------------------------- */ 15 | 16 | body { 17 | font-family: sans-serif; 18 | font-size: 100%; 19 | background-color: #11303d; 20 | color: #000; 21 | margin: 0; 22 | padding: 0; 23 | } 24 | 25 | div.document { 26 | background-color: #1c4e63; 27 | } 28 | 29 | div.documentwrapper { 30 | float: left; 31 | width: 100%; 32 | } 33 | 34 | div.bodywrapper { 35 | margin: 0 0 0 230px; 36 | } 37 | 38 | div.body { 39 | background-color: #ffffff; 40 | color: #000000; 41 | padding: 0 20px 30px 20px; 42 | } 43 | 44 | div.footer { 45 | color: #ffffff; 46 | width: 100%; 47 | padding: 9px 0 9px 0; 48 | text-align: center; 49 | font-size: 75%; 50 | } 51 | 52 | div.footer a { 53 | color: #ffffff; 54 | text-decoration: underline; 55 | } 56 | 57 | div.related { 58 | background-color: #133f52; 59 | line-height: 30px; 60 | color: #ffffff; 61 | } 62 | 63 | div.related a { 64 | color: #ffffff; 65 | } 66 | 67 | div.sphinxsidebar { 68 | } 69 | 70 | div.sphinxsidebar h3 { 71 | font-family: 'Trebuchet MS', sans-serif; 72 | color: #ffffff; 73 | font-size: 1.4em; 74 | font-weight: normal; 75 | margin: 0; 76 | padding: 0; 77 | } 78 | 79 | div.sphinxsidebar h3 a { 80 | color: #ffffff; 81 | } 82 | 83 | div.sphinxsidebar h4 { 84 | font-family: 'Trebuchet MS', sans-serif; 85 | color: #ffffff; 86 | font-size: 1.3em; 87 | font-weight: normal; 88 | margin: 5px 0 0 0; 89 | padding: 0; 90 | } 91 | 92 | div.sphinxsidebar p { 93 | color: #ffffff; 94 | } 95 | 96 | div.sphinxsidebar p.topless { 97 | margin: 5px 10px 10px 10px; 98 | } 99 | 100 | div.sphinxsidebar ul { 101 | margin: 10px; 102 | padding: 0; 103 | color: #ffffff; 104 | } 105 | 106 | div.sphinxsidebar a { 107 | color: #98dbcc; 108 | } 109 | 110 | div.sphinxsidebar input { 111 | border: 1px solid #98dbcc; 112 | font-family: sans-serif; 113 | font-size: 1em; 114 | } 115 | 116 | 117 | 118 | /* -- hyperlink styles ------------------------------------------------------ */ 119 | 120 | a { 121 | color: #355f7c; 122 | text-decoration: none; 123 | } 124 | 125 | a:visited { 126 | color: #355f7c; 127 | text-decoration: none; 128 | } 129 | 130 | a:hover { 131 | text-decoration: underline; 132 | } 133 | 134 | 135 | 136 | /* -- body styles ----------------------------------------------------------- */ 137 | 138 | div.body h1, 139 | div.body h2, 140 | div.body h3, 141 | div.body h4, 142 | div.body h5, 143 | div.body h6 { 144 | font-family: 'Trebuchet MS', sans-serif; 145 | background-color: #f2f2f2; 146 | font-weight: normal; 147 | color: #20435c; 148 | border-bottom: 1px solid #ccc; 149 | margin: 20px -20px 10px -20px; 150 | padding: 3px 0 3px 10px; 151 | } 152 | 153 | div.body h1 { margin-top: 0; font-size: 200%; } 154 | div.body h2 { font-size: 160%; } 155 | div.body h3 { font-size: 140%; } 156 | div.body h4 { font-size: 120%; } 157 | div.body h5 { font-size: 110%; } 158 | div.body h6 { font-size: 100%; } 159 | 160 | a.headerlink { 161 | color: #c60f0f; 162 | font-size: 0.8em; 163 | padding: 0 4px 0 4px; 164 | text-decoration: none; 165 | } 166 | 167 | a.headerlink:hover { 168 | background-color: #c60f0f; 169 | color: white; 170 | } 171 | 172 | div.body p, div.body dd, div.body li, div.body blockquote { 173 | text-align: justify; 174 | line-height: 130%; 175 | } 176 | 177 | div.admonition p.admonition-title + p { 178 | display: inline; 179 | } 180 | 181 | div.admonition p { 182 | margin-bottom: 5px; 183 | } 184 | 185 | div.admonition pre { 186 | margin-bottom: 5px; 187 | } 188 | 189 | div.admonition ul, div.admonition ol { 190 | margin-bottom: 5px; 191 | } 192 | 193 | div.note { 194 | background-color: #eee; 195 | border: 1px solid #ccc; 196 | } 197 | 198 | div.seealso { 199 | background-color: #ffc; 200 | border: 1px solid #ff6; 201 | } 202 | 203 | div.topic { 204 | background-color: #eee; 205 | } 206 | 207 | div.warning { 208 | background-color: #ffe4e4; 209 | border: 1px solid #f66; 210 | } 211 | 212 | p.admonition-title { 213 | display: inline; 214 | } 215 | 216 | p.admonition-title:after { 217 | content: ":"; 218 | } 219 | 220 | pre { 221 | padding: 5px; 222 | background-color: #eeffcc; 223 | color: #333333; 224 | line-height: 120%; 225 | border: 1px solid #ac9; 226 | border-left: none; 227 | border-right: none; 228 | } 229 | 230 | code { 231 | background-color: #ecf0f3; 232 | padding: 0 1px 0 1px; 233 | font-size: 0.95em; 234 | } 235 | 236 | th { 237 | background-color: #ede; 238 | } 239 | 240 | .warning code { 241 | background: #efc2c2; 242 | } 243 | 244 | .note code { 245 | background: #d6d6d6; 246 | } 247 | 248 | .viewcode-back { 249 | font-family: sans-serif; 250 | } 251 | 252 | div.viewcode-block:target { 253 | background-color: #f4debf; 254 | border-top: 1px solid #ac9; 255 | border-bottom: 1px solid #ac9; 256 | } 257 | 258 | div.code-block-caption { 259 | color: #efefef; 260 | background-color: #1c4e63; 261 | } -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/comment-bright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/comment-bright.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/comment-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/comment-close.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/comment.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/default.css: -------------------------------------------------------------------------------- 1 | @import url("classic.css"); 2 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/doctools.js: -------------------------------------------------------------------------------- 1 | /* 2 | * doctools.js 3 | * ~~~~~~~~~~~ 4 | * 5 | * Sphinx JavaScript utilities for all documentation. 6 | * 7 | * :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. 8 | * :license: BSD, see LICENSE for details. 9 | * 10 | */ 11 | 12 | /** 13 | * select a different prefix for underscore 14 | */ 15 | $u = _.noConflict(); 16 | 17 | /** 18 | * make the code below compatible with browsers without 19 | * an installed firebug like debugger 20 | if (!window.console || !console.firebug) { 21 | var names = ["log", "debug", "info", "warn", "error", "assert", "dir", 22 | "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", 23 | "profile", "profileEnd"]; 24 | window.console = {}; 25 | for (var i = 0; i < names.length; ++i) 26 | window.console[names[i]] = function() {}; 27 | } 28 | */ 29 | 30 | /** 31 | * small helper function to urldecode strings 32 | */ 33 | jQuery.urldecode = function(x) { 34 | return decodeURIComponent(x).replace(/\+/g, ' '); 35 | }; 36 | 37 | /** 38 | * small helper function to urlencode strings 39 | */ 40 | jQuery.urlencode = encodeURIComponent; 41 | 42 | /** 43 | * This function returns the parsed url parameters of the 44 | * current request. Multiple values per key are supported, 45 | * it will always return arrays of strings for the value parts. 46 | */ 47 | jQuery.getQueryParameters = function(s) { 48 | if (typeof s == 'undefined') 49 | s = document.location.search; 50 | var parts = s.substr(s.indexOf('?') + 1).split('&'); 51 | var result = {}; 52 | for (var i = 0; i < parts.length; i++) { 53 | var tmp = parts[i].split('=', 2); 54 | var key = jQuery.urldecode(tmp[0]); 55 | var value = jQuery.urldecode(tmp[1]); 56 | if (key in result) 57 | result[key].push(value); 58 | else 59 | result[key] = [value]; 60 | } 61 | return result; 62 | }; 63 | 64 | /** 65 | * highlight a given string on a jquery object by wrapping it in 66 | * span elements with the given class name. 67 | */ 68 | jQuery.fn.highlightText = function(text, className) { 69 | function highlight(node) { 70 | if (node.nodeType == 3) { 71 | var val = node.nodeValue; 72 | var pos = val.toLowerCase().indexOf(text); 73 | if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) { 74 | var span = document.createElement("span"); 75 | span.className = className; 76 | span.appendChild(document.createTextNode(val.substr(pos, text.length))); 77 | node.parentNode.insertBefore(span, node.parentNode.insertBefore( 78 | document.createTextNode(val.substr(pos + text.length)), 79 | node.nextSibling)); 80 | node.nodeValue = val.substr(0, pos); 81 | } 82 | } 83 | else if (!jQuery(node).is("button, select, textarea")) { 84 | jQuery.each(node.childNodes, function() { 85 | highlight(this); 86 | }); 87 | } 88 | } 89 | return this.each(function() { 90 | highlight(this); 91 | }); 92 | }; 93 | 94 | /* 95 | * backward compatibility for jQuery.browser 96 | * This will be supported until firefox bug is fixed. 97 | */ 98 | if (!jQuery.browser) { 99 | jQuery.uaMatch = function(ua) { 100 | ua = ua.toLowerCase(); 101 | 102 | var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || 103 | /(webkit)[ \/]([\w.]+)/.exec(ua) || 104 | /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || 105 | /(msie) ([\w.]+)/.exec(ua) || 106 | ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || 107 | []; 108 | 109 | return { 110 | browser: match[ 1 ] || "", 111 | version: match[ 2 ] || "0" 112 | }; 113 | }; 114 | jQuery.browser = {}; 115 | jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; 116 | } 117 | 118 | /** 119 | * Small JavaScript module for the documentation. 120 | */ 121 | var Documentation = { 122 | 123 | init : function() { 124 | this.fixFirefoxAnchorBug(); 125 | this.highlightSearchWords(); 126 | this.initIndexTable(); 127 | 128 | }, 129 | 130 | /** 131 | * i18n support 132 | */ 133 | TRANSLATIONS : {}, 134 | PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; }, 135 | LOCALE : 'unknown', 136 | 137 | // gettext and ngettext don't access this so that the functions 138 | // can safely bound to a different name (_ = Documentation.gettext) 139 | gettext : function(string) { 140 | var translated = Documentation.TRANSLATIONS[string]; 141 | if (typeof translated == 'undefined') 142 | return string; 143 | return (typeof translated == 'string') ? translated : translated[0]; 144 | }, 145 | 146 | ngettext : function(singular, plural, n) { 147 | var translated = Documentation.TRANSLATIONS[singular]; 148 | if (typeof translated == 'undefined') 149 | return (n == 1) ? singular : plural; 150 | return translated[Documentation.PLURALEXPR(n)]; 151 | }, 152 | 153 | addTranslations : function(catalog) { 154 | for (var key in catalog.messages) 155 | this.TRANSLATIONS[key] = catalog.messages[key]; 156 | this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')'); 157 | this.LOCALE = catalog.locale; 158 | }, 159 | 160 | /** 161 | * add context elements like header anchor links 162 | */ 163 | addContextElements : function() { 164 | $('div[id] > :header:first').each(function() { 165 | $('\u00B6'). 166 | attr('href', '#' + this.id). 167 | attr('title', _('Permalink to this headline')). 168 | appendTo(this); 169 | }); 170 | $('dt[id]').each(function() { 171 | $('\u00B6'). 172 | attr('href', '#' + this.id). 173 | attr('title', _('Permalink to this definition')). 174 | appendTo(this); 175 | }); 176 | }, 177 | 178 | /** 179 | * workaround a firefox stupidity 180 | * see: https://bugzilla.mozilla.org/show_bug.cgi?id=645075 181 | */ 182 | fixFirefoxAnchorBug : function() { 183 | if (document.location.hash) 184 | window.setTimeout(function() { 185 | document.location.href += ''; 186 | }, 10); 187 | }, 188 | 189 | /** 190 | * highlight the search words provided in the url in the text 191 | */ 192 | highlightSearchWords : function() { 193 | var params = $.getQueryParameters(); 194 | var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : []; 195 | if (terms.length) { 196 | var body = $('div.body'); 197 | if (!body.length) { 198 | body = $('body'); 199 | } 200 | window.setTimeout(function() { 201 | $.each(terms, function() { 202 | body.highlightText(this.toLowerCase(), 'highlighted'); 203 | }); 204 | }, 10); 205 | $('') 207 | .appendTo($('#searchbox')); 208 | } 209 | }, 210 | 211 | /** 212 | * init the domain index toggle buttons 213 | */ 214 | initIndexTable : function() { 215 | var togglers = $('img.toggler').click(function() { 216 | var src = $(this).attr('src'); 217 | var idnum = $(this).attr('id').substr(7); 218 | $('tr.cg-' + idnum).toggle(); 219 | if (src.substr(-9) == 'minus.png') 220 | $(this).attr('src', src.substr(0, src.length-9) + 'plus.png'); 221 | else 222 | $(this).attr('src', src.substr(0, src.length-8) + 'minus.png'); 223 | }).css('display', ''); 224 | if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) { 225 | togglers.click(); 226 | } 227 | }, 228 | 229 | /** 230 | * helper function to hide the search marks again 231 | */ 232 | hideSearchWords : function() { 233 | $('#searchbox .highlight-link').fadeOut(300); 234 | $('span.highlighted').removeClass('highlighted'); 235 | }, 236 | 237 | /** 238 | * make the url absolute 239 | */ 240 | makeURL : function(relativeURL) { 241 | return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL; 242 | }, 243 | 244 | /** 245 | * get the current relative url 246 | */ 247 | getCurrentURL : function() { 248 | var path = document.location.pathname; 249 | var parts = path.split(/\//); 250 | $.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() { 251 | if (this == '..') 252 | parts.pop(); 253 | }); 254 | var url = parts.join('/'); 255 | return path.substring(url.lastIndexOf('/') + 1, path.length - 1); 256 | }, 257 | 258 | initOnKeyListeners: function() { 259 | $(document).keyup(function(event) { 260 | var activeElementType = document.activeElement.tagName; 261 | // don't navigate when in search box or textarea 262 | if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') { 263 | switch (event.keyCode) { 264 | case 37: // left 265 | var prevHref = $('link[rel="prev"]').prop('href'); 266 | if (prevHref) { 267 | window.location.href = prevHref; 268 | return false; 269 | } 270 | case 39: // right 271 | var nextHref = $('link[rel="next"]').prop('href'); 272 | if (nextHref) { 273 | window.location.href = nextHref; 274 | return false; 275 | } 276 | } 277 | } 278 | }); 279 | } 280 | }; 281 | 282 | // quick alias for translations 283 | _ = Documentation.gettext; 284 | 285 | $(document).ready(function() { 286 | Documentation.init(); 287 | }); -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/down-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/down-pressed.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/down.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/file.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/logo_sphinx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/logo_sphinx.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/minus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/minus.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/monk_transcribing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/monk_transcribing.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/numscrypt_logo_sphinx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/numscrypt_logo_sphinx.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/plus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/plus.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/pygments.css: -------------------------------------------------------------------------------- 1 | .highlight .hll { background-color: #ffffcc } 2 | .highlight { background: #eeffcc; } 3 | .highlight .c { color: #408090; font-style: italic } /* Comment */ 4 | .highlight .err { border: 1px solid #FF0000 } /* Error */ 5 | .highlight .k { color: #007020; font-weight: bold } /* Keyword */ 6 | .highlight .o { color: #666666 } /* Operator */ 7 | .highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */ 8 | .highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */ 9 | .highlight .cp { color: #007020 } /* Comment.Preproc */ 10 | .highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */ 11 | .highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */ 12 | .highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */ 13 | .highlight .gd { color: #A00000 } /* Generic.Deleted */ 14 | .highlight .ge { font-style: italic } /* Generic.Emph */ 15 | .highlight .gr { color: #FF0000 } /* Generic.Error */ 16 | .highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */ 17 | .highlight .gi { color: #00A000 } /* Generic.Inserted */ 18 | .highlight .go { color: #333333 } /* Generic.Output */ 19 | .highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */ 20 | .highlight .gs { font-weight: bold } /* Generic.Strong */ 21 | .highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ 22 | .highlight .gt { color: #0044DD } /* Generic.Traceback */ 23 | .highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */ 24 | .highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */ 25 | .highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */ 26 | .highlight .kp { color: #007020 } /* Keyword.Pseudo */ 27 | .highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */ 28 | .highlight .kt { color: #902000 } /* Keyword.Type */ 29 | .highlight .m { color: #208050 } /* Literal.Number */ 30 | .highlight .s { color: #4070a0 } /* Literal.String */ 31 | .highlight .na { color: #4070a0 } /* Name.Attribute */ 32 | .highlight .nb { color: #007020 } /* Name.Builtin */ 33 | .highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */ 34 | .highlight .no { color: #60add5 } /* Name.Constant */ 35 | .highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */ 36 | .highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */ 37 | .highlight .ne { color: #007020 } /* Name.Exception */ 38 | .highlight .nf { color: #06287e } /* Name.Function */ 39 | .highlight .nl { color: #002070; font-weight: bold } /* Name.Label */ 40 | .highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */ 41 | .highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */ 42 | .highlight .nv { color: #bb60d5 } /* Name.Variable */ 43 | .highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */ 44 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */ 45 | .highlight .mb { color: #208050 } /* Literal.Number.Bin */ 46 | .highlight .mf { color: #208050 } /* Literal.Number.Float */ 47 | .highlight .mh { color: #208050 } /* Literal.Number.Hex */ 48 | .highlight .mi { color: #208050 } /* Literal.Number.Integer */ 49 | .highlight .mo { color: #208050 } /* Literal.Number.Oct */ 50 | .highlight .sa { color: #4070a0 } /* Literal.String.Affix */ 51 | .highlight .sb { color: #4070a0 } /* Literal.String.Backtick */ 52 | .highlight .sc { color: #4070a0 } /* Literal.String.Char */ 53 | .highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */ 54 | .highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */ 55 | .highlight .s2 { color: #4070a0 } /* Literal.String.Double */ 56 | .highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */ 57 | .highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */ 58 | .highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */ 59 | .highlight .sx { color: #c65d09 } /* Literal.String.Other */ 60 | .highlight .sr { color: #235388 } /* Literal.String.Regex */ 61 | .highlight .s1 { color: #4070a0 } /* Literal.String.Single */ 62 | .highlight .ss { color: #517918 } /* Literal.String.Symbol */ 63 | .highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */ 64 | .highlight .fm { color: #06287e } /* Name.Function.Magic */ 65 | .highlight .vc { color: #bb60d5 } /* Name.Variable.Class */ 66 | .highlight .vg { color: #bb60d5 } /* Name.Variable.Global */ 67 | .highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */ 68 | .highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */ 69 | .highlight .il { color: #208050 } /* Literal.Number.Integer.Long */ -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/sidebar.js: -------------------------------------------------------------------------------- 1 | /* 2 | * sidebar.js 3 | * ~~~~~~~~~~ 4 | * 5 | * This script makes the Sphinx sidebar collapsible. 6 | * 7 | * .sphinxsidebar contains .sphinxsidebarwrapper. This script adds 8 | * in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton 9 | * used to collapse and expand the sidebar. 10 | * 11 | * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden 12 | * and the width of the sidebar and the margin-left of the document 13 | * are decreased. When the sidebar is expanded the opposite happens. 14 | * This script saves a per-browser/per-session cookie used to 15 | * remember the position of the sidebar among the pages. 16 | * Once the browser is closed the cookie is deleted and the position 17 | * reset to the default (expanded). 18 | * 19 | * :copyright: Copyright 2007-2017 by the Sphinx team, see AUTHORS. 20 | * :license: BSD, see LICENSE for details. 21 | * 22 | */ 23 | 24 | $(function() { 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | // global elements used by the functions. 34 | // the 'sidebarbutton' element is defined as global after its 35 | // creation, in the add_sidebar_button function 36 | var bodywrapper = $('.bodywrapper'); 37 | var sidebar = $('.sphinxsidebar'); 38 | var sidebarwrapper = $('.sphinxsidebarwrapper'); 39 | 40 | // for some reason, the document has no sidebar; do not run into errors 41 | if (!sidebar.length) return; 42 | 43 | // original margin-left of the bodywrapper and width of the sidebar 44 | // with the sidebar expanded 45 | var bw_margin_expanded = bodywrapper.css('margin-left'); 46 | var ssb_width_expanded = sidebar.width(); 47 | 48 | // margin-left of the bodywrapper and width of the sidebar 49 | // with the sidebar collapsed 50 | var bw_margin_collapsed = '.8em'; 51 | var ssb_width_collapsed = '.8em'; 52 | 53 | // colors used by the current theme 54 | var dark_color = $('.related').css('background-color'); 55 | var light_color = $('.document').css('background-color'); 56 | 57 | function sidebar_is_collapsed() { 58 | return sidebarwrapper.is(':not(:visible)'); 59 | } 60 | 61 | function toggle_sidebar() { 62 | if (sidebar_is_collapsed()) 63 | expand_sidebar(); 64 | else 65 | collapse_sidebar(); 66 | } 67 | 68 | function collapse_sidebar() { 69 | sidebarwrapper.hide(); 70 | sidebar.css('width', ssb_width_collapsed); 71 | bodywrapper.css('margin-left', bw_margin_collapsed); 72 | sidebarbutton.css({ 73 | 'margin-left': '0', 74 | 'height': bodywrapper.height() 75 | }); 76 | sidebarbutton.find('span').text('»'); 77 | sidebarbutton.attr('title', _('Expand sidebar')); 78 | document.cookie = 'sidebar=collapsed'; 79 | } 80 | 81 | function expand_sidebar() { 82 | bodywrapper.css('margin-left', bw_margin_expanded); 83 | sidebar.css('width', ssb_width_expanded); 84 | sidebarwrapper.show(); 85 | sidebarbutton.css({ 86 | 'margin-left': ssb_width_expanded-12, 87 | 'height': bodywrapper.height() 88 | }); 89 | sidebarbutton.find('span').text('«'); 90 | sidebarbutton.attr('title', _('Collapse sidebar')); 91 | document.cookie = 'sidebar=expanded'; 92 | } 93 | 94 | function add_sidebar_button() { 95 | sidebarwrapper.css({ 96 | 'float': 'left', 97 | 'margin-right': '0', 98 | 'width': ssb_width_expanded - 28 99 | }); 100 | // create the button 101 | sidebar.append( 102 | '
«
' 103 | ); 104 | var sidebarbutton = $('#sidebarbutton'); 105 | light_color = sidebarbutton.css('background-color'); 106 | // find the height of the viewport to center the '<<' in the page 107 | var viewport_height; 108 | if (window.innerHeight) 109 | viewport_height = window.innerHeight; 110 | else 111 | viewport_height = $(window).height(); 112 | sidebarbutton.find('span').css({ 113 | 'display': 'block', 114 | 'margin-top': (viewport_height - sidebar.position().top - 20) / 2 115 | }); 116 | 117 | sidebarbutton.click(toggle_sidebar); 118 | sidebarbutton.attr('title', _('Collapse sidebar')); 119 | sidebarbutton.css({ 120 | 'color': '#FFFFFF', 121 | 'border-left': '1px solid ' + dark_color, 122 | 'font-size': '1.2em', 123 | 'cursor': 'pointer', 124 | 'height': bodywrapper.height(), 125 | 'padding-top': '1px', 126 | 'margin-left': ssb_width_expanded - 12 127 | }); 128 | 129 | sidebarbutton.hover( 130 | function () { 131 | $(this).css('background-color', dark_color); 132 | }, 133 | function () { 134 | $(this).css('background-color', light_color); 135 | } 136 | ); 137 | } 138 | 139 | function set_position_from_cookie() { 140 | if (!document.cookie) 141 | return; 142 | var items = document.cookie.split(';'); 143 | for(var k=0; k2;a== 12 | null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= 13 | function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= 14 | e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= 15 | function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, 17 | c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}}; 24 | b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, 25 | 1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; 26 | b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; 27 | b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), 28 | function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ 29 | u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= 30 | function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= 31 | true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); 32 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/up-pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/up-pressed.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/_static/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/_static/up.png -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/genindex.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | Index — Numscrypt 0.0.40 documentation 11 | 12 | 13 | 14 | 15 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 41 | 42 |
43 |
44 |
45 |
46 | 47 | 48 |

Index

49 | 50 |
51 | 52 |
53 | 54 | 55 |
56 |
57 |
58 | 78 |
79 |
80 | 89 | 93 | 94 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | Welcome to Numscrypt’s documentation! — Numscrypt 0.0.40 documentation 10 | 11 | 12 | 13 | 14 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 44 | 45 |
46 | 85 | 120 |
121 |
122 | 134 | 138 | 139 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/installation_use.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 2. Getting started — Numscrypt 0.0.40 documentation 10 | 11 | 12 | 13 | 14 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 48 | 49 |
50 |
51 |
52 |
53 | 54 |
55 |

2. Getting started

56 |
57 |

2.1. Installation

58 |

Numscrypt is currently tested under Windows, Linux and OSX. To install it, type:

59 |

pip install numscrypt

60 |

from the command prompt. This will also install Transcrypt if it’s not yet there.

61 |

You can test your installation as follows:

62 |
    63 |
  1. Go to directory ../Numscrypt-<version>/numscrypt/development/automated_tests/ndarray
  2. 64 |
  3. From the command prompt run transcrypt -b -c -m autotest.py. This will compile the autotests into file autotest.js and put it into the __javascript__ subdirectory. Do NOT go to that directory (there’s no need, stay where you went at point 4)
  4. 65 |
  5. From the command prompt run transcrypt -r autotest.py. This will run the autotests with CPython creating file autotest.html that refers to the generated autotest.js file
  6. 66 |
  7. Load the autotest.html into your browser, e.g. by clicking on it (tests were done with Chrome). It will load autotest.js, run it and compare the output with what was generated by CPython. It should report no errors
  8. 67 |
68 |

To experiment with Numscrypt yourself:

69 |
    70 |
  1. Create a directory for your experiments
  2. 71 |
  3. Make your own thing there, e.g. experiment1.py
  4. 72 |
  5. Compile with transcrypt -b -c -m experiment1.py (The -c is only needed if you use complex numbers)
  6. 73 |
  7. Make an HTML page that will load your code in the browser. Use the HTML file generated by the autotest as an example of how to do that
  8. 74 |
  9. Load the HTML and and run the JavaSCript
  10. 75 |
76 |
77 |

2.1.1. Troubleshooting checklist

78 |
    79 |
  1. Problem installing NumPy. To be able to test back to back with CPython, NumPy has to be installed into Python 3.6. On Linux and OSX the simplest way to achieve this, is to use miniconda.

    80 |
  2. 81 |
  3. Problem installing Numscrypt into the right version of Python. Numscrypt and Transcrypt require Python 3.6. To be certain that the right version of Python is picked for installation, on Windows install with:

    82 |

    python36 -m pip install Transcrypt

    83 |

    On Linux install with:

    84 |

    python3.6 -m pip install Transcrypt

    85 |

    Preferably use the miniconda installation of Python 3.6 as described earlier in this checklist. 86 | Use the –upgrade switch to upgrade rather than first-time install, as described in pip’s documentation.

    87 |
  4. 88 |
89 |
90 |
91 |
92 | 93 | 94 |
95 |
96 |
97 | 138 |
139 |
140 | 155 | 159 | 160 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/objects.inv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/QQuick/zzz_Numscrypt/184344a6747c4c7ea2e1ac44f3c8036f5e6101ee/numscrypt/docs/sphinx/_build/html/objects.inv -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/search.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | Search — Numscrypt 0.0.40 documentation 10 | 11 | 12 | 13 | 14 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 48 | 49 |
50 |
51 |
52 |
53 | 54 |

Search

55 |
56 | 57 |

58 | Please activate JavaScript to enable the search 59 | functionality. 60 |

61 |
62 |

63 | From here you can search these documents. Enter your search 64 | words into the box below and click "search". Note that the search 65 | function will automatically search for all of the words. Pages 66 | containing fewer words won't appear in the result list. 67 |

68 |
69 | 70 | 71 | 72 |
73 | 74 |
75 | 76 |
77 | 78 |
79 |
80 |
81 | 88 |
89 |
90 | 99 | 103 | 104 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/searchindex.js: -------------------------------------------------------------------------------- 1 | Search.setIndex({docnames:["index","installation_use","supported_constructs","what_why"],envversion:53,filenames:["index.rst","installation_use.rst","supported_constructs.rst","what_why.rst"],objects:{},objnames:{},objtypes:{},terms:{"001j":2,"15j":2,"33j":2,"75j":2,"case":3,"import":2,"int":2,"new":2,"return":2,"switch":1,"true":2,"while":3,NOT:1,One:2,Ones:2,Such:2,The:[1,2,3],These:2,Use:1,With:3,__call__:2,__envir__:2,__javascript__:1,__main__:2,__new__:2,__pragma__:2,__repr__:2,__str__:2,abil:3,abl:1,access:3,achiev:1,add_3a:2,add_a3:2,addit:2,against:2,all:2,alphabet:2,also:[1,2,3],alt:2,although:3,alwai:3,annot:3,anoth:3,appear:3,applic:3,approach:3,arbitrari:3,aren:3,arrai:[0,3],arrang:2,asm:3,aspect:3,astyp:2,attract:3,autom:2,automated_test:1,autotest:[1,2],avail:0,avoid:2,back:1,balanc:3,basic:0,been:3,benchmark:0,benefit:3,between:[2,3],bp0:2,bp1:2,bp2:2,bp3:2,bp4:2,bp5:2,bp6:2,bp7:2,bpsl0:2,bpsl1:2,bpsl2:2,bpsl3:2,bpsl4:2,bpsl5:2,bpsl6:2,bpsl7:2,branch:3,broad:3,broadcast:2,browser:[0,1,2],bsl0:2,bsl1:2,bsl2:2,bsl3:2,bsl4:2,bsl5:2,bsl6:2,bsl7:2,call:2,can:[1,3],certain:1,certainli:3,chanc:3,check:2,choic:3,chrome:1,cid:2,clearest:3,click:1,code:[0,1,3],collect:2,column:2,columnvector:[],command:1,comp_a:2,comp_a_squar:2,comp_b:2,comp_b_squar:2,comp_c:2,comp_c_squar:2,comp_d_squar:2,comp_e_squar:2,comp_f_squar:2,compar:[1,3],compat:3,compil:[1,2,3],complet:3,complex128:2,complex32:2,complex64:2,complex:[0,1],comput:[0,2],confusingli:3,conjug:2,conserv:3,construct:2,convolut:3,copi:[2,3],cos:2,cover:2,cpython:[1,2],creat:[0,1],cs0:2,cs1:2,cti:2,cts0:2,cts1:2,cts2:2,current:[0,1],cut:2,data:3,date:2,decent:3,decomposit:0,dedic:3,def:2,deliber:3,delta:2,demo:[2,3],demonstr:3,describ:1,descript:2,desktop:3,despit:3,develop:1,deviat:3,dif:2,differ:2,dimens:[2,3],dimension:3,direct:3,directori:1,distinct:2,distribut:2,div_3a:2,div_a3:2,divis:2,document:[1,2],doesn:3,doing:3,done:[1,2],dot:2,dotproduct:2,ds0:2,ds1:2,ds2:2,ds3:2,dti:2,dts0:2,dts1:2,dtype:2,dysfunct:2,earlier:1,educ:3,effect:2,effici:3,eig:2,eigen:0,eigenv:2,eigenvalu:2,eigenvector:2,eigval:2,eigvalsmat:2,eigvalssort:2,eigvec:2,eigvecscanon:2,eigvecsnorm:2,eigvecssort:2,elem:2,elementwis:[2,3],els:2,empti:2,enabl:3,enorm:3,enumer:2,enumsort:2,environ:3,error:1,eval:2,evalsmat:2,evalssort:2,evec:2,evecscanon:2,evecsnorm:2,evecssort:2,eventu:3,exampl:[0,1,3],execut:3,executor_nam:2,exist:3,experi:1,experiment1:1,express:2,extend:2,facilit:3,fact:3,fals:2,familiar:3,fast:3,favor:3,fco:2,featur:0,fft2:2,fft:[0,3],file:1,first:[1,3],float32:2,float64:2,focus:3,follow:1,forc:3,format:2,fourier:0,fragment:2,freq:2,freqs2:2,frequenc:2,from:[1,2,3],fsampl:2,fsin:2,fulli:3,furthermor:2,futur:3,gain:3,gener:[1,3],get:0,getelementbyid:2,getnow:2,given:3,goal:3,good:3,gpgpu:3,guid:0,hardwar:3,has:[1,3],have:[2,3],how:1,hsplit:2,hstack:2,html:1,icol:2,icurr:2,ident:2,ifft2:2,ifft:0,illustr:3,imag:2,increas:3,index:2,indicessort:2,innerhtml:2,inorm:2,instal:0,int32:2,interact:0,introduc:3,introduct:3,inv:2,invers:[0,3],irow:2,isampl:2,javascript:[1,3],just:3,keep:3,kei:2,lambda:2,languag:3,larg:3,lean:3,learn:2,led:3,left:3,lengthi:2,librari:[2,3],like:[2,3],linalg:0,linewidth:2,linux:1,list:3,load:1,mai:3,make:1,mani:3,manner:3,manycor:3,math:[2,3],matrix:[0,3],matter:[2,3],mean:3,meant:3,medium:3,memori:3,mimic:3,mind:3,miniconda:1,minor:3,mix:2,module_fft:2,module_linalg:2,more:[0,3],most:3,much:3,mul_3a:2,mul_a3:2,multi:3,multipl:3,natur:3,ndarrai:[1,2,3],need:[1,3],neg_a:2,newli:3,non:3,noopov:2,norm:2,noskip:2,notat:3,note:2,num:2,num_rand:2,number:1,numer:3,numpi:[1,2,3],numscrypt:1,obviou:3,offset:3,often:3,old:2,one:[2,3],ones:2,onli:[1,2,3],oper:[2,3],opov:2,optim:3,order:[2,3],org:2,orig2:2,orig:2,origin:2,osx:1,out:3,output:1,over:3,overload:[2,3],own:1,page:1,pariti:3,part:[2,3],partial:3,per:3,perform:[2,3],permut:2,physic:3,pick:1,pip:1,point:1,pointless:3,port:3,pre:2,prefer:1,primarili:2,print:2,problem:1,prod:2,product:2,program:3,prompt:1,prove:3,pure:3,pursuit:3,put:1,python36:1,python3:1,python:[1,3],quot:2,quotient:2,rand:2,random:2,rang:2,rare:3,rather:[1,3],readi:2,real:2,reconsider:3,reconstr2:2,reconstr:2,reconstruct:2,refer:1,regress:2,rel:3,relax:3,relev:3,replac:2,report:1,requir:[1,3],reshuffl:3,respect:3,restrict:3,result:2,rid:2,right:1,robust:3,round:2,row:[2,3],run:[1,2],runtim:2,sampl:0,scalabilti:3,scalar:2,scale:3,scienc:3,scientist:3,secundarili:2,seriou:3,set_printopt:2,sever:3,shape:2,should:[1,2],shown:2,simd:3,simpl:2,simpler:3,simplest:1,simplic:3,simplif:3,simplifi:3,sin:2,sinc:[2,3],size:2,skip:2,slice:[2,3],slice_a:2,slice_at:2,sliceable_a:2,sliceable_at:2,slicing_optim:2,slow:3,small:3,solut:3,some:[0,3],someth:3,sometim:3,sort:2,sought:3,sourc:3,sourcecod:2,special:3,speed:3,stai:1,start:0,still:3,storag:3,store:3,str:2,stride:3,stub:2,sub_3a:2,sub_a3:2,subdirectori:1,subject:2,subset:3,subtract:2,suit:2,sum:2,support:[2,3],systemat:0,tcurrent:2,technician:3,technolog:3,ten:2,test:[0,1],testlet:2,than:[1,2,3],thei:[2,3],them:3,thi:[1,3],thing:[1,3],time:[1,2],timeend:2,timestartadd:2,timestartdiv:2,timestarteig:2,timestartfft:2,timestartifft:2,timestartinv:2,timestartmul:2,timestartscalp:2,timestartsub:2,timestarttranspos:2,timestopfft:2,timestopifft:2,tolist:2,too:3,took:2,tool:[2,3],tour:0,transcrypt:[1,2,3],transform:0,transpil:2,transpiler_nam:2,transpos:2,trick:3,trivial:3,ttotal:2,tupl:2,two:[2,3],type:[1,3],under:1,upgrad:1,use:[1,3],usecomplex:2,used:[2,3],useful:3,using:[0,3],val:2,valu:2,vec:2,vector:2,vel:2,veri:[2,3],version:[1,3],view:[2,3],vsplit:2,vstack:2,vsum:2,wai:[1,3],weird:3,well:3,went:1,were:1,what:[0,1],when:[2,3],where:[1,2],wherea:3,which:2,why:0,window:1,work:2,worth:2,would:2,yet:1,you:1,your:1,yourself:1,zero:2},titles:["Welcome to Numscrypt\u2019s documentation!","2. Getting started","3. Currently available features","1. Numscrypt: what and why"],titleterms:{arrai:2,avail:2,basic:2,benchmark:2,browser:3,checklist:1,code:2,complex:2,comput:3,content:0,creat:2,current:2,decomposit:2,document:0,eigen:2,exampl:2,featur:2,fft:2,fourier:2,get:1,guid:2,ifft:2,instal:1,interact:2,invers:2,linalg:2,matrix:2,more:2,numscrypt:[0,2,3],sampl:2,some:2,start:1,systemat:2,tabl:0,test:2,tour:2,transform:2,troubleshoot:1,using:2,welcom:0,what:3,why:3}}) -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_build/html/what_why.html: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 1. Numscrypt: what and why — Numscrypt 0.0.40 documentation 10 | 11 | 12 | 13 | 14 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 48 | 49 |
50 |
51 |
52 |
53 | 54 |
55 |

1. Numscrypt: what and why

56 |
57 |

1.1. What is Numscrypt

58 |

Numscrypt is a port of a small but relevant part of NumPy to Transcrypt using JavaScript typed arrays. As with Transcrypt, the eventual goal is not to completely copy a desktop programming environment. Rather a lean and mean subset is sought that can still be very useful, e.g. for science demo’s in the browser or for small to medium scale computations. Whereas NumPy often has multiple way to do things, Numscrypt focuses on one obvious way. The clearest example is the NumPy type matrix type, that is a specialization of ndarray with confusingly deviating use of some operators. In Transcrypt matrix is deliberately left out, to keep the code lean.

59 |

While the first minor versions of Numscrypt fully supported views, strides, offsets and arrays of arbitrary dimension, this proved to be too slow when compiled to JavaScript. In pursuit a good balance between familiarity and efficiency, requirements with respect to Numpy compatibility have been relaxed. Arrays can only have one or two dimensions and are always stored in natural storage order per row. This means that views are not supported and slices are always copies, since that enables them to have natural storage order as well, enabling fast access. Despite the fact that they are used in some branches of physics, arrays with more than two dimensions are relatively rare. If they are needed, in most cases a one- or multi-dimensional list of 2D arrays will do just as well.

60 |

The speed benefits gained from these simplifications are enormous when forced to compile to something like JavaScript rather than C++. With broad applicability in mind, not only is there a direct gain of execution speed by simplifying matters, but also the source code of Numscrypt is much simpler. This code simplicity increases the chance of future optimization using asm.js, simd.js or GPGPU. The newly introduced type annotations of Python may well facilitate introduction of such technologies in a robust manner.

61 |

In Numscrypt, speed is generally favored over memory conservation. In computations like inversion, non-elementwise matrix multiplication, convolution and FFT, the ability to store very large arrays is pointless if computations are slow. So the choice for speed over memory conservation illustrates the fact that Numscrypt is meant for non-trivial computations on small to medium scale, rather than for data reshuffling on medium to large scale.

62 |
63 |
64 |

1.2. Computing in a browser?

65 |

At first Numscrypt was purely meant as a tool for education and demonstration. The fact that some serious numerical math libraries for JavaScript do exist, sometimes using weird tricks to mimic operator overloading, led to reconsideration. Although computing in JavaScript in a browser certainly restricts performance and scalabilty compared to computing in C++ on dedicated manycore hardware, this doesn’t mean that there aren’t many useful, serious applications. If, given the existence of several JavaScript math libraries, there appears to be a need for computing in the browser, why not enable doing so in a language that is familiar to scientists and technicians, and has decent solutions for e.g. operator overloading and slicing notation. The partial parity between Numscrypt and Numpy is another attractive aspect of this approach.

66 |
67 |
68 | 69 | 70 |
71 |
72 |
73 | 112 |
113 |
114 | 129 | 133 | 134 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_templates/globaltoc.html: -------------------------------------------------------------------------------- 1 | {# 2 | basic/globaltoc.html 3 | ~~~~~~~~~~~~~~~~~~~~ 4 | 5 | Sphinx sidebar template: global table of contents. 6 | 7 | :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | #} 10 |

{{ _('Subjects') }}

11 | {{ toctree() }} 12 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/_templates/localtoc.html: -------------------------------------------------------------------------------- 1 | {# 2 | basic/localtoc.html 3 | ~~~~~~~~~~~~~~~~~~~ 4 | 5 | Sphinx sidebar template: local table of contents. 6 | 7 | :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS. 8 | :license: BSD, see LICENSE for details. 9 | #} 10 | {%- if display_toc %} 11 |

{{ _('Subjects') }}

12 | {{ toc }} 13 | {%- endif %} 14 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/conf.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | sys.path.append ('../..') 4 | 5 | import __base__ 6 | 7 | # -*- coding: utf-8 -*- 8 | # 9 | # Transcrypt documentation build configuration file, created by 10 | # sphinx-quickstart on Sat Jan 09 20:57:48 2016. 11 | # 12 | # This file is execfile()d with the current directory set to its containing dir. 13 | # 14 | # Note that not all possible configuration values are present in this 15 | # autogenerated file. 16 | # 17 | # All configuration values have a default; values that are commented out 18 | # serve to show the default. 19 | 20 | import os 21 | 22 | # If extensions (or modules to document with autodoc) are in another directory, 23 | # add these directories to sys.path here. If the directory is relative to the 24 | # documentation root, use os.path.abspath to make it absolute, like shown here. 25 | #sys.path.insert(0, os.path.abspath('.')) 26 | 27 | # -- General configuration ----------------------------------------------------- 28 | 29 | # If your documentation needs a minimal Sphinx version, state it here. 30 | #needs_sphinx = '1.0' 31 | 32 | # Add any Sphinx extension module names here, as strings. They can be extensions 33 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 34 | extensions = [] 35 | 36 | # Add any paths that contain templates here, relative to this directory. 37 | templates_path = ['_templates'] 38 | 39 | # The suffix of source filenames. 40 | source_suffix = '.rst' 41 | 42 | # The encoding of source files. 43 | #source_encoding = 'utf-8-sig' 44 | 45 | # The master toctree document. 46 | master_doc = 'index' 47 | 48 | # General information about the project. 49 | project = u'Numscrypt' 50 | copyright = u'2016, Jacques de Hooge' 51 | 52 | # The version info for the project you're documenting, acts as replacement for 53 | # |version| and |release|, also used in various other places throughout the 54 | # built documents. 55 | # 56 | # The short X.Y version. 57 | version = __base__.ns_version 58 | # The full version, including alpha/beta/rc tags. 59 | release = version 60 | 61 | # The language for content autogenerated by Sphinx. Refer to documentation 62 | # for a list of supported languages. 63 | #language = None 64 | 65 | # There are two options for replacing |today|: either, you set today to some 66 | # non-false value, then it is used: 67 | #today = '' 68 | # Else, today_fmt is used as the format for a strftime call. 69 | #today_fmt = '%B %d, %Y' 70 | 71 | # List of patterns, relative to source directory, that match files and 72 | # directories to ignore when looking for source files. 73 | exclude_patterns = ['_build'] 74 | 75 | # The reST default role (used for this markup: `text`) to use for all documents. 76 | #default_role = None 77 | 78 | # If true, '()' will be appended to :func: etc. cross-reference text. 79 | #add_function_parentheses = True 80 | 81 | # If true, the current module name will be prepended to all description 82 | # unit titles (such as .. function::). 83 | #add_module_names = True 84 | 85 | # If true, sectionauthor and moduleauthor directives will be shown in the 86 | # output. They are ignored by default. 87 | #show_authors = False 88 | 89 | # The name of the Pygments (syntax highlighting) style to use. 90 | pygments_style = 'sphinx' 91 | 92 | # A list of ignored prefixes for module index sorting. 93 | #modindex_common_prefix = [] 94 | 95 | 96 | # -- Options for HTML output --------------------------------------------------- 97 | 98 | # The theme to use for HTML and HTML Help pages. See the documentation for 99 | # a list of builtin themes. 100 | html_theme = 'default' 101 | 102 | # Theme options are theme-specific and customize the look and feel of a theme 103 | # further. For a list of options available for each theme, see the 104 | # documentation. 105 | #html_theme_options = {} 106 | 107 | # Add any paths that contain custom themes here, relative to this directory. 108 | #html_theme_path = [] 109 | 110 | # The name for this set of Sphinx documents. If None, it defaults to 111 | # " v documentation". 112 | #html_title = None 113 | 114 | # A shorter title for the navigation bar. Default is the same as html_title. 115 | #html_short_title = None 116 | 117 | # The name of an image file (relative to this directory) to place at the top 118 | # of the sidebar. 119 | html_logo = '../images/numscrypt_logo_sphinx.png' 120 | 121 | # The name of an image file (within the static path) to use as favicon of the 122 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 123 | # pixels large. 124 | #html_favicon = None 125 | 126 | # Add any paths that contain custom static files (such as style sheets) here, 127 | # relative to this directory. They are copied after the builtin static files, 128 | # so a file named "default.css" will overwrite the builtin "default.css". 129 | html_static_path = ['_static'] 130 | 131 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 132 | # using the given strftime format. 133 | #html_last_updated_fmt = '%b %d, %Y' 134 | 135 | # If true, SmartyPants will be used to convert quotes and dashes to 136 | # typographically correct entities. 137 | #html_use_smartypants = True 138 | 139 | # Custom sidebar templates, maps document names to template names. 140 | #html_sidebars = {} 141 | 142 | # Additional templates that should be rendered to pages, maps page names to 143 | # template names. 144 | #html_additional_pages = {} 145 | 146 | # If false, no module index is generated. 147 | #html_domain_indices = True 148 | 149 | # If false, no index is generated. 150 | #html_use_index = True 151 | 152 | # If true, the index is split into individual pages for each letter. 153 | #html_split_index = False 154 | 155 | # If true, links to the reST sources are added to the pages. 156 | #html_show_sourcelink = True 157 | 158 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 159 | #html_show_sphinx = True 160 | 161 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 162 | #html_show_copyright = True 163 | 164 | # If true, an OpenSearch description file will be output, and all pages will 165 | # contain a tag referring to it. The value of this option must be the 166 | # base URL from which the finished HTML is served. 167 | #html_use_opensearch = '' 168 | 169 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 170 | #html_file_suffix = None 171 | 172 | # Output file base name for HTML help builder. 173 | htmlhelp_basename = 'Numscryptdoc' 174 | 175 | 176 | # -- Options for LaTeX output -------------------------------------------------- 177 | 178 | latex_elements = { 179 | # The paper size ('letterpaper' or 'a4paper'). 180 | #'papersize': 'letterpaper', 181 | 182 | # The font size ('10pt', '11pt' or '12pt'). 183 | #'pointsize': '10pt', 184 | 185 | # Additional stuff for the LaTeX preamble. 186 | #'preamble': '', 187 | } 188 | 189 | # Grouping the document tree into LaTeX files. List of tuples 190 | # (source start file, target name, title, author, documentclass [howto/manual]). 191 | latex_documents = [ 192 | ('index', 'Numscrypt.tex', u'Numscrypt Documentation', 193 | u'Jacques de Hooge', 'manual'), 194 | ] 195 | 196 | # The name of an image file (relative to this directory) to place at the top of 197 | # the title page. 198 | #latex_logo = None 199 | 200 | # For "manual" documents, if this is true, then toplevel headings are parts, 201 | # not chapters. 202 | #latex_use_parts = False 203 | 204 | # If true, show page references after internal links. 205 | #latex_show_pagerefs = False 206 | 207 | # If true, show URL addresses after external links. 208 | #latex_show_urls = False 209 | 210 | # Documents to append as an appendix to all manuals. 211 | #latex_appendices = [] 212 | 213 | # If false, no module index is generated. 214 | #latex_domain_indices = True 215 | 216 | 217 | # -- Options for manual page output -------------------------------------------- 218 | 219 | # One entry per manual page. List of tuples 220 | # (source start file, name, description, authors, manual section). 221 | man_pages = [ 222 | ('index', 'numscrypt', u'Numscrypt Documentation', 223 | [u'Jacques de Hooge'], 1) 224 | ] 225 | 226 | # If true, show URL addresses after external links. 227 | #man_show_urls = False 228 | 229 | 230 | # -- Options for Texinfo output ------------------------------------------------ 231 | 232 | # Grouping the document tree into Texinfo files. List of tuples 233 | # (source start file, target name, title, author, 234 | # dir menu entry, description, category) 235 | texinfo_documents = [ 236 | ('index', 'Numscrypt', u'Numscrypt Documentation', 237 | u'Jacques de Hooge', 'Numscrypt', 'One line description of project.', 238 | 'Miscellaneous'), 239 | ] 240 | 241 | # Documents to append as an appendix to all manuals. 242 | #texinfo_appendices = [] 243 | 244 | # If false, no module index is generated. 245 | #texinfo_domain_indices = True 246 | 247 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 248 | #texinfo_show_urls = 'footnote' 249 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to Numscrypt's documentation! 2 | ====================================== 3 | 4 | Table of Contents: 5 | ------------------ 6 | 7 | .. toctree:: 8 | :numbered: 9 | :maxdepth: 2 10 | 11 | what_why 12 | installation_use 13 | supported_constructs 14 | 15 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/installation_use.rst: -------------------------------------------------------------------------------- 1 | Getting started 2 | =============== 3 | 4 | Installation 5 | ------------ 6 | 7 | Numscrypt is currently tested under Windows, Linux and OSX. To install it, type: 8 | 9 | *pip install numscrypt* 10 | 11 | from the command prompt. This will also install Transcrypt if it's not yet there. 12 | 13 | You can test your installation as follows: 14 | 15 | 1. Go to directory *../Numscrypt-/numscrypt/development/automated_tests/ndarray* 16 | 2. From the command prompt run *transcrypt -b -c -m autotest.py*. This will compile the autotests into file *autotest.js* and put it into the *__javascript__* subdirectory. Do NOT go to that directory (there's no need, stay where you went at point 4) 17 | 3. From the command prompt run *transcrypt -r autotest.py*. This will run the autotests with CPython creating file *autotest.html* that refers to the generated *autotest.js* file 18 | 4. Load the autotest.html into your browser, e.g. by clicking on it (tests were done with Chrome). It will load *autotest.js*, run it and compare the output with what was generated by CPython. It should report no errors 19 | 20 | To experiment with Numscrypt yourself: 21 | 22 | 1. Create a directory for your experiments 23 | 2. Make your own thing there, e.g. *experiment1.py* 24 | 3. Compile with *transcrypt -b -c -m experiment1.py* (The -c is only needed if you use complex numbers) 25 | 4. Make an HTML page that will load your code in the browser. Use the HTML file generated by the autotest as an example of how to do that 26 | 5. Load the HTML and and run the JavaSCript 27 | 28 | Troubleshooting checklist 29 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 30 | 31 | 1. Problem installing NumPy. To be able to test back to back with CPython, NumPy has to be installed into Python 3.6. On Linux and OSX the simplest way to achieve this, is to use `miniconda `_. 32 | 2. Problem installing Numscrypt into the right version of Python. Numscrypt and Transcrypt require Python 3.6. To be certain that the right version of Python is picked for installation, on Windows install with: 33 | 34 | *python36 -m pip install Transcrypt* 35 | 36 | On Linux install with: 37 | 38 | *python3.6 -m pip install Transcrypt* 39 | 40 | Preferably use the miniconda installation of Python 3.6 as described earlier in this checklist. 41 | Use the --upgrade switch to upgrade rather than first-time install, as described in `pip's documentation `_. 42 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | set SPHINXBUILD=python -m sphinx.__init__ 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set BUILDDIR=_build 11 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 12 | set I18NSPHINXOPTS=%SPHINXOPTS% . 13 | if NOT "%PAPER%" == "" ( 14 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 15 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 16 | ) 17 | 18 | if "%1" == "" goto help 19 | 20 | if "%1" == "help" ( 21 | :help 22 | echo.Please use `make ^` where ^ is one of 23 | echo. html to make standalone HTML files 24 | echo. dirhtml to make HTML files named index.html in directories 25 | echo. singlehtml to make a single large HTML file 26 | echo. pickle to make pickle files 27 | echo. json to make JSON files 28 | echo. htmlhelp to make HTML files and a HTML help project 29 | echo. qthelp to make HTML files and a qthelp project 30 | echo. devhelp to make HTML files and a Devhelp project 31 | echo. epub to make an epub 32 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 33 | echo. text to make text files 34 | echo. man to make manual pages 35 | echo. texinfo to make Texinfo files 36 | echo. gettext to make PO message catalogs 37 | echo. changes to make an overview over all changed/added/deprecated items 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | goto end 41 | ) 42 | 43 | if "%1" == "clean" ( 44 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 45 | del /q /s %BUILDDIR%\* 46 | goto end 47 | ) 48 | 49 | if "%1" == "html" ( 50 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 51 | if errorlevel 1 exit /b 1 52 | echo. 53 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 54 | goto end 55 | ) 56 | 57 | if "%1" == "dirhtml" ( 58 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 59 | if errorlevel 1 exit /b 1 60 | echo. 61 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 62 | goto end 63 | ) 64 | 65 | if "%1" == "singlehtml" ( 66 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 67 | if errorlevel 1 exit /b 1 68 | echo. 69 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 70 | goto end 71 | ) 72 | 73 | if "%1" == "pickle" ( 74 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 75 | if errorlevel 1 exit /b 1 76 | echo. 77 | echo.Build finished; now you can process the pickle files. 78 | goto end 79 | ) 80 | 81 | if "%1" == "json" ( 82 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 83 | if errorlevel 1 exit /b 1 84 | echo. 85 | echo.Build finished; now you can process the JSON files. 86 | goto end 87 | ) 88 | 89 | if "%1" == "htmlhelp" ( 90 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 91 | if errorlevel 1 exit /b 1 92 | echo. 93 | echo.Build finished; now you can run HTML Help Workshop with the ^ 94 | .hhp project file in %BUILDDIR%/htmlhelp. 95 | goto end 96 | ) 97 | 98 | if "%1" == "qthelp" ( 99 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 100 | if errorlevel 1 exit /b 1 101 | echo. 102 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 103 | .qhcp project file in %BUILDDIR%/qthelp, like this: 104 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\Numscrypt.qhcp 105 | echo.To view the help file: 106 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\Numscrypt.ghc 107 | goto end 108 | ) 109 | 110 | if "%1" == "devhelp" ( 111 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 112 | if errorlevel 1 exit /b 1 113 | echo. 114 | echo.Build finished. 115 | goto end 116 | ) 117 | 118 | if "%1" == "epub" ( 119 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 120 | if errorlevel 1 exit /b 1 121 | echo. 122 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 123 | goto end 124 | ) 125 | 126 | if "%1" == "latex" ( 127 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 128 | if errorlevel 1 exit /b 1 129 | echo. 130 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 131 | goto end 132 | ) 133 | 134 | if "%1" == "text" ( 135 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 136 | if errorlevel 1 exit /b 1 137 | echo. 138 | echo.Build finished. The text files are in %BUILDDIR%/text. 139 | goto end 140 | ) 141 | 142 | if "%1" == "man" ( 143 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 144 | if errorlevel 1 exit /b 1 145 | echo. 146 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 147 | goto end 148 | ) 149 | 150 | if "%1" == "texinfo" ( 151 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 152 | if errorlevel 1 exit /b 1 153 | echo. 154 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 155 | goto end 156 | ) 157 | 158 | if "%1" == "gettext" ( 159 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 160 | if errorlevel 1 exit /b 1 161 | echo. 162 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 163 | goto end 164 | ) 165 | 166 | if "%1" == "changes" ( 167 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 168 | if errorlevel 1 exit /b 1 169 | echo. 170 | echo.The overview file is in %BUILDDIR%/changes. 171 | goto end 172 | ) 173 | 174 | if "%1" == "linkcheck" ( 175 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 176 | if errorlevel 1 exit /b 1 177 | echo. 178 | echo.Link check complete; look for any errors in the above output ^ 179 | or in %BUILDDIR%/linkcheck/output.txt. 180 | goto end 181 | ) 182 | 183 | if "%1" == "doctest" ( 184 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 185 | if errorlevel 1 exit /b 1 186 | echo. 187 | echo.Testing of doctests in the sources finished, look at the ^ 188 | results in %BUILDDIR%/doctest/output.txt. 189 | goto end 190 | ) 191 | 192 | :end 193 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/supported_constructs.rst: -------------------------------------------------------------------------------- 1 | Currently available features 2 | ============================= 3 | 4 | Numscrypt currently supports: 5 | 6 | - ndarray with 7 | - one or two dimensions 8 | - dtype int32, float32, float64, complex32 and complex64 9 | - indexing 10 | - simple and extended slicing 11 | - astype 12 | - tolist 13 | - real 14 | - imag 15 | - __repr__ and __str__ 16 | - transpose 17 | - overloaded operators: * / + - @, mixing of ndarray and scalar expressions 18 | 19 | - empty, array, copy 20 | - hsplit, vsplit 21 | - hstack, vstack 22 | - zeros, ones, identity 23 | 24 | - linalg with 25 | - matrix inversion 26 | - eigenvalue / eigenvector decomposition 27 | 28 | - FFT with 29 | - FFT for 2^n complex samples 30 | - IFFT for 2^n complex samples 31 | - FFT2 for 2^n x 2^n complex samples 32 | - IFFT2 for 2^n x 2^n complex samples 33 | 34 | Note that all operations where the distinction between row vectors and column vectors matters, only work on ndarrays with two dimensions. 35 | Such operations are e.g. *@*, *hstack*, *vstack*, *hsplit* and *vsplit*. 36 | When used with these operations, a row vector should have shape *(1,n)* and a column vector should have shape *(n,1)*. 37 | Furthermore views and broadcasting are not supported. 38 | 39 | Systematic code examples: a guided tour of Numscrypt 40 | ===================================================== 41 | 42 | One ready-to-run code example is worth more than ten lengthy descriptions. The *autotest and demo suite*, that is part of the distribution, is a collection of sourcecode fragments called *testlets*. These testlets are used for automated regression testing of Numscrypt against NumPy. 43 | Since they systematically cover all the library constructs, they are also very effective as a learning tool. The testlets are arranged alphabetically by subject. 44 | 45 | .. literalinclude:: ../../development/automated_tests/ndarray/autotest.py 46 | :tab-width: 4 47 | :caption: Autotest: Numscrypt autotest demo suite 48 | 49 | Basics: creating and using arrays 50 | --------------------------------- 51 | 52 | .. literalinclude:: ../../development/automated_tests/ndarray/basics/__init__.py 53 | :tab-width: 4 54 | :caption: Testlet: basics 55 | 56 | Linalg: matrix inversion and eigen decomposition 57 | ------------------------------------------------ 58 | 59 | .. literalinclude:: ../../development/automated_tests/ndarray/module_linalg/__init__.py 60 | :tab-width: 4 61 | :caption: Testlet: module_linalg 62 | 63 | Fourier transform: FFT(2) and IFFT(2) for 2^n (x 2^n) samples, using complex arrays 64 | ----------------------------------------------------------------------------------- 65 | 66 | .. literalinclude:: ../../development/automated_tests/ndarray/module_fft/__init__.py 67 | :tab-width: 4 68 | :caption: Testlet: module_fft 69 | 70 | Some more examples: interactive tests 71 | ===================================== 72 | 73 | Benchmark 74 | --------- 75 | 76 | Performance of operations like *@* and *inv* 77 | 78 | .. literalinclude:: ../../development/manual_tests/slicing_optimization/test.py 79 | :tab-width: 4 80 | :caption: Benchmark: slicing_optimization 81 | -------------------------------------------------------------------------------- /numscrypt/docs/sphinx/what_why.rst: -------------------------------------------------------------------------------- 1 | Numscrypt: what and why 2 | ======================== 3 | 4 | What is Numscrypt 5 | ----------------- 6 | 7 | Numscrypt is a port of a small but relevant part of NumPy to Transcrypt using JavaScript typed arrays. As with Transcrypt, the eventual goal is not to completely copy a desktop programming environment. Rather a lean and mean subset is sought that can still be very useful, e.g. for science demo's in the browser or for small to medium scale computations. Whereas NumPy often has multiple way to do things, Numscrypt focuses on one obvious way. The clearest example is the NumPy type *matrix* type, that is a specialization of *ndarray* with confusingly deviating use of some operators. In Transcrypt *matrix* is deliberately left out, to keep the code lean. 8 | 9 | While the first minor versions of Numscrypt fully supported views, strides, offsets and arrays of arbitrary dimension, this proved to be too slow when compiled to JavaScript. In pursuit a good balance between familiarity and efficiency, requirements with respect to Numpy compatibility have been relaxed. Arrays can only have one or two dimensions and are always stored in natural storage order per row. This means that views are not supported and slices are always copies, since that enables them to have natural storage order as well, enabling fast access. Despite the fact that they are used in some branches of physics, arrays with more than two dimensions are relatively rare. If they are needed, in most cases a one- or multi-dimensional list of 2D arrays will do just as well. 10 | 11 | The speed benefits gained from these simplifications are enormous when forced to compile to something like JavaScript rather than C++. With broad applicability in mind, not only is there a direct gain of execution speed by simplifying matters, but also the source code of Numscrypt is much simpler. This code simplicity increases the chance of future optimization using asm.js, simd.js or GPGPU. The newly introduced type annotations of Python may well facilitate introduction of such technologies in a robust manner. 12 | 13 | In Numscrypt, speed is generally favored over memory conservation. In computations like inversion, non-elementwise matrix multiplication, convolution and FFT, the ability to store very large arrays is pointless if computations are slow. So the choice for speed over memory conservation illustrates the fact that Numscrypt is meant for non-trivial computations on small to medium scale, rather than for data reshuffling on medium to large scale. 14 | 15 | Computing in a browser? 16 | ----------------------- 17 | 18 | At first Numscrypt was purely meant as a tool for education and demonstration. The fact that some serious numerical math libraries for JavaScript do exist, sometimes using weird tricks to mimic operator overloading, led to reconsideration. Although computing in JavaScript in a browser certainly restricts performance and scalabilty compared to computing in C++ on dedicated manycore hardware, this doesn't mean that there aren't many useful, serious applications. If, given the existence of several JavaScript math libraries, there appears to be a need for computing in the browser, why not enable doing so in a language that is familiar to scientists and technicians, and has decent solutions for e.g. operator overloading and slicing notation. The partial parity between Numscrypt and Numpy is another attractive aspect of this approach. 19 | -------------------------------------------------------------------------------- /numscrypt/fft/__init__.py: -------------------------------------------------------------------------------- 1 | __pragma__ ('noanno') 2 | 3 | import numscrypt as ns 4 | 5 | __pragma__ ('js', '{}', __include__ ('numscrypt/fft/__javascript__/fft_nayuki_precalc_fixed.js') .replace ('// "use strict";', '')) 6 | 7 | def fft (a, ns_fftn = None): 8 | fftn = ns_fftn if ns_fftn else __new__ (FFTNayuki (a.size)) 9 | result = ns.copy (a) 10 | fftn.forward (result.real () .realbuf, result.imag () .realbuf) 11 | return result 12 | 13 | def ifft (a, ns_fftn = None): 14 | fftn = ns_fftn if ns_fftn else __new__ (FFTNayuki (a.size)) 15 | real = a.real () .__div__ (a.size) # Avoid complex division for efficiency 16 | imag = a.imag () .__div__ (a.size) 17 | fftn.inverse (real.realbuf, imag.realbuf) 18 | return ns.ndarray (real.shape, a.dtype, real.realbuf, imag.realbuf) 19 | 20 | def fft2 (a, ns_fftn = None): 21 | if a.ns_nrows != a.ns_ncols: 22 | raise 'Matrix isn\'t square' 23 | fftn = ns_fftn if ns_fftn else __new__ (FFTNayuki (a.ns_nrows)) 24 | result = ns.empty (a.shape, a.dtype) 25 | for irow in range (a.ns_nrows): 26 | __pragma__ ('opov') 27 | result [irow, : ] = fft (a [irow, : ], fftn) 28 | __pragma__ ('noopov') 29 | 30 | for icol in range (a.ns_ncols): 31 | __pragma__ ('opov') 32 | result [ : , icol] = fft (result [ : , icol], fftn) 33 | __pragma__ ('noopov') 34 | return result 35 | 36 | def ifft2 (a, ns_fftn = None): 37 | if a.ns_nrows != a.ns_ncols: 38 | raise 'Matrix isn\'t square' 39 | fftn = ns_fftn if ns_fftn else __new__ (FFTNayuki (a.ns_nrows)) 40 | result = ns.empty (a.shape, a.dtype) 41 | 42 | for irow in range (a.ns_nrows): 43 | __pragma__ ('opov') 44 | result [irow, : ] = ifft (a [irow, : ], fftn) 45 | __pragma__ ('noopov') 46 | 47 | for icol in range (a.ns_ncols): 48 | __pragma__ ('opov') 49 | result [ : , icol] = ifft (result [ : , icol], fftn) 50 | __pragma__ ('noopov') 51 | return result 52 | -------------------------------------------------------------------------------- /numscrypt/fft/__javascript__/fft_nayuki_precalc_fixed.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Free FFT and convolution (JavaScript) 3 | * 4 | * Copyright (c) 2014 Project Nayuki 5 | * http://www.nayuki.io/page/free-small-fft-in-multiple-languages 6 | * 7 | * (MIT License) 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy of 9 | * this software and associated documentation files (the "Software"), to deal in 10 | * the Software without restriction, including without limitation the rights to 11 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 12 | * the Software, and to permit persons to whom the Software is furnished to do so, 13 | * subject to the following conditions: 14 | * - The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * - The Software is provided "as is", without warranty of any kind, express or 17 | * implied, including but not limited to the warranties of merchantability, 18 | * fitness for a particular purpose and noninfringement. In no event shall the 19 | * authors or copyright holders be liable for any claim, damages or other 20 | * liability, whether in an action of contract, tort or otherwise, arising from, 21 | * out of or in connection with the Software or the use or other dealings in the 22 | * Software. 23 | * 24 | * Slightly restructured by Chris Cannam, cannam@all-day-breakfast.com 25 | * 26 | * Fix added by Jacques de Hooge, jdeh@transcrypt.org: 'this' added to inverse, indentation repaired 27 | */ 28 | 29 | // "use strict"; 30 | 31 | /* 32 | * Construct an object for calculating the discrete Fourier transform (DFT) of size n, where n is a power of 2. 33 | */ 34 | function FFTNayuki(n) { 35 | 36 | this.n = n; 37 | this.levels = -1; 38 | 39 | for (var i = 0; i < 32; i++) { 40 | if (1 << i == n) { 41 | this.levels = i; // Equal to log2(n) 42 | } 43 | } 44 | if (this.levels == -1) { 45 | throw "Length is not a power of 2"; 46 | } 47 | 48 | this.cosTable = new Array(n / 2); 49 | this.sinTable = new Array(n / 2); 50 | for (var i = 0; i < n / 2; i++) { 51 | this.cosTable[i] = Math.cos(2 * Math.PI * i / n); 52 | this.sinTable[i] = Math.sin(2 * Math.PI * i / n); 53 | } 54 | 55 | /* 56 | * Computes the discrete Fourier transform (DFT) of the given complex vector, storing the result back into the vector. 57 | * The vector's length must be equal to the size n that was passed to the object constructor, and this must be a power of 2. Uses the Cooley-Tukey decimation-in-time radix-2 algorithm. 58 | */ 59 | this.forward = function(real, imag) { 60 | 61 | var n = this.n; 62 | 63 | // Bit-reversed addressing permutation 64 | for (var i = 0; i < n; i++) { 65 | var j = reverseBits(i, this.levels); 66 | if (j > i) { 67 | var temp = real[i]; 68 | real[i] = real[j]; 69 | real[j] = temp; 70 | temp = imag[i]; 71 | imag[i] = imag[j]; 72 | imag[j] = temp; 73 | } 74 | } 75 | 76 | // Cooley-Tukey decimation-in-time radix-2 FFT 77 | for (var size = 2; size <= n; size *= 2) { 78 | var halfsize = size / 2; 79 | var tablestep = n / size; 80 | for (var i = 0; i < n; i += size) { 81 | for (var j = i, k = 0; j < i + halfsize; j++, k += tablestep) { 82 | var tpre = real[j+halfsize] * this.cosTable[k] + 83 | imag[j+halfsize] * this.sinTable[k]; 84 | var tpim = -real[j+halfsize] * this.sinTable[k] + 85 | imag[j+halfsize] * this.cosTable[k]; 86 | real[j + halfsize] = real[j] - tpre; 87 | imag[j + halfsize] = imag[j] - tpim; 88 | real[j] += tpre; 89 | imag[j] += tpim; 90 | } 91 | } 92 | } 93 | 94 | // Returns the integer whose value is the reverse of the lowest 'bits' bits of the integer 'x'. 95 | function reverseBits(x, bits) { 96 | var y = 0; 97 | for (var i = 0; i < bits; i++) { 98 | y = (y << 1) | (x & 1); 99 | x >>>= 1; 100 | } 101 | return y; 102 | } 103 | } 104 | 105 | /* 106 | * Computes the inverse discrete Fourier transform (IDFT) of the given complex vector, storing the result back into the vector. 107 | * The vector's length must be equal to the size n that was passed to the object constructor, and this must be a power of 2. This is a wrapper function. This transform does not perform scaling, so the inverse is not a true inverse. 108 | */ 109 | this.inverse = function(real, imag) { 110 | this.forward(imag, real); // Fix by JdeH: 'this' added 111 | } 112 | } 113 | 114 | -------------------------------------------------------------------------------- /numscrypt/license_reference.txt: -------------------------------------------------------------------------------- 1 | Licence 2 | ======= 3 | 4 | Copyright 2016 Jacques de Hooge, GEATEC engineering, www.geatec.com 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | -------------------------------------------------------------------------------- /numscrypt/linalg/__init__.py: -------------------------------------------------------------------------------- 1 | import numscrypt as ns 2 | import numscrypt.linalg.eigen_mpmath as eigen 3 | 4 | def inv (a): 5 | # Work directly with flat data atoms in natural order speeds up by factor 70 (!) 6 | if a.ns_complex: 7 | return cinv (a) 8 | else: 9 | return rinv (a) 10 | 11 | def rinv (a): 12 | # Leave original matrix intact 13 | b = ns.hstack ((a, ns.identity (a.shape [0], a.dtype))) # b will always have natural order 14 | real = b.realbuf 15 | nrows, ncols = b.shape 16 | 17 | # Use each row of the matrix as pivot row\n 18 | for ipiv in range (nrows): 19 | 20 | # Swap rows if needed to get a nonzero pivot 21 | if not real [ipiv * ncols + ipiv]: 22 | for irow in range (ipiv + 1, nrows): 23 | if real [irow * ncols + ipiv]: 24 | for icol in range (ncols): 25 | temp = real [irow * ncols + icol] 26 | real [irow * ncols + icol] = b [ipiv * ncols + icol] 27 | real [ipiv * ncols + icol] = temp 28 | break 29 | 30 | # Make pivot element 1 31 | piv = real [ipiv * ncols + ipiv] 32 | for icol in range (ipiv, ncols): 33 | real [ipiv * ncols + icol] /= piv 34 | 35 | # Sweep other rows to get all zeroes in pivot column 36 | for irow in range (nrows): 37 | if irow != ipiv: 38 | factor = real [irow * ncols + ipiv] 39 | for icol in range (ncols): 40 | real [irow * ncols + icol] -= factor * real [ipiv * ncols + icol] 41 | 42 | # Chop of left matrix, return right matrix 43 | return ns.hsplit (b, 2)[1] 44 | 45 | def cinv (a): # for speed, don't use 'complex' or operator overloading 46 | # Leave original matrix intact 47 | b = ns.hstack ((a, ns.identity (a.shape [0], a.dtype))) # b will always have natural order 48 | 49 | real = b.realbuf 50 | imag = b.imagbuf 51 | nrows, ncols = b.shape 52 | 53 | # Use each row of the matrix as pivot row\n 54 | for ipiv in range (nrows): 55 | ipiv_flat = ipiv * ncols + ipiv 56 | 57 | # Swap rows if needed to get a nonzero pivot 58 | if not (real [ipiv_flat] or imag [ipiv_flat]): 59 | for irow in range (ipiv + 1, nrows): 60 | iswap = irow * ncols + ipiv 61 | if real [iswap] or imag [iswap]: 62 | for icol in range (ncols): 63 | isource = irow * ncols + icol 64 | itarget = ipiv * ncols + icol 65 | 66 | temp = real [isource] 67 | real [isource] = real [itarget] 68 | real [itarget] = temp 69 | 70 | temp = imag [isource_flat] 71 | imag [isource] = imag [itarget] 72 | imag [itarget] = temp 73 | break 74 | 75 | # Make pivot element 1 76 | pivre = real [ipiv_flat] 77 | pivim = imag [ipiv_flat] 78 | 79 | denom = pivre * pivre + pivim * pivim 80 | 81 | for icol in range (ipiv, ncols): 82 | icur = ipiv * ncols + icol 83 | 84 | oldre = real [icur] 85 | oldim = imag [icur] 86 | 87 | real [icur] = (oldre * pivre + oldim * pivim) / denom 88 | imag [icur] = (oldim * pivre - oldre * pivim) / denom 89 | 90 | # Sweep other rows to get all zeroes in pivot column 91 | for irow in range (nrows): 92 | if irow != ipiv: 93 | ifac = irow * ncols + ipiv 94 | facre = real [ifac] 95 | facim = imag [ifac] 96 | for icol in range (ncols): 97 | itarget = irow * ncols + icol 98 | isource = ipiv * ncols + icol 99 | 100 | oldre = real [isource] 101 | oldim = imag [isource] 102 | 103 | real [itarget] -= (facre * oldre - facim * oldim) 104 | imag [itarget] -= (facre * oldim + facim * oldre) 105 | 106 | # Chop of left matrix, return right matrix 107 | return ns.hsplit (b, 2)[1] 108 | 109 | def norm (a): 110 | result = 0 111 | 112 | if a.ns_complex: 113 | for i in range (a.size): 114 | result += a.realbuf [i] * a.realbuf [i] + a.imagbuf [i] * a.imagbuf [i] 115 | else: 116 | for i in range (a.size): 117 | result += a.realbuf [i] * a.realbuf [i] 118 | 119 | return Math.sqrt (result) 120 | 121 | def eig (a): # Everything presumed complex for now 122 | evals, evecs = eigen.eig (a) 123 | 124 | nrows, ncols = evecs.shape 125 | real = evecs.realbuf 126 | imag = evecs.imagbuf 127 | 128 | for icol in range (ncols): 129 | sum = 0 130 | 131 | for irow in range (nrows): 132 | iterm = irow * ncols + icol 133 | sum += (real [iterm] * real [iterm] + imag [iterm] * imag [iterm]) 134 | 135 | norm = Math.sqrt (sum) 136 | 137 | for irow in range (nrows): 138 | iterm = irow * ncols + icol 139 | real [iterm] /= norm 140 | imag [iterm] /= norm 141 | 142 | return ns.array (evals, 'complex64'), evecs 143 | -------------------------------------------------------------------------------- /numscrypt/random.py: -------------------------------------------------------------------------------- 1 | import numscrypt as ns 2 | 3 | def rand (*dims): 4 | result = ns.empty (dims, 'float64') 5 | for i in range (result.size): 6 | result.realbuf [i] = Math.random () 7 | return result 8 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [wheel] 2 | universal = 1 3 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | sys.path.append ('numscrypt') 5 | import __base__ 6 | 7 | from setuptools import setup 8 | 9 | def read (*paths): 10 | with open (os.path.join (*paths), 'r') as aFile: 11 | return aFile.read() 12 | 13 | setup ( 14 | name = 'Numscrypt', 15 | version = __base__.ns_version, 16 | description = 'A tiny bit of NumPy for Transcrypt using JavaScript typed arrays', 17 | long_description = ( 18 | read ('README.rst') + '\n\n' + 19 | read ('numscrypt/license_reference.txt') 20 | ), 21 | keywords = ['transcrypt', 'numscrypt', 'numpy', 'browser'], 22 | url = 'https://github.com/JdeH/Numscrypt', 23 | license = 'Apache 2.0', 24 | author = 'Jacques de Hooge', 25 | author_email = 'jacques.de.hooge@qquick.org', 26 | packages = ['numscrypt'], 27 | install_requires = [ 28 | 'transcrypt' 29 | ], 30 | include_package_data = True, 31 | classifiers = [ 32 | 'Development Status :: 2 - Pre-Alpha', 33 | 'Intended Audience :: Developers', 34 | 'Natural Language :: English', 35 | 'License :: OSI Approved :: Apache Software License', 36 | 'Topic :: Software Development :: Libraries :: Python Modules', 37 | 'Operating System :: OS Independent', 38 | 'Programming Language :: Python :: 3.5', 39 | ], 40 | ) 41 | --------------------------------------------------------------------------------