当前位置:网站首页>01 NumPy介绍
01 NumPy介绍
2022-07-01 08:06:00 【懒笑翻】
什么是NumPy(Numerical Python)
NumPy是Python中科学计算的基础包,它是一个Python库,提供多维数组对象,各种派生对象(如掩码数组和矩阵),以及用于数组快速操作的各种API,包括数学、逻辑、形状操作、排序、选择、输入输出、离散傅立叶变换、基本线性代数,基本统计运算和随机模拟等。NumPy完全支持面向对象的方法。
NumPy 的前身 Numeric 最早是由 Jim Hugunin 与其它协作者共同开发,2005 年,Travis Oliphant 在 Numeric 中结合了另一个同性质的程序库 Numarray 的特色,并加入了其它扩展而开发了 NumPy。NumPy 为开放源代码并且由许多协作者共同维护开发。
NumPy的历史可以追溯到90年代中期,它的前身为Numeric(用C语言编写,主要用来调取C++中应用)和Numarray(用于处理高维数组,可灵活的索引、数据类型变换、广播等),2005年出现的NumPy作为继承者,吸取了Numeric中丰富的C API及Numarray的高维数组处理能力,成为Python科学计算生态系统的基础
NumPy包的核心是 ndarray 对象。它封装了python原生的同数据类型的 n 维数组,为了保证其性能优良,其中有许多操作都是代码在本地进行编译后执行的。
NumPy 是一个运行速度非常快的数学库,主要用于数组计算,包含:
- 一个强大的N维数组对象 ndarray
- 广播功能函数
- 整合 C/C++/Fortran 代码的工具
- 线性代数、傅里叶变换、随机数生成等功能
为什么NumPy这么快
1,底层是C,部分是Fortran
2,除了用C以外,numpy有自己的一个指令集合。可以提升运行速度。
3,在R里有一个东西叫向量化编程。速度是直接用内嵌数据结构的100倍左右。
矢量化描述了代码中没有任何显式的循环,索引等。这些是预编译的C代码中“幕后”优化的结果。如果没有矢量化,我们的代码就会被低效且难以阅读的for循环所困扰。矢量化代码有许多优点,其中包括:
- 矢量化代码更简洁,更易于阅读
- 更少的代码行通常意味着更少的错误
- 代码更接近于标准的数学符号(通常,更容易正确编码数学结构)
- 矢量化导致产生更多 “Pythonic” 代码。
一般来说,在NumPy中,所有操作,不仅仅是算术运算,而是逻辑,位,功能等,都以这种隐式的逐元素方式表现,即它们进行广播。
边栏推荐
- Aardio - Method of self constructed geticonhandle
- Basic number theory -- combinatorial number
- Anddroid 文本合成语音TTS实现
- Li Kou daily question - day 31 -1790 Can a string exchange be performed only once to make two strings equal
- 【批处理DOS-CMD命令-汇总和小结】-Cmd窗口中常用操作符(<、<<、&<、>、>>、&>、&、&&、||、|、()、;、@)
- SQL number injection and character injection
- php laravel微信支付
- Aardio - 自己构造的getIconHandle的方法
- [getting started] intercepting strings
- 如何使用layui将数据库中的数据以表格的形式展现出来
猜你喜欢
![[staff] key number (key number identification position | key number marking list | a major key identification principle | F, C, G position marking ascending | F major key identification principle | B](/img/48/e98d01830867baa742574e1b6e1096.jpg)
[staff] key number (key number identification position | key number marking list | a major key identification principle | F, C, G position marking ascending | F major key identification principle | B

Access report realizes subtotal function

Office365 - how to use stream app to watch offline files at any time

Learn reptiles for a month and earn 6000 a month? Tell you the truth about the reptile, netizen: I wish I had known it earlier

P4 安装bmv2 详细教程

OJ输入输出练习

How to check ad user information?

Gdip - hatchbrush pattern table

Gru of RNN

LSTM of RNN
随机推荐
How to get a SharePoint online site created using the office365 group template
5大组合拳,解决校园6大难题,护航教育信息化建设
Wang Yingqi, founder of ones, talks to fortune (Chinese version): is there any excellent software in China?
The Windows C disk is full
[getting started] intercepting strings
Differential: definition of total differential, partial derivative, gradient
Significance and measures of source code encryption
Anddroid 文本合成语音TTS实现
【网站架构】一招搞定90%的分布式事务,实打实介绍数据库事务、分布式事务的工作原理应用场景
Erreur de hauteur du clavier souple
[staff] key number (key number identification position | key number marking list | a major key identification principle | F, C, G position marking ascending | F major key identification principle | B
[untitled]
Aardio - 自己构造的getIconHandle的方法
PHP laravel wechat payment
Transaction method call @transactional
【批处理DOS-CMD命令-汇总和小结】-Cmd窗口中常用操作符(<、<<、&<、>、>>、&>、&、&&、||、|、()、;、@)
Precautions and skills in using regular expressions in golang
golang中的正则表达式使用注意事项与技巧
[redis] it takes you through redis installation and connection at one go
[force deduction 10 days SQL introduction] Day10 control flow
