Python-Numpy(3)矩阵基本操作
2017-08-12 11:34
731 查看
import numpy as np a = np.arange(15).reshape(3, 5) a
a.shape
#the number of axes (dimensions) of the array a.ndim#维度
a.dtype.name
#the total number of elements of the array a.size
np.zeros ((3,4))
np.ones( (2,3,4), dtype=np.int32 )
#To create sequences of numbers np.arange( 10, 30, 5 )
np.arange( 0, 2, 0.3 )
np.arange(12).reshape(4,3)
np.random.random((2,3))
from numpy import pi np.linspace( 0, 2*pi, 100 )
np.sin(np.linspace( 0, 2*pi, 100 ))
#the product operator * operates elementwise in NumPy arrays a = np.array( [20,30,40,50] ) b = np.arange( 4 ) #print a #print b #b c = a-b #print c b**2 #print b**2 print a<35
#The matrix product can be performed using the dot function or method A = np.array( [[1,1], [0,1]] ) B = np.array( [[2,0], [3,4]] ) print A print B #print A*B print A.dot(B) print np.dot(A, B)
相关文章推荐
- Python中矩阵库Numpy基本操作详解
- python基础练习(三)—— numpy的矩阵基本操作
- Python中矩阵库Numpy基本操作
- python数据挖掘包numpy基本操作
- numpy - 矩阵基本操作
- Python机器学习:numpy的应用之基本操作命令
- python的Numpy之矩阵操作
- Numpy入门学习之(三) 数组、矩阵基本操作
- python之numpy对矩阵的操作
- python numpy包的使用一 基本操作
- Python机器学习:numpy之矩阵操作命令
- 【矩阵分解】Python下基于Numpy的四种矩阵基本分解的实现
- python numpy 矩阵操作
- numpy的基本操作(矩阵、文件)
- python numpy 使用笔记 矩阵操作
- python和numpy的基本操作速查
- Python numpy(ndarray 随机数组 常用操作 线性方程组和矩阵运算)
- Python使用numpy产生正态分布随机数的向量或矩阵操作示例
- Python Numpy 数组的初始化和基本操作
- 【Python】记录四:numpy矩阵操作(持续更新)