You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>The <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.linalg.inv.html#numpy.linalg.inv" title="(in NumPy v1.24)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.linalg.inv()</span></code></a> function may be
364
+
<p>The <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.linalg.inv.html#numpy.linalg.inv" title="(in NumPy v1.26)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.linalg.inv()</span></code></a> function may be
Copy file name to clipboardExpand all lines: 4_function_spaces.html
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -334,11 +334,11 @@ <h2><span class="section-number">4.5. </span>Implementing function spaces in Pyt
334
334
<divclass="admonition hint">
335
335
<pclass="admonition-title">Hint</p>
336
336
<p><codeclass="xref py py-attr docutils literal notranslate"><spanclass="pre">cell_nodes</span></code> needs to
337
-
be integer-valued. If you choose to use <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.zeros.html#numpy.zeros" title="(in NumPy v1.24)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.zeros()</span></code></a>
337
+
be integer-valued. If you choose to use <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.zeros.html#numpy.zeros" title="(in NumPy v1.26)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.zeros()</span></code></a>
338
338
to create a matrix which you then populate with values, you
339
339
need to explicitly specify that you want a matrix of
340
340
integers. This can be achieved by passing the <codeclass="docutils literal notranslate"><spanclass="pre">dtype</span></code> argument
341
-
to <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.zeros.html#numpy.zeros" title="(in NumPy v1.24)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.zeros()</span></code></a>. For example <codeclass="docutils literal notranslate"><spanclass="pre">numpy.zeros((nrows,</span><spanclass="pre">ncols),</span><spanclass="pre">dtype=int)</span></code>.</p>
341
+
to <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.zeros.html#numpy.zeros" title="(in NumPy v1.26)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.zeros()</span></code></a>. For example <codeclass="docutils literal notranslate"><spanclass="pre">numpy.zeros((nrows,</span><spanclass="pre">ncols),</span><spanclass="pre">dtype=int)</span></code>.</p>
basis functions at each quadrature point.</p></li>
386
386
<li><p>Visit each cell in turn.</p></li>
387
387
<li><p>Construct the <codeclass="xref py py-meth docutils literal notranslate"><spanclass="pre">jacobian()</span></code> for that cell
388
-
and take the absolute value of its determinant (<aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.absolute.html#numpy.absolute" title="(in NumPy v1.24)"><codeclass="xref py py-data docutils literal notranslate"><spanclass="pre">numpy.absolute</span></code></a>
389
-
and <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html#numpy.linalg.det" title="(in NumPy v1.24)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.linalg.det()</span></code></a> will be useful here).</p></li>
388
+
and take the absolute value of its determinant (<aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.absolute.html#numpy.absolute" title="(in NumPy v1.26)"><codeclass="xref py py-data docutils literal notranslate"><spanclass="pre">numpy.absolute</span></code></a>
389
+
and <aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html#numpy.linalg.det" title="(in NumPy v1.26)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.linalg.det()</span></code></a> will be useful here).</p></li>
390
390
<li><p>Sum all of the arrays you have constructed over the correct
391
-
indices to a contribution to the integral (<aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.einsum.html#numpy.einsum" title="(in NumPy v1.24)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.einsum()</span></code></a>
391
+
indices to a contribution to the integral (<aclass="reference external" href="https://numpy.org/doc/stable/reference/generated/numpy.einsum.html#numpy.einsum" title="(in NumPy v1.26)"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">numpy.einsum()</span></code></a>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="n">A</span><spanclass="p">[</span><spanclass="n">nodes</span><spanclass="p">,</span><spanclass="n">nodes</span><spanclass="p">]</span><spanclass="o">+=</span><spanclass="n">m</span><spanclass="c1"># DON'T DO THIS!</span>
257
257
</pre></div>
258
258
</div>
259
-
<p>Unfortunately, <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.24)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> interprets this as an instruction to
259
+
<p>Unfortunately, <aclass="reference external" href="https://numpy.org/doc/stable/reference/index.html#module-numpy" title="(in NumPy v1.26)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">numpy</span></code></a> interprets this as an instruction to
260
260
insert a vector into the diagonal of <codeclass="docutils literal notranslate"><spanclass="pre">A</span></code>, and will complain that
261
261
the two-dimensional right hand side does not match the
262
262
one-dimensional left hand side. Instead, one has to employ the
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="n">A</span><spanclass="p">[</span><spanclass="n">np</span><spanclass="o">.</span><spanclass="n">ix_</span><spanclass="p">(</span><spanclass="n">nodes</span><spanclass="p">,</span><spanclass="n">nodes</span><spanclass="p">)]</span><spanclass="o">+=</span><spanclass="n">m</span><spanclass="c1"># DO THIS!</span>
which enable Python code to employ a variety of sparse matrix
322
322
formats using essentially identical operations to the dense matrix
323
323
case. The skeleton code already contains commands to construct
324
324
empty sparse matrices and to solve the resulting linear system. You
325
325
may, if you wish, experiment with choosing other sparse formats
326
-
from <aclass="reference external" href="http://scipy.github.io/devdocs/reference/sparse.html#module-scipy.sparse" title="(in SciPy v1.11.0.dev0+2027.1651835)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">scipy.sparse</span></code></a>, but it is very strongly suggested that
326
+
from <aclass="reference external" href="http://scipy.github.io/devdocs/reference/sparse.html#module-scipy.sparse" title="(in SciPy v1.13.0.dev)"><codeclass="xref py py-mod docutils literal notranslate"><spanclass="pre">scipy.sparse</span></code></a>, but it is very strongly suggested that
327
327
you do <strong>not</strong> switch to a dense numpy array; unless, that is, you
328
328
particularly enjoy running out of memory on your computer!</p>
0 commit comments