Skip to content

Commit

Permalink
deploy: 9abfc3a
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoGranstrom committed Nov 22, 2024
1 parent 68bea55 commit bb57ee5
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
Binary file modified __pycache__/mymod.cpython-310.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion basics/common_datatypes.html
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ <h3>A few more typical ways to create sequences</h3>
standard library provides a <code>rand</code> procedure we can combine with <code>mapIt</code>:</p>
<pre><code class="nohighlight hljs nim"><span class="hljs-keyword">import</span> random
randomize()
<span class="hljs-keyword">echo</span> toSeq(<span class="hljs-number">0</span> ..&lt; <span class="hljs-number">5</span>).mapIt(rand(<span class="hljs-number">10.0</span>))</code></pre><pre class="nb-output">@[9.579251111264801, 1.578132457619805, 4.889709401360747, 8.848071916580956, 2.386300214710697]</pre>
<span class="hljs-keyword">echo</span> toSeq(<span class="hljs-number">0</span> ..&lt; <span class="hljs-number">5</span>).mapIt(rand(<span class="hljs-number">10.0</span>))</code></pre><pre class="nb-output">@[0.8769893891051761, 8.003552359258268, 0.1919852990291604, 9.043200846330667, 1.789818960578717]</pre>
<p>samples 5 floating point numbers between 0 and 10.</p>
<h2><code>Tensor[T]</code> - an ND-array type from <a href="https://github.com/mratsim/Arraymancer">Arraymancer</a></h2>
<p>Arraymancer provides an ND-array type called <code>Tensor[T]</code> that is best compared to a numpy
Expand Down
2 changes: 1 addition & 1 deletion basics/units_basics.html
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ <h2>Motivating example</h2>
<span class="hljs-keyword">let</span> lbfs = <span class="hljs-number">1.</span>lbf•s
<span class="hljs-keyword">let</span> <span class="hljs-type">Ns</span> = lbfs.to(<span class="hljs-type">N•s</span>)

