码迷,mamicode.com
首页 > 其他好文 > 详细

学习线性代数模块

时间:2017-11-03 15:19:11      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:obj   utils   open   multi   file   cti   none   导入   arrays   

Linear algebra

 

简介

When SciPy is built using the optimized ATLAS LAPACK and BLAS libraries, it has very fast linear algebra capabilities.

If you dig deep enough, all of the raw lapack and blas libraries are available for your use for even more speed.

All of these linear algebra routines expect an object that can be converted into a 2-dimensional array. The output of these routines is also a two-dimensional array.

 

1.模块文档

技术分享
NAME
    numpy.linalg
DESCRIPTION
    Core Linear Algebra Tools
    -------------------------
    Linear algebra basics:
    
    - norm            Vector or matrix norm
    - inv             Inverse of a square matrix
    - solve           Solve a linear system of equations
    - det             Determinant of a square matrix
    - lstsq           Solve linear least-squares problem
    - pinv            Pseudo-inverse (Moore-Penrose) calculated using a singular
                      value decomposition
    - matrix_power    Integer power of a square matrix
    
    Eigenvalues and decompositions:
    
    - eig             Eigenvalues and vectors of a square matrix
    - eigh            Eigenvalues and eigenvectors of a Hermitian matrix
    - eigvals         Eigenvalues of a square matrix
    - eigvalsh        Eigenvalues of a Hermitian matrix
    - qr              QR decomposition of a matrix
    - svd             Singular value decomposition of a matrix
    - cholesky        Cholesky decomposition of a matrix
    
    Tensor operations:
    
    - tensorsolve     Solve a linear tensor equation
    - tensorinv       Calculate an inverse of a tensor
    
    Exceptions:
    
    - LinAlgError     Indicates a failed linear algebra operation
View Code
技术分享
LA.info?
Type:        module
String form: <module numpy.linalg.info from F:\\Anaconda3\\lib\\site-packages\\numpy\\linalg\\info.py>
File:        f:\anaconda3\lib\site-packages\numpy\linalg\info.py
Docstring:  
Core Linear Algebra Tools
-------------------------
Linear algebra basics:

- norm            Vector or matrix norm
- inv             Inverse of a square matrix
- solve           Solve a linear system of equations
- det             Determinant of a square matrix
- lstsq           Solve linear least-squares problem
- pinv            Pseudo-inverse (Moore-Penrose) calculated using a singular
                  value decomposition
- matrix_power    Integer power of a square matrix

Eigenvalues and decompositions:

- eig             Eigenvalues and vectors of a square matrix
- eigh            Eigenvalues and eigenvectors of a Hermitian matrix
- eigvals         Eigenvalues of a square matrix
- eigvalsh        Eigenvalues of a Hermitian matrix
- qr              QR decomposition of a matrix
- svd             Singular value decomposition of a matrix
- cholesky        Cholesky decomposition of a matrix

Tensor operations:

- tensorsolve     Solve a linear tensor equation
- tensorinv       Calculate an inverse of a tensor

Exceptions:

- LinAlgError     Indicates a failed linear algebra operation
View Code

 

2.可用方法

‘bench‘,‘cholesky‘,‘cond‘,‘det‘,‘division‘,‘eig‘,‘array‘,‘eigh‘,‘eigvals‘,‘eigvalsh‘,‘info‘,‘inv‘,‘lapack_lite‘,‘linalg‘,‘lstsq‘,‘matrix_power‘,‘matrix_rank‘,‘multi_dot‘,‘norm‘,‘pinv‘,‘print_function‘,‘qr‘,‘slogdet‘,‘solve‘,‘svd‘,‘tensorinv‘,‘tensorsolve‘,‘test‘

eig : eigenvalues and right eigenvectors of general arrays
eigvalsh : eigenvalues of symmetric or Hermitian arrays.
eigh : eigenvalues and eigenvectors of symmetric/Hermitian arrays.

 

3.常用方法

首先导入相关模块

import numpy as np
from scipy import linalg as LA
#or
#from numpy import linalg as LA

 

3.1求数组的行列式:det

技术分享

技术分享

 

3.2求方阵的特征值、特征向量:eig

 技术分享

 

3.3求方阵的逆矩阵::inv

 技术分享

技术分享

 

3.4求解线性方程组:solve

Solve the system of equations x0 x1 9 and x0 x1 8:

 技术分享

 

3.5一个方阵的整数次幂:matrix_power

 技术分享

 技术分享

 

3.6计算在一个函数调用两个或两个以上的阵列的点积:multi_dot

 技术分享

4.官网文档

https://docs.scipy.org/doc/numpy/reference/routines.linalg.html

 

学习线性代数模块

标签:obj   utils   open   multi   file   cti   none   导入   arrays   

原文地址:http://www.cnblogs.com/jasonhaven/p/7777712.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!