当前位置:网站首页>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中,所有操作,不仅仅是算术运算,而是逻辑,位,功能等,都以这种隐式的逐元素方式表现,即它们进行广播。
边栏推荐
- Day5: scanner object, next() and nextline(), sequential structure, selection structure, circular structure
- sqlalchemy创建MySQL_Table
- Latex formula code
- Li Kou daily question - day 31 -1790 Can a string exchange be performed only once to make two strings equal
- Differential: definition of total differential, partial derivative, gradient
- 力扣——求一组字符中的第一个回文字符
- Find the nearest n-th power of 2
- uni 热更新
- On June 30, 2022, the record of provincial competition + national competition of Bluebridge
- Latex table
猜你喜欢

Gru of RNN

PWN attack and defense world int_ overflow

base64
![[untitled]](/img/be/3523d0c14d555b293673af2b6fbcff.jpg)
[untitled]

Download xshell and xftp

SharePoint - modify web application authentication using PowerShell

What information does the supplier need to know about Audi EDI project?

【入门】提取不重复的整数

Array: question brushing record

0 basic introduction to single chip microcomputer: how to use digital multimeter and precautions
随机推荐
postgresql源码学习(26)—— Windows vscode远程调试Linux上的postgresql
Soft keyboard height error
Five combination boxing, solving six difficult problems on campus and escorting the construction of educational informatization
uni 热更新
Thesis learning -- Analysis and Research on similarity query of hydrological time series
软键盘高度报错
[getting started] extract non repeating integers
力扣——求一组字符中的第一个回文字符
EDA开源仿真工具verilator入门6:调试实例
Microsoft stream - how to modify video subtitles
[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
【力扣10天SQL入门】Day9 控制流
Oracle create auto increment ID
[force deduction 10 days SQL introduction] Day9 control flow
Precautions and skills in using regular expressions in golang
凸印的印刷原理及工艺介绍
Analysis of slice capacity expansion mechanism
Access报表实现小计功能
PWN attack and defense world int_ overflow
ContentType所有类型对比
