build based on e6474b1

This commit is contained in:
Documenter.jl
2024-08-19 14:07:02 +00:00
parent 96c390a5bf
commit b69d0e7340
58 changed files with 16359 additions and 1840 deletions

View File

@@ -7333,11 +7333,12 @@ a.anchor-link {
if (!diagrams.length) {
return;
}
const mermaid = (await import("https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.5.0/mermaid.esm.min.mjs")).default;
const mermaid = (await import("https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.7.0/mermaid.esm.min.mjs")).default;
const parser = new DOMParser();
mermaid.initialize({
maxTextSize: 100000,
maxEdges: 100000,
startOnLoad: false,
fontFamily: window
.getComputedStyle(document.body)
@@ -7408,7 +7409,8 @@ a.anchor-link {
let results = null;
let output = null;
try {
const { svg } = await mermaid.render(id, raw, el);
let { svg } = await mermaid.render(id, raw, el);
svg = cleanMermaidSvg(svg);
results = makeMermaidImage(svg);
output = document.createElement("figure");
results.map(output.appendChild, output);
@@ -7423,6 +7425,38 @@ a.anchor-link {
parent.appendChild(output);
}
/**
* Post-process to ensure mermaid diagrams contain only valid SVG and XHTML.
*/
function cleanMermaidSvg(svg) {
return svg.replace(RE_VOID_ELEMENT, replaceVoidElement);
}
/**
* A regular expression for all void elements, which may include attributes and
* a slash.
*
* @see https://developer.mozilla.org/en-US/docs/Glossary/Void_element
*
* Of these, only `<br>` is generated by Mermaid in place of `\n`,
* but _any_ "malformed" tag will break the SVG rendering entirely.
*/
const RE_VOID_ELEMENT =
/<\s*(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)\s*([^>]*?)\s*>/gi;
/**
* Ensure a void element is closed with a slash, preserving any attributes.
*/
function replaceVoidElement(match, tag, rest) {
rest = rest.trim();
if (!rest.endsWith('/')) {
rest = `${rest} /`;
}
return `<${tag} ${rest}>`;
}
void Promise.all([...diagrams].map(renderOneMarmaid));
});
</script>
@@ -7506,13 +7540,70 @@ a.anchor-link {
</div>
</div>
</div>
<div class="jp-Cell jp-MarkdownCell jp-Notebook-cell" id="cell-id=cde5ee75">
<div class="jp-Cell-inputWrapper" tabindex="0">
<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
</div>
<div class="jp-InputArea jp-Cell-inputArea"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput" data-mime-type="text/markdown">
<div class="alert alert-block alert-info">
<b>Note:</b> Do not forget to execute the next cell before starting this notebook!
</div>
</div>
</div>
</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs" id="cell-id=0b0496c7">
<div class="jp-Cell-inputWrapper" tabindex="0">
<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
</div>
<div class="jp-InputArea jp-Cell-inputArea">
<div class="jp-InputPrompt jp-InputArea-prompt">In [ ]:</div>
<div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline">
<div class="cm-editor cm-s-jupyter">
<div class="highlight hl-julia"><pre><span></span><span class="k">function</span><span class="w"> </span><span class="n">why_q1</span><span class="p">()</span>
<span class="w"> </span><span class="n">msg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"""</span>
<span class="s"> Evaluating compute_π(100_000_000) takes about 0.25 seconds on the teacher's laptop. Thus, the loop would take about 2.5 seconds since we are calling the function 10 times.</span>
<span class="s"> """</span>
<span class="w"> </span><span class="n">println</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">function</span><span class="w"> </span><span class="n">why_q2</span><span class="p">()</span>
<span class="w"> </span><span class="n">msg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"""</span>
<span class="s"> The time in doing the loop will be almost zero since the loop just schedules 10 tasks, which should be very fast.</span>
<span class="s"> """</span>
<span class="w"> </span><span class="n">println</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">function</span><span class="w"> </span><span class="n">why_q3</span><span class="p">()</span>
<span class="w"> </span><span class="n">msg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"""</span>
<span class="s"> It will take 2.5 seconds, like in question 1. The @sync macro forces to wait for all tasks we have generated with the @async macro. Since we have created 10 tasks and each of them takes about 0.25 seconds, the total time will be about 2.5 seconds.</span>
<span class="s"> """</span>
<span class="w"> </span><span class="n">println</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">function</span><span class="w"> </span><span class="n">why_q4</span><span class="p">()</span>
<span class="w"> </span><span class="n">msg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"""</span>
<span class="s"> It will take about 3 seconds. The channel has buffer size 4, thus the call to put!will not block. The call to take! will not block neither since there is a value stored in the channel. The taken value is 3 and therefore we will wait for 3 seconds.</span>
<span class="s"> """</span>
<span class="w"> </span><span class="n">println</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">end</span>
<span class="k">function</span><span class="w"> </span><span class="n">why_q5</span><span class="p">()</span>
<span class="w"> </span><span class="n">msg</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"""</span>
<span class="s"> The channel is not buffered and therefore the call to put! will block. The cell will run forever, since there is no other task that calls take! on this channel.</span>
<span class="s"> """</span>
<span class="w"> </span><span class="n">println</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">end</span>
<span class="n">println</span><span class="p">(</span><span class="s">"🥳 Well done! "</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="jp-Cell jp-MarkdownCell jp-Notebook-cell" id="cell-id=caf64254">
<div class="jp-Cell-inputWrapper" tabindex="0">
<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
</div>
<div class="jp-InputArea jp-Cell-inputArea"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput" data-mime-type="text/markdown">
<h2 id="Tasks">Tasks<a class="anchor-link" href="#Tasks"></a></h2><h3 id="Creating--a-task">Creating a task<a class="anchor-link" href="#Creating--a-task"></a></h3><p>Technically, a task in Julia is a <em>symmetric co-routine</em>. More informally, a task is a piece of computation work that can be started (scheduled) at some point in the future, and that can be interrupted and resumed. To create a task, we first need to create a function that represents the work to be done in the task. In next cell, we generate a task that generates and sums two matrices.</p>
<h2 id="Tasks">Tasks<a class="anchor-link" href="#Tasks"></a></h2><h3 id="Creating--a-task">Creating a task<a class="anchor-link" href="#Creating--a-task"></a></h3><p>Technically, a task in Julia is a <em>symmetric</em> <a href="https://en.wikipedia.org/wiki/Coroutine"><em>co-routine</em></a>. More informally, a task is a piece of computational work that can be started (scheduled) at some point in the future, and that can be interrupted and resumed. To create a task, we first need to create a function that represents the work to be done in the task. In next cell, we generate a task that generates and sums two matrices.</p>
</div>
</div>
</div>
@@ -8397,6 +8488,20 @@ d) near 0*t </code></pre>
</div>
</div>
</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs" id="cell-id=d6b8382e">
<div class="jp-Cell-inputWrapper" tabindex="0">
<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
</div>
<div class="jp-InputArea jp-Cell-inputArea">
<div class="jp-InputPrompt jp-InputArea-prompt">In [ ]:</div>
<div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline">
<div class="cm-editor cm-s-jupyter">
<div class="highlight hl-julia"><pre><span></span><span class="n">why_q1</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="jp-Cell jp-MarkdownCell jp-Notebook-cell" id="cell-id=5f19d38c">
<div class="jp-Cell-inputWrapper" tabindex="0">
@@ -8430,6 +8535,20 @@ d) near 0*t </code></pre>
</div>
</div>
</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs" id="cell-id=edff9747">
<div class="jp-Cell-inputWrapper" tabindex="0">
<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
</div>
<div class="jp-InputArea jp-Cell-inputArea">
<div class="jp-InputPrompt jp-InputArea-prompt">In [ ]:</div>
<div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline">
<div class="cm-editor cm-s-jupyter">
<div class="highlight hl-julia"><pre><span></span><span class="n">why_q2</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="jp-Cell jp-MarkdownCell jp-Notebook-cell" id="cell-id=5041c355">
<div class="jp-Cell-inputWrapper" tabindex="0">
@@ -8463,6 +8582,20 @@ d) near 0*t </code></pre>
</div>
</div>
</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs" id="cell-id=87bc7c5c">
<div class="jp-Cell-inputWrapper" tabindex="0">
<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
</div>
<div class="jp-InputArea jp-Cell-inputArea">
<div class="jp-InputPrompt jp-InputArea-prompt">In [ ]:</div>
<div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline">
<div class="cm-editor cm-s-jupyter">
<div class="highlight hl-julia"><pre><span></span><span class="n">why_q3</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="jp-Cell jp-MarkdownCell jp-Notebook-cell" id="cell-id=841b690e">
<div class="jp-Cell-inputWrapper" tabindex="0">
@@ -8513,6 +8646,20 @@ d) 3 seconds</code></pre>
</div>
</div>
</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs" id="cell-id=a18a0a7d">
<div class="jp-Cell-inputWrapper" tabindex="0">
<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
</div>
<div class="jp-InputArea jp-Cell-inputArea">
<div class="jp-InputPrompt jp-InputArea-prompt">In [ ]:</div>
<div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline">
<div class="cm-editor cm-s-jupyter">
<div class="highlight hl-julia"><pre><span></span><span class="n">why_q4</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="jp-Cell jp-MarkdownCell jp-Notebook-cell" id="cell-id=df663f11">
<div class="jp-Cell-inputWrapper" tabindex="0">
@@ -8562,6 +8709,33 @@ d) 3 seconds</code></pre>
</div>
</div>
</div>
</div><div class="jp-Cell jp-CodeCell jp-Notebook-cell jp-mod-noOutputs" id="cell-id=d8923fae">
<div class="jp-Cell-inputWrapper" tabindex="0">
<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
</div>
<div class="jp-InputArea jp-Cell-inputArea">
<div class="jp-InputPrompt jp-InputArea-prompt">In [ ]:</div>
<div class="jp-CodeMirrorEditor jp-Editor jp-InputArea-editor" data-type="inline">
<div class="cm-editor cm-s-jupyter">
<div class="highlight hl-julia"><pre><span></span><span class="n">why_q5</span><span class="p">()</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
<div class="jp-Cell jp-MarkdownCell jp-Notebook-cell" id="cell-id=0ee77abe">
<div class="jp-Cell-inputWrapper" tabindex="0">
<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
</div>
<div class="jp-InputArea jp-Cell-inputArea"><div class="jp-InputPrompt jp-InputArea-prompt">
</div><div class="jp-RenderedHTMLCommon jp-RenderedMarkdown jp-MarkdownOutput" data-mime-type="text/markdown">
<div class="alert alert-block alert-info">
<b>Note:</b> If for some reason a cell keeps running forever, we can stop it with Kernel &gt; Interrupt or Kernel &gt; Restart (see tabs above).
</div>
</div>
</div>
</div>
</div>
<div class="jp-Cell jp-MarkdownCell jp-Notebook-cell" id="cell-id=a5d3730b">
<div class="jp-Cell-inputWrapper" tabindex="0">