np.linalg.inv():

  • (1)np.linalg.inv():矩阵求逆
  • (2)np.linalg.det():矩阵求行列式(标量)

np.linalg.norm

顾名思义, linalg=linear+algebra norm 则表示范数,首先需要注意的是范数是对向量(或者矩阵)的度量,是一个标量(scalar)

首先help(np.linalg.norm)查看其文档:

<code class="hljs mathematica has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">norm(x, ord=<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">None</span>, axis=<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">None</span>, keepdims=<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">False</span>)</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

这里我们只对常用设置进行说明, x 表示要度量的向量, ord 表示范数的种类,

参数 说明 计算方法
默认 二范数: 2 x21+x22++x2n
ord=2 二范数: 2 同上
ord=1 一范数: 1 |x1|+|x2|++|xn|
ord=np.inf 无穷范数: max(|xi|)
<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">>>> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">x</span> = np<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.array</span>([<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3</span>, <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span>])
>>> np<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.linalg</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.norm</span>(<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">x</span>)
<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5.</span>
>>> np<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.linalg</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.norm</span>(<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">x</span>, ord=<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>)
<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5.</span>
>>> np<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.linalg</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.norm</span>(<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">x</span>, ord=<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>)
<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.</span>
>>> np<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.linalg</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.norm</span>(<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">x</span>, ord=np<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.inf</span>)
<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">4</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li><li style="box-sizing: border-box; padding: 0px 5px;">7</li><li style="box-sizing: border-box; padding: 0px 5px;">8</li><li style="box-sizing: border-box; padding: 0px 5px;">9</li></ul>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值