<span class="hljs-keyword">echo</span> lbfs, <span class="hljs-string">&quot; equals &quot;</span>, <span class="hljs-type">Ns</span></code></pre><pre class="nb-output">1 lbf•s equals 4.44822 kg•m•s⁻¹</pre>
<span class="hljs-keyword">echo</span> lbfs, <span class="hljs-string">&quot; equals &quot;</span>, <span class="hljs-type">Ns</span></code></pre><pre class="nb-output">1 lbf•s equals 4.44822 N•s</pre>
<p>As you can see, they thought the value they read was 4.4 times smaller than it really was!</p>
<p>But what does the code do? Let's dissect it block-by-block:</p>
<ol>
Expand Down
2 changes: 1 addition & 1 deletion book.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"initDir":"/home/runner/work/getting-started/getting-started","cfgDir":"/home/runner/work/getting-started/getting-started","rawCfg":"[nimib]\nsrcDir = \"book\"\nhomeDir = \"docs\"\n\n[nimibook]\ntitle = \"SciNim Getting Started\"\ndescription = \"Tutorials for libraries in SciNim ecosystems\"\ngit_repository_url = \"https://github.com/SciNim/getting-started\"\nplausible_analytics_url = \"scinim.github.io/getting-started\"\n","nbCfg":{"srcDir":"book","homeDir":"docs"},"cfg":{"title":"SciNim Getting Started","language":"en-us","description":"Tutorials for libraries in SciNim ecosystems","default_theme":"light","preferred_dark_theme":"navy","git_repository_url":"https://github.com/SciNim/getting-started","git_repository_icon":"fa-github","plausible_analytics_url":"scinim.github.io/getting-started","favicon_escaped":"<link rel=\"icon\" href=\"data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2280%22>🐳</text></svg>\">"},"theme_option":{"navy":"Navy","coal":"Coal","rust":"Rust","ayu":"Ayu","light":"Light (default)"},"toc":{"entries":[{"title":"Introduction","path":"index.md","levels":[1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Ecosystem overview","path":"overview/index.md","levels":[2],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Basic topics","path":"basics/index.md","levels":[3],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Common datatypes","path":"basics/common_datatypes.nim","levels":[3,1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Data wrangling with dataframes","path":"basics/data_wrangling.nim","levels":[3,2],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Plotting","path":"basics/basic_plotting.nim","levels":[3,3],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Units","path":"basics/units_basics.nim","levels":[3,4],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Numerical methods","path":"numerical_methods/index.md","levels":[4],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Curve fitting","path":"numerical_methods/curve_fitting.nim","levels":[4,1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Integration (1D)","path":"numerical_methods/integration1d.nim","levels":[4,2],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"ODEs","path":"numerical_methods/ode.nim","levels":[4,3],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Optimization","path":"numerical_methods/optimization.nim","levels":[4,4],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Interpolation","path":"numerical_methods/interpolation.nim","levels":[4,5],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Data visualization","path":"data_viz/index.md","levels":[5],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Plotting data","path":"data_viz/plotting_data.nim","levels":[5,1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Interfacing with other language","path":"external_language_integration/index.md","levels":[6],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Nimpy - The Nim Python bridge","path":"external_language_integration/nim_with_py.nim","levels":[6,1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Nimjl - The Nim Julia bridge","path":"external_language_integration/julia/basics.nim","levels":[6,2],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Advanced types","path":"external_language_integration/julia/nimjl_conversions.nim","levels":[6,2,1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Julia Arrays from Nim","path":"external_language_integration/julia/nimjl_arrays.nim","levels":[6,2,2],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Interfacing with R","path":"external_language_integration/nim_with_R.nim","levels":[6,3],"isNumbered":true,"isDraft":false,"isActive":false}]},"keep":[]}
{"initDir":"/home/runner/work/getting-started/getting-started","cfgDir":"/home/runner/work/getting-started/getting-started","rawCfg":"[nimib]\nsrcDir = \"book\"\nhomeDir = \"docs\"\n\n[nimibook]\ntitle = \"SciNim Getting Started\"\ndescription = \"Tutorials for libraries in SciNim ecosystems\"\ngit_repository_url = \"https://github.com/SciNim/getting-started\"\nplausible_analytics_url = \"scinim.github.io/getting-started\"\n","nbCfg":{"srcDir":"book","homeDir":"docs"},"cfg":{"title":"SciNim Getting Started","language":"en-us","description":"Tutorials for libraries in SciNim ecosystems","default_theme":"light","preferred_dark_theme":"navy","git_repository_url":"https://github.com/SciNim/getting-started","git_repository_icon":"fa-github","plausible_analytics_url":"scinim.github.io/getting-started","favicon_escaped":"<link rel=\"icon\" href=\"data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2280%22>🐳</text></svg>\">"},"theme_option":{"navy":"Navy","rust":"Rust","coal":"Coal","ayu":"Ayu","light":"Light (default)"},"toc":{"entries":[{"title":"Introduction","path":"index.md","levels":[1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Ecosystem overview","path":"overview/index.md","levels":[2],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Basic topics","path":"basics/index.md","levels":[3],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Common datatypes","path":"basics/common_datatypes.nim","levels":[3,1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Data wrangling with dataframes","path":"basics/data_wrangling.nim","levels":[3,2],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Plotting","path":"basics/basic_plotting.nim","levels":[3,3],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Units","path":"basics/units_basics.nim","levels":[3,4],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Numerical methods","path":"numerical_methods/index.md","levels":[4],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Curve fitting","path":"numerical_methods/curve_fitting.nim","levels":[4,1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Integration (1D)","path":"numerical_methods/integration1d.nim","levels":[4,2],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"ODEs","path":"numerical_methods/ode.nim","levels":[4,3],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Optimization","path":"numerical_methods/optimization.nim","levels":[4,4],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Interpolation","path":"numerical_methods/interpolation.nim","levels":[4,5],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Data visualization","path":"data_viz/index.md","levels":[5],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Plotting data","path":"data_viz/plotting_data.nim","levels":[5,1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Interfacing with other language","path":"external_language_integration/index.md","levels":[6],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Nimpy - The Nim Python bridge","path":"external_language_integration/nim_with_py.nim","levels":[6,1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Nimjl - The Nim Julia bridge","path":"external_language_integration/julia/basics.nim","levels":[6,2],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Advanced types","path":"external_language_integration/julia/nimjl_conversions.nim","levels":[6,2,1],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Julia Arrays from Nim","path":"external_language_integration/julia/nimjl_arrays.nim","levels":[6,2,2],"isNumbered":true,"isDraft":false,"isActive":false},{"title":"Interfacing with R","path":"external_language_integration/nim_with_R.nim","levels":[6,3],"isNumbered":true,"isDraft":false,"isActive":false}]},"keep":[]}
12 changes: 6 additions & 6 deletions external_language_integration/julia/nimjl_arrays.html
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,13 @@ <h2>Conversion between JlArray[T] and Arraymancer's Tensor[T] (and dealing with
<span class="hljs-keyword">echo</span> localTensor

<span class="hljs-keyword">var</span> localTensor2 = localArray.to(<span class="hljs-type">Tensor</span>[<span class="hljs-built_in">int</span>], rowMajor)
<span class="hljs-keyword">assert</span>(localTensor == localTensor2)</code></pre><pre class="nb-output">[3 5 2 1 2; 5 1 3 4 4; 3 3 5 4 3; 5 2 5 4 2; 5 2 3 4 5]
<span class="hljs-keyword">assert</span>(localTensor == localTensor2)</code></pre><pre class="nb-output">[4 2 1 1 3; 4 1 5 3 2; 3 2 2 4 5; 5 5 2 1 4; 5 4 1 2 4]
Tensor[system.int] of shape &quot;[5, 5]&quot; on backend &quot;Cpu&quot;
|3 5 2 1 2|
|5 1 3 4 4|
|3 3 5 4 3|
|5 2 5 4 2|
|5 2 3 4 5|</pre>
|4 2 1 1 3|
|4 1 5 3 2|
|3 2 2 4 5|
|5 5 2 1 4|
|5 4 1 2 4|</pre>
<p>Both Tensors have identical indexed values but the buffer are different according to the memory layout argument.</p>
<p>When passing Tensor directly as values in a <code>jlCall</code> / <code>Julia.</code> expression, a <code>JlArray[T]</code> will be constructed by buffer; so you should be aware about the memory layout of the buffer.</p>
<pre><code class="nohighlight hljs nim"><span class="hljs-keyword">var</span> orderedTensor = newTensor[<span class="hljs-built_in">int</span>]([<span class="hljs-number">3</span>, <span class="hljs-number">2</span>])
Expand Down
12 changes: 6 additions & 6 deletions numerical_methods/integration1d.html
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,12 @@ <h3>Let the integration begin!</h3>

timeIt <span class="hljs-string">&quot;AdaGauss&quot;</span>:
keep adaptiveGauss(f, a, b, tol=tol)</code></pre><pre class="nb-output"> min time avg time std dv runs name
0.017 ms 0.019 ms ±0.001 x1000 Trapz
0.018 ms 0.019 ms ±0.005 x1000 Simpson
0.066 ms 0.076 ms ±0.128 x1000 GaussQuad
0.036 ms 0.040 ms ±0.002 x1000 Romberg
0.293 ms 0.493 ms ±1.211 x1000 AdaSimpson
0.040 ms 0.045 ms ±0.003 x1000 AdaGauss</pre>
0.015 ms 0.017 ms ±0.001 x1000 Trapz
0.016 ms 0.019 ms ±0.064 x1000 Simpson
0.065 ms 0.073 ms ±0.093 x1000 GaussQuad
0.035 ms 0.038 ms ±0.002 x1000 Romberg
0.293 ms 0.605 ms ±1.541 x1000 AdaSimpson
0.032 ms 0.037 ms ±0.040 x1000 AdaGauss</pre>
<p>As we can see, all methods except AdaSimpson were roughly equally fast. So if I were to choose
a winner, it would be <code>adaptiveGauss</code> because it was the most accurate while still being among
the fastest methods.</p>
Expand Down
16 changes: 8 additions & 8 deletions numerical_methods/ode.html
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,10 @@ <h2>Let's code</h2>
<code>odeOptions</code> would probably get them on-par with the others. There is one parameter we haven't talked about though,
the execution time. Let's look at that and see if it bring any further insights:</p>
<pre><code class="nohighlight hljs nim"></code></pre><pre class="nb-output"> min time avg time std dv runs name
11.259 ms 20.406 ms ±6.787 x243 heun2
14.426 ms 16.404 ms ±3.768 x295 rk4
0.259 ms 0.284 ms ±0.009 x1000 rk21
0.304 ms 0.361 ms ±0.118 x1000 tsit54</pre>
11.078 ms 16.221 ms ±6.710 x298 heun2
10.544 ms 10.629 ms ±0.268 x460 rk4
0.214 ms 0.217 ms ±0.002 x1000 rk21
0.256 ms 0.258 ms ±0.002 x1000 tsit54</pre>
<p>As we can see, the adaptive methods are orders of magnitude faster while achieving roughly the same errors.
This is because they take fewer and longer steps when the function is flatter and only decrease the
step-size when the function is changing more rapidly.</p>
Expand Down Expand Up @@ -393,10 +393,10 @@ <h2>Vector-valued functions</h2>
<ul>
<li>tsit54: 2.114975e-13</li>
</ul>
<pre><code class="nohighlight hljs nim"></code></pre><pre class="nb-output">2615.167 ms 2626.198 ms ±15.601 x2 heun2
5261.133 ms 5261.133 ms ±0.000 x1 rk4
50.778 ms 51.349 ms ±0.291 x98 rk21
224.308 ms 225.149 ms ±0.704 x23 tsit54</pre>
<pre><code class="nohighlight hljs nim"></code></pre><pre class="nb-output">2733.102 ms 2738.193 ms ±7.199 x2 heun2
5430.602 ms 5430.602 ms ±0.000 x1 rk4
52.290 ms 52.462 ms ±0.123 x96 rk21
232.087 ms 233.602 ms ±1.008 x22 tsit54</pre>
<p>We can once again see that the high-order adaptive methods are both more accurate and faster than the fixed-order ones.</p>
<h2>Further reading</h2>
<ul>
Expand Down
8 changes: 4 additions & 4 deletions numerical_methods/optimization.html
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,10 @@ <h1>Optimize functions in Nim</h1>
LBFGS: Tensor[system.float] of shape &quot;[2]&quot; on backend &quot;Cpu&quot;
1 1
min time avg time std dv runs name
214.122 ms 315.523 ms ±49.139 x16 Steepest
0.201 ms 0.268 ms ±0.332 x1000 Newton
3.051 ms 9.665 ms ±7.740 x509 BFGS
4.878 ms 9.730 ms ±5.731 x504 LBFGS</pre>
158.509 ms 325.429 ms ±106.262 x16 Steepest
0.207 ms 0.235 ms ±0.012 x1000 Newton
2.216 ms 3.286 ms ±0.601 x1000 BFGS
3.784 ms 4.218 ms ±0.760 x1000 LBFGS</pre>
<p>As we can see, Newton, BFGS and LBFGS found the exact solution and they did it fast.
Steepest descent didn't find as good a solution and took by far the longest time.
Steepest descent has an order of convergence of $O(N)$, Newton has $O(N^2)$ and (L)BFGS
Expand Down

0 comments on commit bb57ee5

Please sign in to comment.