努比。Python中的polymul()

这个 努比。polymul() 方法计算两个多项式的乘积,并返回两个输入多项式“p1”和“p2”相乘得到的多项式。

null

语法: 努比。polymul(p1,p2) 参数: p1: [array_like或poly1D]输入多项式1。 p2: [array_like或poly1D]输入多项式2。

返回: 由输入相乘得到的多项式。

如果其中一个输入是 poly1D 对象,则输出也是一个poly1D对象,否则,按次递减的1D多项式系数数组。

代码:解释polymul()的Python代码

# Python code explaining
# numpy.polymul()
# importing libraries
import numpy as np
import pandas as pd
# Constructing polynomial
p1 = np.poly1d([ 1 , 2 ])
p2 = np.poly1d([ 4 , 9 , 5 , 4 ])
print ( "P1 : " , p1)
print ( " p2 : " , p2)


图片[1]-努比。Python中的polymul()-yiteyi-C++库

mul = np.polymul(p2, p1)
print ( "poly1D object : " )
print ( "Multiplication Result  : " , mul)


图片[2]-努比。Python中的polymul()-yiteyi-C++库

# Defining ndarray
x = np.array([ 1 , 2 ])
y = np.array([ 4 , 9 , 5 , 4 ])
mul = np.polymul(y, x)
print ( "1D array : " )
print ( "Multiplication Result  : " , mul)


图片[3]-努比。Python中的polymul()-yiteyi-C++库

© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享