首页 > 编程语言 >Python_numpy-基础以及进一步了解

Python_numpy-基础以及进一步了解

时间:2022-12-09 17:34:54浏览次数:32  
标签:Python data 视图 -- shape 了解 np numpy 向量

python

type() len() 
?

向量化编程-广播机制

 向量化-一次处理一个数字转换为一次处理一批数据,尽可能的少使用for循环,使用arrray为基本元素进行操作
    使用numpy的函数或者操作符进行运算
 广播机制: ndim shape 解决了限制条件下不同ndmi或shape的ndarray之间的运算 
 the Numpy's features which are the basic of much of its power: vectorization and broadcasting

数据和元数据-numerical python

the raw array data (from now on, referred to as the data buffer),
and the information about the raw array data-meta data

属性

 实数虚数:real imag -->(complex 复数元素)
 关于数据  data dtype ndim shape  size
 关于内存  flags itemsize nbytes
 扩展:    flat strides ctypes base

ndarray 的赋值Assignment、视图、拷贝和广播--shape和数据
  副本(Shallow Copy)和视图(view)- 
  副本--The copy SHOULD NOT be affected by the changes made to the original array.
  the difference between these two terms 
  and to know which operations return copies and which return views.
  a view without copying data around.-赋值还是视图,对其中一个数组的改变都会影响另外一个
      The view SHOULD be affected by the changes made to the original array. 
      视图方法可以实现不同的数组对象共享同样的数据-视图相对于原来的数组来说,除了数据是共享的,其他都是独立的
        	当 my_arr2 的形状发生改变时,my_arr1 的形状并不会发生改变。 --shape
            当 my_arr2 的数据发生改变时,my_arr1 会发生同样的改变。 
order
    “c_index”导致跟踪C顺序索引。 “f_index”导致跟踪Fortran-order索引

elementwise

数学运算

 np.dot np.matmul np.multipy np.inner np.outer np.cross 

数学	
点乘,也叫做向量的内积、数量积。对两个向量执行点乘运算,就是对着两个向量对应位置一一相乘之后求和的操作,点乘的结果是一个标量
   表征或计算两个向量之间的夹角,以及在b向量在a向量方向上的投影。 
两个向量的叉乘,又叫向量积、外积、叉积,叉乘的运算结果是一个向量而不是一个标量。
   并且两个向量的叉积与这两个向量组成的坐标平面垂直。 
   三维几何中,向量 a aa 和向量 b bb 的叉乘结果是一个向量,更为熟知的叫法是【法向量】,该向量垂直于a aa 和 b bb 向量构成的平面
   二维空间中,叉乘还有另外一个几何意义就是:a × b = a×b=a×b= 由向量 a aa 和向量 b bb 构成的平行四边形的面积

标签:Python,data,视图,--,shape,了解,np,numpy,向量
From: https://www.cnblogs.com/ytwang/p/16969532.html

相关文章