python线性代数_线性代数-python

Linear Algebra (

scipy.linalg

)

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. In this section, some easier-to-use interfaces to these

routines are described.

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.

scipy.linalg vs numpy.linalg

scipy.linalg

contains

all

the

functions

in

numpy.linalg.

plus

some

other

more advanced ones not contained in numpy.linalg

Another advantage of using scipy.linalg over numpy.linalg is that it is

always

compiled

with

BLAS/LAPACK

support,

while

for

numpy

this

is

optional.

Therefore, the scipy version might be faster depending on how numpy was

installed.

Therefore, un

less you don’t want to add scipy as a dependency to your

numpy program, use scipy.linalg instead of numpy.linalg

numpy.matrix vs 2D numpy.ndarray

The

classes

that

represent

matrices,

and

basic

operations

such

as

matrix

multiplications and transpose are a part of numpy. For convenience, we

summarize the differences between numpy.matrix and numpy.ndarray here.

numpy.matrix is matrix class that has a more convenient interface than

numpy.ndarray for matrix operations. This class supports for example

MATLAB-like

creation

syntax

via

the,

has

matrix

multiplication

as

default

for the * operator, and contains I and T members that serve as shortcuts

for inverse and transpose:

>>> import numpy as np

>>> A = np.mat('[1 2;3 4]')

>>> A

matrix([[1, 2],

[3, 4]])

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值