numpy sinh 用法及代码示例
用法:
numpy.sinh(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'sinh'>
双曲正弦,元素方式。
相当于1/2 * (np.exp(x) – np.exp(-x))或者-1j * np.sin(1j*x)。
– | 描述 |
---|---|
参数 | x: : array_like
输入数组。 结果存储的位置。如果提供,它必须具有输入广播到的形状。如果未提供或没有,则返回一个新分配的数组。元组(只能作为关键字参数)的长度必须等于输出的数量。 此条件通过输入广播。在条件为True的位置,将out数组设置为ufunc结果。在其他地方,out数组将保留其原始值。请注意,如果通过默认创建未初始化的输出数组out=None,条件中为False的位置将保持未初始化状态。 有关其他仅关键字的参数,请参见ufunc文档。 |
返回值 | y: : ndarray
相应的双曲正弦值。如果x是标量,则这是标量。 |
注意:
如果提供了out,则函数将结果写入其中,并返回对out的引用。 (请参见示例)
参考文献:
M. Abramowitz和I. A. Stegun,《数学函数手册》。纽约,纽约:多佛(Dover),1972年,页。 83。
例子:
>>> np.sinh(0)
0.0
>>> np.sinh(np.pi*1j/2)
1j
>>> np.sinh(np.pi*1j) # (exact value is 0)
1.2246063538223773e-016j
>>> # Discrepancy due to vagaries of floating point arithmetic.
>>> # Example of providing the optional output parameter
>>> out1 = np.array([0], dtype='d')
>>> out2 = np.sinh([0.1], out1)
>>> out2 is out1
True
>>> # Example of ValueError due to provision of shape mis-matched `out`
>>> np.sinh(np.zeros((3,3)),np.zeros((2,2)))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError:operands could not be broadcast together with shapes (3,3) (2,2)
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。