Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use numpy to generate zero values for an array

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the knowledge of "how to use numpy to generate zero values of an array". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope this article "how to use numpy to generate zero values of an array" can help you solve the problem.

Today, when using numpy to write the sinc function, I accidentally found that the function could take 1 when x0. it was incredible that the function was meaningless when xroom0. after studying it, I found that numpy automatically used a very small number instead of 0 when generating an array.

In [2]: import numpy as npIn [3]: np.arange (- 1,1,0.1) Out [3]: array ([- 1.00000000e+00,-9.00000000e-01,-8.00000000e-01,-7.00000000e-01,-6.00000000e-01,-5.00000000e-01,-4.00000000e-01,-3.00000000e-01,-2.00000000e-01,-1.00000000e-01,-2.22044605e-16, 1.00000000e-01) 2.00000000e-01, 3.00000000e-01, 4.00000000e-01, 5.00000000e-01, 6.00000000e-01, 7.00000000e-01, 8.00000000e-01, 9.00000000e-01]) In [4]: np.linspace (- 1,0.9,20) Out [4]: array ([- 1.00000000e+00,-9.00000000e-01,-8.00000000e-01,-7.00000000e-01,-6.00000000e-01) -5.00000000e-01,-4.00000000e-01,-3.00000000e-01,-2.00000000e-01,-1.00000000e-01,-1.11022302e-16, 1.00000000e-01, 2.00000000e-01, 3.00000000e-01, 4.00000000e-01, 5.00000000e-01, 6.00000000e-01, 7.00000000e-01, 8.00000000e-01, 9.00000000e-01])

Where the arange and linspace functions are replaced by a very small number of eMur16 where they should have been zero.

That's all for "how to use numpy to generate zero values for arrays". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report