Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tut] NumPy polymulx()

#1
NumPy polymulx()

<div><pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">numpy.polynomial.polynomial.polymulx©</pre>
<p class="has-pale-cyan-blue-background-color has-background">The <code><a href="https://numpy.org/doc/stable/reference/generated/numpy.polynomial.polynomial.polymulx.html#numpy.polynomial.polynomial.polymulx" target="_blank" rel="noreferrer noopener" title="https://numpy.org/doc/stable/reference/generated/numpy.polynomial.polynomial.polymulx.html#numpy.polynomial.polynomial.polymulx">numpy.polymulx</a></code> function multiplies the polynomial <code>c</code> with a value <code>x</code> which is the independent variable.</p>
<figure class="wp-block-table is-style-stripes">
<table>
<thead>
<tr>
<th>Arguments</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>c</strong></td>
<td>array_like or poly1d object</td>
<td>The input polynomials to be multiplied</td>
</tr>
</tbody>
</table>
</figure>
<p>The following table shows the return value of the function:</p>
<figure class="wp-block-table is-style-stripes">
<table>
<thead>
<tr>
<th></th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><strong>Return Value</strong></strong></td>
<td>ndarray or poly1d object</td>
<td>The polynomial resulting from the multiplication of the inputs. If either inputs is a poly1d object, then the output is also a poly1d object. Otherwise, it is a 1D array of polynomial coefficients from highest to lowest degree.</td>
</tr>
</tbody>
</table>
</figure>
<p>Let’s dive into some examples to show how the function is used in practice:</p>
<h3>Examples</h3>
<pre class="EnlighterJSRAW" data-enlighter-language="generic" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">
import numpy as np
import numpy.polynomial.polynomial as poly print(poly.polymulx([0]) == [0])
print(poly.polymulx([1]) == [0, 1])
for i in range(1, 5): ser = [0]*i + [1] tgt = [0]*(i + 1) + [1] print(poly.polymulx(ser) == tgt) '''
[ True]
[ True True]
[ True True True]
[ True True True True]
[ True True True True True]
[ True True True True True True] '''</pre>
<p>This function is inspired from <a href="https://github.com/Frank-qlu/recruit" target="_blank" rel="noreferrer noopener" title="https://github.com/Frank-qlu/recruit">this </a>Github repository.</p>
<p>Any master coder has a “hands-on” mentality with a bias towards action. Try it yourself—play with the function in the following interactive code shell:</p>
<p> <iframe height="400px" width="100%" src="https://repl.it/@finxter/polyx?lite=true" scrolling="no" frameborder="no" allowtransparency="true" allowfullscreen="true" sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"></iframe> </p>
<p><em><strong>Exercise</strong>: Change the parameters of your polynomials and print them without the comparisons. Do you understand where they come from?</em></p>
<p><em><strong>Master NumPy—and become a data science pro:</strong></em></p>
<figure class="wp-block-image size-large is-resized"><a href="https://blog.finxter.com/coffee-break-numpy/" target="_blank" rel="noopener noreferrer"><img src="https://blog.finxter.com/wp-content/uploads/2019/04/Cover_Coffee_Break_NumPy_v2-1-683x1024.png" alt="Coffee Break NumPy" class="wp-image-2860" width="342" height="512" srcset="https://blog.finxter.com/wp-content/uploads/2019/04/Cover_Coffee_Break_NumPy_v2-1.png 683w, https://blog.finxter.com/wp-content/uplo...00x300.png 200w, https://blog.finxter.com/wp-content/uplo...8x1152.png 768w, https://blog.finxter.com/wp-content/uplo...00x150.png 100w, https://blog.finxter.com/wp-content/uplo...0x1005.png 670w" sizes="(max-width: 342px) 100vw, 342px" /></a></figure>
<h2>Related Video</h2>
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio">
<div class="wp-block-embed__wrapper">
<div class="ast-oembed-container"><iframe title="NumPy Tutorial - Everything You Need to Know to Get Started" width="1400" height="788" src="https://www.youtube.com/embed/s55BEAJRTOk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></div>
</div>
</figure>
</div>


https://www.sickgaming.net/blog/2020/07/...-polymulx/
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016